static public void AddLog(SeverityEnum severity, string source, string message) { try { using (var dc = new WMSContext()) { dc.Logs.Add(new Log { Severity = SeverityEnum.Exception, Message = message.Substring(0, Math.Min(250, message.Length)), Source = source }); dc.SaveChanges(); } } catch { } }
static public void AddException(Exception ex, [CallerMemberName] string member = "", [CallerFilePath] string fileName = "", [CallerLineNumber] int line = 0) { try { string[] str = fileName.Split('\\'); using (var dc = new WMSContext()) { dc.Logs.Add(new Log { Severity = SeverityEnum.Exception, Message = ex.Message.Substring(0, Math.Min(250, ex.Message.Length)), Source = $"{member} ({str[str.Length - 1]} {line})" }); dc.SaveChanges(); } } catch { } }