|
private void ReleaseRequestState(object sender, EventArgs eventArgs ) { // This event is a good choice for apply filters to the output // stream to the browser/client. By overriding the filter, you // can modify the output stream after all the response.write''''s are // done and before it gets to the browser. // Just add your own business rules to determine whether a filter // should be applied at all. try { if(HttpRes.ContentType != "text/html") { return; } // HttpRes.Filter = new IISCapture.FilterHtml(ref CaptureSession,HttpRes.Filter); } catch (Exception err) { ProcessError(err.Message); } }
// Custom methods
private bool IsSessionInTechSupportMode() { bool Ret = false; try { if (HttpApp.Context.Session[IISCapture.TroubleTicket.TechSupportEnable] != null) { if (HttpApp.Context.Session[IISCapture.TroubleTicket.TechSupportEnable].ToString() =="1") { Ret=true; } } } catch { } return Ret; }
private bool IsSessionATechSupportRep() { bool Ret = false; try { if (HttpApp.Context.Session[IISCapture.TroubleTicket.TechSupportRep] != null) { if (HttpApp.Context.Session[IISCapture.TroubleTicket.TechSupportRep].ToString() =="1") { Ret=true; } } } catch { } return Ret; }
private void ProcessError(string ErrMsg) { HttpApp.Context.Response.Write(ErrMsg); }
public void Dispose(){} } }
TroubleTicket.cs using System; using System.Web; using System.Collections; using System.Text; using System.IO; using System.Diagnostics;
namespace IISCapture { public class TroubleTicket { public const string TechSupportUserLastPage = "TechSupportUserLastPage"; public const string TechSupportEnable = "TechSupportEnable"; public const string TechSupportKey = "TechSupportKey"; public const string TechSupportRep = "TechSupportRep"; public const string TechSupportCache = "TechSupportCache_"; public const string TechSupportCacheSession = "Session_"; public const string TechSupportCacheForm = "Form_";
public TroubleTicket() { }
public void TransferToUrl(HttpContext oContext) { try { oContext.Response.Redirect(oContext.Session[TechSupportUserLastPage].ToString()); } catch (Exception) { throw; } } public string LoadNewSessionToApplication(HttpContext oContext,string GotoUrl) { string TroubleTicket=""; try { TroubleTicket = System.Guid.NewGuid().ToString(); LoadSessionToApplication(oContext,TroubleTicket,GotoUrl); LoadFormToApplication(oContext,TroubleTicket); } catch (Exception) { throw; } return TroubleTicket; } public void LoadSessionToApplication(HttpContext oContext,string TroubleTicket,string GotoUrl) { try { oContext.Session[TechSupportUserLastPage] = GotoUrl; oContext.Session[TechSupportKey] = TroubleTicket;
object[,] oValues = new object[2,oContext.Session.Keys.Count];
for(int i=0;i<oContext.Session.Keys.Count;i++) { oValues[0,i] = oContext.Session.Keys[i].ToString(); oValues[1,i] = oContext.Session[oContext.Session.Keys[i].ToString()]; }
oContext.Session[TechSupportEnable] = "1";
if ((object[,])oContext.Cache[TechSupportCache + TechSupportCacheSession + TroubleTicket.Trim()] != null) { oContext.Cache.Remove(TechSupportCache + TechSupportCacheSession + TroubleTicket.Trim()); }
oContext.Cache.Insert(TechSupportCache + TechSupportCacheSession + TroubleTicket, _ oValues,null,DateTime.MaxValue, TimeSpan.FromMinutes(10)); } catch (Exception) { throw; } return; } public void LoadFormToApplication(HttpContext oContext,string TroubleTicket) { bool Found=false; try { object[,] oValues = new object[2,oContext.Request.Form.Keys.Count];
for(int i=0;i<oContext.Request.Form.Keys.Count;i++) { oValues[0,i] = oContext.Request.Form.Keys[i].ToString(); oValues[1,i] = oContext.Request[oContext.Request.Form.Keys[i].ToString()]; Found=true; } if ((object[,])oContext.Cache[TechSupportCache + TechSupportCacheForm + TroubleTicket.Trim()] != null) { if (Found==true) { oContext.Cache.Remove(TechSupportCache + TechSupportCacheForm + TroubleTicket.Trim()); } }
oContext.Cache.Insert(TechSupportCache + TechSupportCacheForm + _ TroubleTicket,oValues,null,DateTime.MaxValue, TimeSpan.FromMinutes(10)); } catch (Exception) { throw; } return; } public string LoadSessionFromApplication(HttpContext oContext,string TroubleTicket) { string GotoUrl="";
try { object[,] oValues = (object[,])oContext.Cache[TechSupportCache + _ TechSupportCacheSession + TroubleTicket.Trim()]; for(int i=0;i<=oValues.GetUpperBound(1);i++) { oContext.Session[oValues[0,i].ToString()] = oValues[1,i]; }
oContext.Session[TechSupportEnable] = "0"; oContext.Session[TechSupportRep] = "1"; GotoUrl = oContext.Session[TechSupportUserLastPage].ToString(); } catch (Exception) { throw; } return GotoUrl; } public object[,] GetFormFromApplication(HttpContext oContext,string TroubleTicket) { object[,] oValues = null;
try { oValues = (object[,])oContext.Cache[TechSupportCache + TechSupportCacheForm + TroubleTicket.Trim()]; } catch (Exception) { throw; } return oValues; } } }
上一页 [1] [2] |