public ActionResult Edit(ImpactLevel level) { if (ModelState.IsValid) { db.ImpactLevels.Attach(level); db.Entry(level).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); UpdateImpactLevelMoneyValues(); return(RedirectToAction("Index")); } return(View(level)); }
public static void Save(this Exception ex, ImpactLevel impactLevel, string errorDescription) { using (var db = new DataContext()) { Log log = new Log(); if (errorDescription != null && errorDescription != "") { log.ErrorMessage = errorDescription; } log.ExceptionType = ex.GetType().FullName; var stackTrace = new StackTrace(ex, true); var allFrames = stackTrace.GetFrames().ToList(); foreach (var frame in allFrames) { log.FileName = frame.GetFileName(); log.LineNumber = frame.GetFileLineNumber(); var method = frame.GetMethod(); log.MethodName = method.Name; log.ClassName = frame.GetMethod().DeclaringType.ToString(); } log.ImpactLevel = impactLevel.ToString(); try { log.AppName = Assembly.GetCallingAssembly().GetName().Name; } catch { log.AppName = ""; } log.ErrorMessage = ex.Message; log.StackTrace = ex.StackTrace; if (ex.InnerException != null) { log.InnerException = ex.InnerException.ToString(); log.InnerExceptionMessage = ex.InnerException.Message; } try { log.CreatedAt = DateTime.Now; db.Logs.Add(log); db.SaveChanges(); } catch (Exception e) { } } }
/// <summary> /// Saves the exception details to ErrorLogging db with specified ImpactLevel and user message /// </summary> /// <param name="ex">The exception</param> /// <param name="impactLevel">The impact level.</param> /// <param name="errorDescription">The error Description.</param> public static void Save(this Exception ex, ImpactLevel impactLevel, string errorDescription) { using (var db = new ErrorLoggingDataContext()) { Log log = new Log(); if (errorDescription != null && errorDescription != "") { log.ErrorShortDescription = errorDescription; } log.ExceptionType = ex.GetType().FullName; var stackTrace = new StackTrace(ex, true); var allFrames = stackTrace.GetFrames().ToList(); foreach (var frame in allFrames) { log.FileName = frame.GetFileName(); log.LineNumber = frame.GetFileLineNumber(); var method = frame.GetMethod(); log.MethodName = method.Name; log.ClassName = frame.GetMethod().DeclaringType.ToString(); } log.ImpactLevel = impactLevel.ToString(); try { log.ApplicationName = Assembly.GetCallingAssembly().GetName().Name; } catch { log.ApplicationName = ""; } log.ErrorMessage = ex.Message; log.StackTrace = ex.StackTrace; if (ex.InnerException != null) { log.InnerException = ex.InnerException.ToString(); log.InnerExceptionMessage = ex.InnerException.Message; } log.IpAddress = ""; //get the ip address if (System.Diagnostics.Debugger.IsAttached) { log.IsProduction = false; } try { db.Logs.InsertOnSubmit(log); db.SubmitChanges(); } catch (Exception eex) { } } }
public override string ToString() { return(string.Join(",", new List <string> { s_statusesConverter.ConvertToString(Status).ToLowerInvariant().WithPrefixAndParentheses("status"), string.Join(",", SeverityLevel.Select(x => s_severityLevelsConverter.ConvertToString(x).ToLowerInvariant())).WithPrefixAndParentheses("severityLevel"), string.Join(",", ImpactLevel.Select(x => s_impactLevelsConverter.ConvertToString(x).ToLowerInvariant())).WithPrefixAndParentheses("impactLevel"), string.Join(",", RootCauseEntities).WithPrefixAndParentheses("rootCauseEntity"), string.Join(",", ManagementZoneIds).WithPrefixAndParentheses("managementZoneIds"), string.Join(",", ManagementZoneNames).WithPrefixAndParentheses("managementZones"), string.Join(",", ImpactedEntities).WithPrefixAndParentheses("impactedEntities"), string.Join(",", AffectedEntities).WithPrefixAndParentheses("affectedEntities"), string.Join(",", AffectedEntityTypes).WithPrefixAndParentheses("affectedEntityTypes"), string.Join(",", ProblemIds).WithPrefixAndParentheses("problemId"), string.Join(",", ProblemFilterIds).WithPrefixAndParentheses("problemFilterIds"), string.Join(",", ProblemFilterNames).WithPrefixAndParentheses("problemFilterNames"), string.Join(",", EntityTags.Select(kvp => $"{kvp.Key}:{kvp.Value}")).WithPrefixAndParentheses("entityTags"), string.Join(",", DisplayIds).WithPrefixAndParentheses("displayId") })); }
/// <summary> /// Saves the exception details to ErrorLogging db with specified ImpactLevel and user message /// </summary> /// <param name="ex">The exception</param> /// <param name="impactLevel">The impact level.</param> /// <param name="errorDescription">The error Description.</param> public static void Save(this Exception ex, ImpactLevel impactLevel, string errorDescription) { using (var db = new ErrorLoggingDataContext()) { Log log = new Log(); if (errorDescription != null && errorDescription != "") { log.ErrorShortDescription = errorDescription; } log.ExceptionType = ex.GetType().FullName; var stackTrace = new StackTrace(ex, true); var allFrames = stackTrace.GetFrames().ToList(); foreach (var frame in allFrames) { log.FileName = frame.GetFileName(); log.LineNumber = frame.GetFileLineNumber(); var method = frame.GetMethod(); log.MethodName = method.Name; log.ClassName = frame.GetMethod().DeclaringType.ToString(); } log.ImpactLevel = impactLevel.ToString(); try { log.ApplicationName = Assembly.GetCallingAssembly().GetName().Name; } catch { log.ApplicationName = ""; } log.ErrorMessage = ex.Message; log.StackTrace = ex.StackTrace; if (ex.InnerException != null) { log.InnerException = ex.InnerException.ToString(); log.InnerExceptionMessage = ex.InnerException.Message; } //var methodsName = System.Reflection.MethodBase.GetCurrentMethod(); //string projectName=System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString(); string whosOnCookie = Email.FindCookieValue("whoson"); if (!string.IsNullOrEmpty(whosOnCookie)) { log.WhosOnCookie = whosOnCookie; } string commercerserverId = Email.FindCookieValue("COMMERCE_SITE_Identity"); if (!string.IsNullOrEmpty(commercerserverId)) { log.CommerceServerId = commercerserverId; } log.IpAddress = Email.GetIPAddress(); if (System.Diagnostics.Debugger.IsAttached) { log.IsProduction = false; } try { db.Logs.InsertOnSubmit(log); db.SubmitChanges(); } catch (Exception eex) { } } }
/// <summary> /// Saves the exception details to ErrorLogging db with specified ImpactLevel /// </summary> /// <param name="ex">The exception.</param> /// <param name="impactLevel">The Impact level.</param> public static void Save(this Exception ex, ImpactLevel impactLevel) { Save(ex, impactLevel, ""); }
public static Data.Log Save(this Exception ex, HttpSessionStateBase Session, string callDetail, ImpactLevel impactLevel, string errorDescription) { using (var db = new ScreenPlayCRMEntities()) { Data.Log log = new Data.Log(); log.ContactId = SessionControl.SessionManager.GetContactId(Session); log.ClientId = SessionControl.SessionManager.GetClientId(Session); log.UserId = SessionControl.SessionManager.GetUserId(Session); log.CallDetail = callDetail; log.ErrorDate = DateTime.Now; log.LastModified = DateTime.Now; if (errorDescription != null && errorDescription != "") { log.ErrorShortDescription = errorDescription; } log.ExceptionType = ex.GetType().FullName; var stackTrace = new StackTrace(ex, true); var allFrames = stackTrace.GetFrames().ToList(); foreach (var frame in allFrames) { log.FileName = frame.GetFileName(); log.LineNumber = frame.GetFileLineNumber(); var method = frame.GetMethod(); log.MethodName = method.Name; log.ClassName = frame.GetMethod().DeclaringType.ToString(); } log.ImpactLevel = impactLevel.ToString(); try { log.ApplicationName = Assembly.GetCallingAssembly().GetName().Name; } catch { log.ApplicationName = ""; } log.ErrorMessage = ex.Message; log.StackTrace = ex.StackTrace; if (ex.InnerException != null) { log.InnerException = ex.InnerException.ToString(); log.InnerExceptionMessage = ex.InnerException.Message; } log.IpAddress = ""; try { db.Logs.Add(log); db.SaveChanges(); } catch (Exception eex) { } return(log); } }
public static Data.Log Save(this Exception ex, HttpSessionStateBase Session, string callDetail, ImpactLevel impactLevel) { return(Save(ex, Session, callDetail, impactLevel, "")); }
/// <summary> /// Saves the exception details to ErrorLogging db with specified ImpactLevel and user message /// </summary> /// <param name="ex">The exception</param> /// <param name="impactLevel">The impact level.</param> /// <param name="errorDescription">The error Description.</param> public static void Save(this Exception ex, ImpactLevel impactLevel, string errorDescription) { using (var db = new SMS.Models.SMSDbContext()) { Log log = new Log(); if (errorDescription != null && errorDescription != "") { log.ErrorShortDescription = errorDescription; } log.ExceptionType = ex.GetType().FullName; var stackTrace = new StackTrace(ex, true); var allFrames = stackTrace.GetFrames().ToList(); foreach (var frame in allFrames) { log.FileName = frame.GetFileName(); log.LineNumber = frame.GetFileLineNumber(); var method = frame.GetMethod(); log.MethodName = method.Name; log.ClassName = frame.GetMethod().DeclaringType.ToString(); } log.ImpactLevel = impactLevel.ToString(); try { log.ApplicationName = Assembly.GetCallingAssembly().GetName().Name; } catch { log.ApplicationName = ""; } log.ErrorMessage = ex.Message; log.StackTrace = ex.StackTrace; if (ex.InnerException != null) { log.InnerException = ex.InnerException.ToString(); log.InnerExceptionMessage = ex.InnerException.Message; } log.IpAddress = HttpContext.Current.Request.UserHostAddress; //get the ip address //log.HostName = HttpContext.Current.Request; //get the host name try { IPHostEntry host = Dns.GetHostEntry(log.IpAddress); log.HostName = host.HostName; } catch (SocketException se) { log.HostName = "Mobile/Unknown Host"; } log.ErrorDate = DateTime.Now; if (System.Diagnostics.Debugger.IsAttached) { log.IsProduction = false; } try { db.Logs.Add(log); db.SaveChanges(); } catch (Exception eex) { } finally { log.Dispose(); } } }