/// <summary> /// 添加一条新记录 /// </summary> /// <param name="ex">错误包</param> /// <returns></returns> public static int Insert(Exception ex) { if ((ex is System.Threading.ThreadAbortException)) { return(-1); } PfmErrorMDL errMdl = new PfmErrorMDL(); if (ex.InnerException != null) { errMdl.ErrTime = System.DateTime.Now; errMdl.ErrPage = string.IsNullOrEmpty(ex.InnerException.HelpLink) == true ? "非法数据!(页面信息)" : ex.InnerException.HelpLink; errMdl.ErrMessage = string.IsNullOrEmpty(ex.InnerException.Message) == true ? "非法数据!(错误信息)" : ex.InnerException.Message; errMdl.ErrTargetSite = string.IsNullOrEmpty(ex.InnerException.TargetSite.ToString()) == true ? "非法数据!(异常方法)" : ex.InnerException.TargetSite.ToString(); errMdl.ErrStackTrace = string.IsNullOrEmpty(ex.InnerException.StackTrace) == true ? "非法数据!(表示形式)" : ex.InnerException.StackTrace; errMdl.ErrSource = string.IsNullOrEmpty(ex.InnerException.Source) == true ? "非法数据!(数据源)" : ex.InnerException.Source; errMdl.ErrIp = GetIPs(); errMdl.ErrName = "未登录"; } else { errMdl.ErrTime = System.DateTime.Now; errMdl.ErrPage = string.IsNullOrEmpty(ex.HelpLink) == true ? "非法数据!(页面信息)" : ex.HelpLink; errMdl.ErrMessage = string.IsNullOrEmpty(ex.Message) == true ? "非法数据!(错误信息)" : ex.Message; errMdl.ErrTargetSite = string.IsNullOrEmpty(ex.TargetSite.ToString()) == true ? "非法数据!(异常方法)" : ex.TargetSite.ToString(); errMdl.ErrStackTrace = string.IsNullOrEmpty(ex.StackTrace) == true ? "非法数据!(表示形式)" : ex.StackTrace; errMdl.ErrSource = string.IsNullOrEmpty(ex.Source) == true ? "非法数据!(数据源)" : ex.Source; errMdl.ErrIp = GetIPs(); errMdl.ErrName = "未登录"; } return(PfmErrorBLL.Insert(errMdl)); }
/// <summary> /// 向数据表PfmError中插入一条新记录 /// </summary> /// <param name="pfmError">PfmError实体对象</param> /// <returns></returns> public static int Insert(PfmErrorMDL pfmError) { if (pfmError == null) { return(0); } return(PfmErrorBLL._dal.Insert(pfmError)); }