Esempio n. 1
0
        /// <summary>
        /// 保存系统异常
        /// </summary>
        /// <param name="e">异常</param>
        /// <param name="request">当前信息的请求参数</param>

        private static void save(Exception e, object request = null)
        {
            string condtion = string.Empty;

            if (request != null)
            {
                condtion = JsonConvert.SerializeObject(request);
            }
            using (var db = new SysModelContainer())
            {
                Db_SysExceptionLog d = new Db_SysExceptionLog()
                {
                    condtion   = condtion,
                    createdOn  = DateTime.Now,
                    message    = e.Message,
                    msgType    = SysMessageType.异常.GetHashCode(),
                    source     = e.Source,
                    stackTrace = e.StackTrace,
                    targetSite = e.TargetSite == null ? null : e.TargetSite.ToString(),
                    errorCode  = SysExceptionType.系统.GetHashCode()
                };
                db.Db_SysMsgSet.Add(d);
                db.SaveChanges();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 保存自定义的异常
 /// </summary>
 private void save()
 {
     using (var db = new SysModelContainer()) {
         Db_SysExceptionLog d = new Db_SysExceptionLog()
         {
             condtion   = this.condtion,
             createdOn  = DateTime.Now,
             message    = this.Message,
             msgType    = SysMessageType.异常.GetHashCode(),
             source     = this.Source,
             stackTrace = this.StackTrace,
             targetSite = this.TargetSite == null? null :this.TargetSite.ToString(),
             errorCode  = SysExceptionType.自定义.GetHashCode()
         };
         db.Db_SysMsgSet.Add(d);
         db.SaveChanges();
     }
 }