Ejemplo n.º 1
0
        /// <summary>
        /// 添加错误信息
        /// </summary>
        private static void AddErrorEntity(Exception ex)
        {
            ex = ex == null && HttpContext.Current != null?HttpContext.Current.Server.GetLastError() : ex;

            if (!CheckSave(ex))
            {
                return;
            }
            var info = new ErrorEntity
            {
                Address  = HttpContext.Current.Request.Url.ToString(),
                Device   = HttpContext.Current.Request.UserAgent,
                Ip       = GetClientIp(),
                SaveType = SaveType.Add
            };

            info.SetEntity(ex);
            FillIdentity(info);
            Ioc.Resolve <IApplicationService, ErrorEntity>().Save(info);
            if (ConfigurationManager.GetSetting <bool>("IsDebug"))
            {
                throw ex;
            }
            var url = UrlExtension.GetUrl(null, "PresentationAdminHomeUrl");

            HttpContext.Current.Response.Redirect(string.Format("{0}/Errors/Generic.htm", url));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加异常
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="ex"></param>
        static public void AddExceptionLog(this Page handle, Exception ex = null)
        {
            ex = ex == null && HttpContext.Current != null?HttpContext.Current.Server.GetLastError() : ex;

            var info = new ErrorEntity
            {
                Address  = HttpContext.Current.Request.Url.ToString(),
                Device   = HttpContext.Current.Request.UserAgent,
                Ip       = GetClientIp(),
                SaveType = SaveType.Add
            };

            info.SetEntity(ex);
            FillIdentity(info);
            Ioc.Resolve <IApplicationService, ErrorEntity>().Save(info);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="ex"></param>
        protected virtual void Add(Exception ex)
        {
            var info = new ErrorEntity
            {
                Address = HttpContext.Current == null ? "" : HttpContext.Current.Request.Url.ToString(),
                Ip      = HttpContext.Current == null ? "" : HttpContext.Current.Request.UserHostAddress,
                Device  = HttpContext.Current == null ? "" : HttpContext.Current.Request.UserAgent,
                Account = new AccountEntity {
                    Id = 0
                },
                SaveType = SaveType.Add
            };

            info.SetEntity(ex);
            Creator.Get <IContext>().Set(info, info, info.SaveSequence);
            Creator.Get <IContext>().Commit(Creator.Get <IContext>().Save());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 添加错误信息
        /// </summary>
        public static void AddExceptionLog(this Controller handle, Exception ex, IdentityEntity identity = null)
        {
            var info = new ErrorEntity
            {
                Address  = HttpContext.Current.Request.Url.ToString(),
                Ip       = HttpContextHelper.GetClientIp(),
                Device   = HttpContext.Current.Request.UserAgent,
                SaveType = SaveType.Add
            };

            if (identity != null)
            {
                info.Account = new AccountEntity {
                    Id = identity.Id
                };
            }
            info.SetEntity(ex);
            Ioc.Resolve <IApplicationService, ErrorEntity>().Save(info);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 添加日志
        /// </summary>
        /// <param name="ex"></param>
        public static void AddError(Exception ex)
        {
            if (ex == null)
            {
                return;
            }
            var info = new ErrorEntity
            {
                Address  = "Beeant.Distributed.Service.Host",
                Device   = "",
                Ip       = "127.0.0.1",
                SaveType = SaveType.Add
            };

            info.SetEntity(ex);
            info.Account = new AccountEntity {
                Id = 0
            };
            Ioc.Resolve <IApplicationService, EntityInfo>().Save(info);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 添加错误信息
        /// </summary>
        protected virtual void AddErrorInfo(Exception ex, TaskEntity task)
        {
            if (ex == null)
            {
                return;
            }
            var info = new ErrorEntity
            {
                Address  = task.ClassName,
                Device   = task.Args,
                Ip       = "127.0.0.1",
                SaveType = SaveType.Add
            };

            info.SetEntity(ex);
            info.Account = new AccountEntity {
                Id = 0
            };
            Ioc.Resolve <IApplicationService, EntityInfo>().Save(info);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 添加异常
 /// </summary>
 private static void AddExceptionLog()
 {
     try
     {
         var url    = ConfigurationManager.GetSetting <string>("PresentationWebsiteSharedUrl");
         var action = CheckSave();
         if (string.IsNullOrEmpty(action))
         {
             var info = new ErrorEntity
             {
                 Address  = HttpContext.Current.Request.Url.ToString(),
                 Ip       = HttpContextHelper.GetClientIp(),
                 Device   = HttpContext.Current.Request.UserAgent,
                 SaveType = SaveType.Add
             };
             info.SetEntity(HttpContext.Current.Server.GetLastError());
             info.Account = new AccountEntity {
                 Id = 0
             };
             Ioc.Resolve <IApplicationService, ErrorEntity>().Save(info);
             action = "General";
         }
         if (ConfigurationManager.GetSetting <bool>("IsDebug"))
         {
             throw HttpContext.Current.Server.GetLastError();
         }
         HttpContext.Current.Response.Redirect(string.Format("{0}/Error/{1}", url, action));
     }
     catch (Exception ex)
     {
         if (ex.InnerException != null)
         {
             throw ex.InnerException;
         }
         throw ex;
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 添加异常
 /// </summary>
 /// <param name="handle"></param>
 static public void AddApiErrorLog(this HttpApplication handle)
 {
     try
     {
         var ex     = HttpContext.Current.Server.GetLastError();
         var action = CheckSave();
         if (string.IsNullOrEmpty(action))
         {
             var info = new ErrorEntity
             {
                 Address  = HttpContext.Current.Request.Url.ToString(),
                 Ip       = HttpContextHelper.GetClientIp(),
                 Device   = HttpContext.Current.Request.UserAgent,
                 SaveType = SaveType.Add
             };
             info.SetEntity(ex);
             info.Account = new AccountEntity {
                 Id = 0
             };
             Ioc.Resolve <IApplicationService, ErrorEntity>().Save(info);
         }
         if (ConfigurationManager.GetSetting <bool>("IsDebug"))
         {
             throw ex;
         }
         HttpContext.Current.Response.Redirect("/Shared/Error");
     }
     catch (Exception ex)
     {
         if (ex.InnerException != null)
         {
             throw ex.InnerException;
         }
         throw ex;
     }
 }