public void Insert(SystemError error)
 {
     string sql = string.Format(@"INSERT INTO {0} ({1},{2},{3},{4},{5},{6}) VALUES (@{1},@{2},@{3},@{4},@{5},@{6})", SystemError.TABLENAME, SystemError.ERRORMESSAGE,
         SystemError.ERRORLEVEL, SystemError.STACKTRACK, SystemError.PAGEURL, SystemError.REMARKS, SystemError.IPFIELD);
     base.ExecuteNonQuery(sql, new SqlParameter(SystemError.ERRORMESSAGE, error.ErrorMessage),
         new SqlParameter(SystemError.ERRORLEVEL, (int)error.ErrorLevel),
         new SqlParameter(SystemError.STACKTRACK, error.StackTrack),
         new SqlParameter(SystemError.PAGEURL, error.PageUrl),
         new SqlParameter(SystemError.REMARKS, error.Remarks),
         new SqlParameter(SystemError.IPFIELD, error.IP));
 }
Example #2
0
 public void LogError(Exception innerException, ErrorLevel level, string url, string remark = "")
 {
     SystemError error = new SystemError
     {
         ErrorLevel = level,
         ErrorMessage = innerException.Message,
         StackTrack = innerException.StackTrace ?? string.Empty,
         PageUrl = url,
         Remarks = remark,
         IP = IPHelper.IPAddress
     };
     try
     {
         DaSystemErrorLog.Insert(error);
     }
     catch (Exception ex)
     {
         Func<string> getDividingLines = () => { string line = string.Empty; for (int i = 0; i < 20; i++)line += "-"; return line; };
         LogConsole.Error(getDividingLines() + "插入日志失败" + getDividingLines());
         LogConsole.Error("插入SystemError失败!", ex);
         LogConsole.Error(getDividingLines() + getDividingLines());
     }
 }