public override void OnException(ExceptionContext filterContext) { int u_id = UserInfo.Uid; string bcxx = filterContext.Exception.Message; //报错信息 string bcController = filterContext.Controller.ToString(); //报错控制器 string bcff = filterContext.Exception.TargetSite.ToString(); //报错方法 string bcdx = filterContext.Exception.Source; //报错对象 string bcwz = filterContext.Exception.StackTrace; //引发异常位置 var message = "报错信息:" + bcxx + ",报错控制器:" + bcController + ",报错方法:" + bcff + ",报错对象:" + bcdx + ",报错位置:" + bcwz; //AddLocLog.AddUserLog(u_id, 4, RequestHelper.GetClientIp(), "错误日志", "报错信息:" + bcxx + ",报错控制器:" + bcController + ",报错方法:" + bcff + ",报错对象:" + bcdx + ",报错位置:" + bcwz);//写入报错日志 GlobalErrorLogger.Log(message, filterContext.Exception.Source); filterContext.ExceptionHandled = true;//设置异常已处理 if (filterContext.HttpContext.Request.IsAjaxRequest()) { filterContext.Result = new JsonResult { Data = new { success = 9997, msg = "出错了!", Redirect = "/Home/Error" } }; } else { filterContext.Result = new RedirectResult("/Home/Error"); } base.OnException(filterContext); }
public void Start(HttpConfiguration configuration) { lock (this) { if (this.initialized) { throw new InvalidOperationException("The WebBootstrapper can't be initialized more than once."); } log4net.Config.XmlConfigurator.Configure(); IUnityContainer unityContainer = UnityContainerConfig.CreateAndRegisterUnityContainer(); DependencyModuleResolver.RegisterDependencyModulesFromLoadedAssemblies(unityContainer); var logger = unityContainer.Resolve <ILog>(); logger.Debug($"{AppDomain.CurrentDomain.BaseDirectory}: {unityContainer.GetMappingAsString()}"); GlobalErrorLogger.RegisterErrorHandlers(); var unityDependencyResolver = new UnityDependencyResolver(unityContainer); configuration.DependencyResolver = unityDependencyResolver; this.initialized = true; } }
public JsonResult CustomAdd(JMP.MDL.CsComplainOrder mode) { object retJson = new { success = 0, msg = "操作失败" }; if (mode.Id > 0) { #region 修改 //得到一个实体对象 cscomod = cscobll.GetModel(mode.Id); //拷贝 var mocolne = cscomod.Clone(); cscomod.ComplainTypeId = mode.ComplainTypeId; cscomod.ComplainTypeName = mode.ComplainTypeName; cscomod.ComplainDate = mode.ComplainDate; cscomod.Envidence = mode.Envidence; cscomod.DownstreamStartTime = mode.DownstreamStartTime; cscomod.DownstreamEndTime = mode.DownstreamEndTime; if (cscobll.Update(cscomod)) { Logger.ModifyLog("修改投诉", mocolne, cscomod); retJson = new { success = 1, msg = "修改成功" }; } else { retJson = new { success = 0, msg = "修改失败" }; } #endregion } else { //判断该订单是否已经添加到投诉表中 var exists = cscobll.GetModelList(string.Format("OrderNumber='{0}'", mode.OrderNumber.Replace("'", "''"))); if (exists != null && exists.Count > 0) { return(Json(new { success = 0, msg = "此订单已提交过了" })); } var time = DateTime.ParseExact(mode.OrderNumber.Substring(0, 8), "yyyyMMdd", CultureInfo.CurrentCulture); var tableName = WeekDateTime.GetOrderTableName(time.ToString(CultureInfo.InvariantCulture)); mode.state = 0; mode.CreatedOn = DateTime.Now; mode.FounderId = UserInfo.UserId; mode.FounderName = UserInfo.UserName; mode.OrderTable = tableName; try { //从订单归档表读取订单金额 var orderBll = new JMP.BLL.jmp_order(); var archiveOrder = orderBll.FindOrderByTableNameAndOrderNo(tableName, mode.OrderNumber); if (archiveOrder == null || archiveOrder.o_price <= 0) { retJson = new { success = 0, msg = "添加失败[读取订单金额失败]" }; GlobalErrorLogger.Log("添加失败[读取订单金额失败]", summary: "添加投诉失败"); return(Json(retJson)); } mode.Price = archiveOrder.o_price; } catch (Exception ex) { retJson = new { success = 0, msg = "添加失败[读取订单金额失败]" }; GlobalErrorLogger.Log("添加失败[读取订单金额失败]", summary: "添加投诉失败"); return(Json(retJson)); } int num = cscobll.Add(mode); if (num > 0) { Logger.CreateLog("添加投诉", mode); retJson = new { success = 1, msg = "添加成功" }; } else { retJson = new { success = 0, msg = "添加失败" }; } } return(Json(retJson)); }