public override void OnException(ExceptionContext httpContext) { XElement error = new XElement("Error"); string emailbody = "<table border='1'>"; emailbody += "<tr><td>User</td><td>" + (string)httpContext.HttpContext.Session["LogonUserName"] + "</td></tr>"; emailbody += "<tr><td>Site</td><td>" + httpContext.HttpContext.Request.Url.ToString() + "</td></tr>"; emailbody += "<tr><td>ControllerName</td><td>" + httpContext.Controller.ToString() + "</td></tr>"; emailbody += "<tr><td>Method</td><td>" + httpContext.Exception.TargetSite.Name + "</td></tr>"; emailbody += "<tr><td>Message</td><td>" + httpContext.Exception.Message + "</td></tr>"; emailbody += "<tr><td>InnerException</td><td>" + httpContext.Exception.InnerException + "</td></tr>"; emailbody += "<tr><td>StackTrace</td><td>" + httpContext.Exception.StackTrace.ToString() + "</td></tr>"; error.Add(new XElement("ControllerName", httpContext.Controller.ToString())); error.Add(new XElement("Method", httpContext.Exception.TargetSite.Name)); error.Add(new XElement("Message", httpContext.Exception.Message)); error.Add(new XElement("InnerException", httpContext.Exception.InnerException)); error.Add(new XElement("StackTrace", httpContext.Exception.StackTrace.ToString())); error.Add(new XElement("UserAgent", httpContext.HttpContext.Request.UserAgent)); error.Add(new XElement("UserHostAddress", httpContext.HttpContext.Request.UserHostAddress)); error.Add(new XElement("UserHostName", httpContext.HttpContext.Request.UserHostName)); error.Add(new XElement("Params", httpContext.HttpContext.Request.Params.ToString())); XElement para = new XElement("Parameters"); for (int x = 0; x < httpContext.HttpContext.Request.Form.Count; x++) { XElement parameters = new XElement("para"); parameters.Add(new XElement("Name", httpContext.HttpContext.Request.Form.AllKeys[x])); parameters.Add(new XElement("Value", httpContext.HttpContext.Request.Form[httpContext.HttpContext.Request.Form.AllKeys[x]])); emailbody += "<tr><td>" + httpContext.HttpContext.Request.Form.AllKeys[x] + "</td><td>" + httpContext.HttpContext.Request.Form[httpContext.HttpContext.Request.Form.AllKeys[x]] + "</td></tr>"; para.Add(parameters); } error.Add(para); DOS_DBDataContext sql_conn = new DOS_DBDataContext(); sql_conn.usp_insertlogging('E', "System", "SystemError", "SystemError", 1, "NA", "", error); sendErrorEmail(emailbody, (string)httpContext.HttpContext.Session["ErrorRecipients"], (string)httpContext.HttpContext.Session["SMTPAccount"], (string)httpContext.HttpContext.Session["SMTPAccountPassword"], (string)httpContext.HttpContext.Session["SMTPAddress"]); httpContext.Result = new RedirectToRouteResult(new RouteValueDictionary( new { controller = "Error", action = "DisplayError" })); }
protected void Session_Start(object sender, EventArgs e) { WebClient client = new WebClient(); DOS_DBDataContext sql_conn = new DOS_DBDataContext(); Session["FileIOStream"] = null; Session["FileName"] = ""; Session["TextfieldLength"] = sql_conn.usp_getAllTextFieldLengthInXML().ElementAt(0).XML.ToString(); IEnumerable <usp_getAppConfigResult> res = sql_conn.usp_getAppConfig().ToList(); for (int x = 0; x < res.Count(); x++) { //Not using onemap.sg api. using googlemap api instead. if (res.ElementAt(x).ConfigName == "OneMapTokenURL") { getOneMapToken(res.ElementAt(x).value.Trim()); } else if (res.ElementAt(x).ConfigName == "PostalCodeRetrivalURL") { Session[res.ElementAt(x).ConfigName] = res.ElementAt(x).value.Trim().Replace("<KSTOKEN>", (string)Session["OneMapToken"]); } else if (res.ElementAt(x).ConfigName == "BasicSearchRetrivalURL") { Session[res.ElementAt(x).ConfigName] = res.ElementAt(x).value.Trim().Replace("<KSTOKEN>", (string)Session["OneMapToken"]); } else { Session[res.ElementAt(x).ConfigName] = res.ElementAt(x).value.Trim(); } } //not using onemap.sg api, using googlemap instead if (((string)Session["OneMapToken"]).ToString() == "null") { Session["AutoPostalCode"] = "Off"; } if (((string)Session["SystemMode"]).ToUpper() != "FULL") { IEnumerable <usp_getAllEmailResult> emailres = sql_conn.usp_getAllEmail().ToList(); for (int x = 0; x < emailres.Count(); x++) { Session[emailres.ElementAt(x).EmailType] = emailres.ElementAt(x).EmailContent; } } }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (Session["UserInformation"] == null && User.Identity.IsAuthenticated) { DOS_DBDataContext sql_conn = new DOS_DBDataContext(); Session["UserInformation"] = sql_conn.usp_getUserInformation(User.Identity.Name).ElementAt(0).XML_F52E2B61_18A1_11d1_B105_00805F49916B; Session["AccessRight"] = sql_conn.usp_getModuleFunctionsAccessRight(User.Identity.Name).ElementAt(0).FunctionAccessRight; Session["LogonUserName"] = sql_conn.usp_getStaffName(User.Identity.Name).ElementAt(0).Name; WebClient client = new WebClient(); Session["TextfieldLength"] = sql_conn.usp_getAllTextFieldLengthInXML().ElementAt(0).XML.ToString(); IEnumerable <usp_getAppConfigResult> res = sql_conn.usp_getAppConfig().ToList(); for (int x = 0; x < res.Count(); x++) { if (res.ElementAt(x).ConfigName == "OneMapTokenURL") { getOneMapToken(res.ElementAt(x).value.Trim()); } else if (res.ElementAt(x).ConfigName == "PostalCodeRetrivalURL") { Session[res.ElementAt(x).ConfigName] = res.ElementAt(x).value.Trim().Replace("<KSTOKEN>", (string)Session["OneMapToken"]); } else { Session[res.ElementAt(x).ConfigName] = res.ElementAt(x).value.Trim(); } } if (((string)Session["OneMapToken"]).ToString() == "null") { Session["AutoPostalCode"] = "Off"; } } base.OnActionExecuting(filterContext); }