Example #1
0
 public string UpdateData(MecidineModel objMecidineModel)
 {
     objClsMecidicne = new ClsMecidicne();
     try
     {
         return(objClsMecidicne.UpdateData(objMecidineModel));
     }
     catch (Exception ex)
     {
         strGuid      = DateTime.Now.ToString("ddMMyyyyhhmmss");
         levelCounter = 0;
         ClsLogging.writefile("---------------------------------------------------------------------------------", ClsLogging.LogType.CL_Exception);
         ClsLogging.writefile("Exception Ouccred Section Start", ClsLogging.LogType.CL_Exception);
         ClsLogging.writefile("Unique ID " + strGuid, ClsLogging.LogType.CL_Exception);
         ClsLogging.writefile("Exception In UpdateData" + ex.Message, ClsLogging.LogType.CL_Exception);
         foreach (StackFrame stackFrame in new StackTrace(ex, true).GetFrames().Where(x => x.GetFileLineNumber() != 0 && x.GetFileName() != null))
         {
             ClsLogging.writefile("Level : " + Convert.ToString(++levelCounter), ClsLogging.LogType.CL_Exception);
             ClsLogging.writefile("File Name : " + stackFrame.GetFileName(), ClsLogging.LogType.CL_Exception);
             ClsLogging.writefile("Method Name : " + stackFrame.GetMethod().Name, ClsLogging.LogType.CL_Exception);
             ClsLogging.writefile("Line Number : " + stackFrame.GetFileLineNumber(), ClsLogging.LogType.CL_Exception);
             ClsLogging.writefile("Col Number : " + stackFrame.GetFileColumnNumber(), ClsLogging.LogType.CL_Exception);
         }
         ClsLogging.writefile("Exception Ouccred Section End", ClsLogging.LogType.CL_Exception);
         throw ex;
     }
 }
        public void OnException(ExceptionContext filterContext)
        {
            objStringBuilder = new StringBuilder();
            st = new StackTrace(filterContext.Exception, true);
            objStringBuilder.AppendLine("Controller Name : " + filterContext.RouteData.Values["controller"]);
            objStringBuilder.AppendLine("<br/>" + "Action Name : " + filterContext.RouteData.Values["action"]);
            objStringBuilder.AppendLine("<br/>" + "Message : " + filterContext.Exception.Message);
            foreach (StackFrame stackFrame in st.GetFrames().Where(x => x.GetFileLineNumber() != 0 && x.GetFileName() != null))
            {
                objStringBuilder.AppendLine("<br/>" + "Level : " + Convert.ToString(++levelCounter));
                objStringBuilder.AppendLine("<br/>" + "File Name : " + stackFrame.GetFileName());
                objStringBuilder.AppendLine("<br/>" + "Method Name : " + stackFrame.GetMethod().Name);
                objStringBuilder.AppendLine("<br/>" + "Line Number : " + stackFrame.GetFileLineNumber());
                objStringBuilder.AppendLine("<br/>" + "Col Number : " + stackFrame.GetFileColumnNumber());
            }

            ClsLogging.writefile("---------------------------------------------------------------------------------", ClsLogging.LogType.CL_Exception);
            ClsLogging.writefile("Exception Ouccred Section Start", ClsLogging.LogType.CL_Exception);
            ClsLogging.writefile(objStringBuilder.ToString().Replace("<br/>", "\t\t\t\t"), ClsLogging.LogType.CL_Exception);
            ClsLogging.writefile("Exception Ouccred Section End", ClsLogging.LogType.CL_Exception);
            if (filterContext.Exception is HttpAntiForgeryException)
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(
                                                                     new
                {
                    action              = "XSS",
                    controller          = "Common",
                    id                  = new HttpException(null, filterContext.Exception).GetHttpCode().ToString(),
                    exceptionAction     = (string)filterContext.RouteData.Values["action"],
                    exceptionController = (string)filterContext.RouteData.Values["controller"]
                }));
            }
            else
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(
                                                                     new
                {
                    action              = "Exception",
                    controller          = "Common",
                    id                  = new HttpException(null, filterContext.Exception).GetHttpCode().ToString(),
                    exceptionAction     = (string)filterContext.RouteData.Values["action"],
                    exceptionController = (string)filterContext.RouteData.Values["controller"]
                }));
            }
            filterContext.ExceptionHandled = true;
        }