public ActionResult SaveForm(KeyBoxEntity entity) { Operator user = OperatorProvider.Provider.Current(); WriteLog.AddLog($"用户:{user.UserName} id:{user.UserId}开始编辑钥匙管理数据 \r\n {JsonConvert.SerializeObject(entity)}", "KeyBox"); try { if (string.IsNullOrEmpty(entity.CreateUserId)) { entity.CreateDate = DateTime.Now; entity.CreateUserId = user.UserId; entity.CreateUserName = user.UserName; } entity.ModifyDate = DateTime.Now; entity.ModifyUserId = user.UserId; entity.ModifyUserName = user.UserName; List <KeyBoxEntity> dataList = new List <KeyBoxEntity>(); dataList.Add(entity); _bll.operateKeyBox(dataList); return(Success("操作成功")); } catch (Exception ex) { WriteLog.AddLog($"错误 \r\n用户:{user.UserName} id:{user.UserId}编辑钥匙管理数据失败 \r\n 错误信息:{JsonConvert.SerializeObject(ex)}", "SafetyScore"); return(Error(ex.Message)); } }
public override void OnException(ExceptionContext context) { base.OnException(context); Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(context.Exception, "错误"); if (!context.ExceptionHandled)//如果异常没有被处理过 { WriteLog.AddLog(JsonConvert.SerializeObject(context.Exception.Message)); string controllerName = (string)context.RouteData.Values["controller"]; string actionName = (string)context.RouteData.Values["action"]; //string msgTemplate =string.Format( "在执行controller[{0}的{1}]方法时产生异常",controllerName,actionName);//写入日志 if (this.IsAjaxRequest(context.HttpContext.Request)) { context.Result = new JsonResult(new { Result = false, PromptMsg = "系统出现异常,请联系管理员", DebugMessage = context.Exception.Message }); } else { var result = new ViewResult { ViewName = "Error" }; result.ViewData = new ViewDataDictionary(_moprovider, context.ModelState); result.ViewData.Add("Execption", context.Exception); context.Result = result; } ; } }
private void openGLControl_MouseUp(object sender, MouseEventArgs e) { if (mode == 1 && e.Button == MouseButtons.Left) { //Khi nhả chuột trái ở chế độ vẽ hình bình thường isDown = false; end = e.Location; if (newShapeItem != null) { WriteLog.AddLog(new Log { name = newShapeItem.GetType().ToString().Split('.')[2], dayDraw = DateTime.Now, timeToDraw = newShapeItem.thoiGianVe }); } WriteLog.Render(name, thoigian); } else if (mode == 3) { //Khi nhả chuột ở chế độ vẽ Polygon if (e.Button == MouseButtons.Left) { newPolygonItem.Add(e.Location); mouseLeft = true; } else { lPolygon.Add(newPolygonItem); WriteLog.AddLog(new Log { name = "Polygon", dayDraw = DateTime.Now, timeToDraw = newPolygonItem.thoiGianVe }); newPolygonItem = new Polygon(); mouseLeft = false; } WriteLog.Render(name, thoigian); } else if (mode == 4) { //Khi nhả chuột ở chế độ chọn hình //Tính khoảng cách tới tất cả các hình, tìm nhỏ nhất, so với epsilon, nếu nhỏ hơn thì hiện hình đó ControlPoint.GetMin(lPolygon, Draw.listDraw, e.Location); ControlPoint.AllowToDraw(_epsilon); //Khi bấm ra ngoài hoặc bấm vào hình khác thì hủy old Mouse để tránh bị delay if (ControlPoint.minPolygon == null && ControlPoint.minShape == null) { oldMousePoint.X = -1000; } if (ControlPoint.minPolygon != null && oldMousePoint.X != -1000) { Affine.TinhTien(ControlPoint.minPolygon, new Point(e.Location.X - oldMousePoint.X, e.Location.Y - oldMousePoint.Y)); } if (ControlPoint.minShape != null && oldMousePoint.X != -1000) { Affine.TinhTien(ControlPoint.minShape, new Point(e.Location.X - oldMousePoint.X, e.Location.Y - oldMousePoint.Y)); } isDown = false; } }
public async Task <IActionResult> OnPostAsync() { if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(Input.Email); if (user == null || !(await _userManager.IsEmailConfirmedAsync(user))) { // Don't reveal that the user does not exist or is not confirmed return(RedirectToPage("./ForgotPasswordConfirmation")); } // For more information on how to enable account confirmation and password reset please // visit https://go.microsoft.com/fwlink/?LinkID=532713 var code = await _userManager.GeneratePasswordResetTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ResetPassword", pageHandler: null, values: new { area = "Identity", code }, protocol: Request.Scheme); //await _emailSender.SendEmailAsync( // Input.Email, // "Reset Password", // $"Please reset your password by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); try { EmailSender sndEmail = new EmailSender("smtp.gmail.com", 587, true, "*****@*****.**", "03461578803"); string message = "Hello User.<br/> Welcome to FoodDelivery. " + "<br/>" + " You can " + "<a href=" + callbackUrl + ">Click Here</a>" + " to change your password. <br/> Thanks."; await sndEmail.SendEmailAsync(user.Email, "Email Confirmation", message); return(RedirectToPage("./ForgotPasswordConfirmation")); } catch (Exception ex) { WriteLog.AddLog(ex.Message); WriteLog.AddLog(ex.StackTrace); WriteLog.AddLog(ex.InnerException.ToString()); } } return(Page()); }
public ActionResult Remove(string keyValue) { Operator user = OperatorProvider.Provider.Current(); WriteLog.AddLog($"用户:{user.UserName} id:{user.UserId}开始删除积分管理数据{keyValue}", "SafetyScore"); try { _bll.Remove(keyValue); return(Success("删除成功。")); } catch (Exception ex) { WriteLog.AddLog($"错误 \r\n用户:{user.UserName} id:{user.UserId}删除积分管理数据{keyValue}失败 \r\n 错误信息:{JsonConvert.SerializeObject(ex)}", "SafetyScore"); return(Error("删除失败:" + ex.Message)); } }
public ActionResult SaveForm(string keyValue, SafetyScoreEntity entity) { Operator user = OperatorProvider.Provider.Current(); WriteLog.AddLog($"用户:{user.UserName} id:{user.UserId}开始编辑积分管理数据{keyValue} \r\n {JsonConvert.SerializeObject(entity)}", "SafetyScore"); try { _bll.SaveForm(keyValue, entity); return(Success("操作成功")); } catch (Exception ex) { WriteLog.AddLog($"错误 \r\n用户:{user.UserName} id:{user.UserId}编辑积分管理数据{keyValue}失败 \r\n 错误信息:{JsonConvert.SerializeObject(ex)}", "SafetyScore"); return(Error(ex.Message)); } }
public ActionResult SaveForm(string keyValue, DeviceInspectionEntity entity, string itemsJson) { try { Operator user = OperatorProvider.Provider.Current(); List <DeviceInspectionItemEntity> items = new List <DeviceInspectionItemEntity>();//检查项 if (!string.IsNullOrWhiteSpace(itemsJson)) { items = JsonConvert.DeserializeObject <List <DeviceInspectionItemEntity> >(itemsJson); } _bll.SaveForm(keyValue, entity, items); return(Success("操作成功")); } catch (Exception ex) { WriteLog.AddLog($"参数:body_{JsonConvert.SerializeObject(Request.Form)} QueryString_{Request.QueryString}\r\n错误消息:{JsonConvert.SerializeObject(ex)}", "DeviceInspection"); return(Error(ex.Message)); } }
/// <summary> /// 根据内置的规则类型 ,添加积分数据 /// </summary> /// <param name="userId"></param> /// <param name="dataType">根据内置的规则类型 ,添加积分数据 规则类型 /// 1 登记一般隐患(未整改) /// 2 登记一般隐患(已整改) /// 3 登记重大隐患(未整改) /// 4 登记违章 /// 5 早安中铝 /// 6 班前一题 /// 7 班前一课 /// </param> public void AddScore(string userId, int dataType) { WriteLog.AddLog($"Service AddScore 接收到参数userId:{userId} dataType:{dataType}", "SafetyScore"); try { var db = new RepositoryFactory().BaseRepository(); var user = (from q1 in db.IQueryable <UserEntity>() join q2 in db.IQueryable <DepartmentEntity>() on q1.DepartmentId equals q2.DepartmentId into t from t1 in t.DefaultIfEmpty() where q1.UserId == userId select new { q1.UserId, q1.RealName, t1.DepartmentId, DepartmentCode = t1.EnCode, DeptName = t1.FullName, q1.Gender }).FirstOrDefault(); if (user == null) { throw new Exception("用户不存在"); } SafetyScoreEntity entity = new SafetyScoreEntity() { Id = Guid.NewGuid().ToString(), CreateDate = DateTime.Now, CreateUserId = user.UserId, CreateUserName = user.RealName, UserId = user.UserId, UserName = user.RealName, DeptId = user.DepartmentId, DeptCode = user.DepartmentCode, DeptName = user.DeptName, Gender = user.Gender, ScoreType = Enum.GetName(typeof(ScoreType), ScoreType.自动), ModifyDate = DateTime.Now, ModifyUserId = user.UserId, ModifyUserName = user.RealName, }; AccountRuleEntity rule; switch (dataType) { case 1: rule = db.IQueryable <AccountRuleEntity>(p => p.Standard == "登记一般隐患(未整改)" && p.IsOpen == 1).FirstOrDefault(); break; case 2: rule = db.IQueryable <AccountRuleEntity>(p => p.Standard == "登记一般隐患(已整改)" && p.IsOpen == 1).FirstOrDefault(); break; case 3: rule = db.IQueryable <AccountRuleEntity>(p => p.Standard == "登记重大隐患(未整改)" && p.IsOpen == 1).FirstOrDefault(); break; case 4: rule = db.IQueryable <AccountRuleEntity>(p => p.Standard == "登记违章" && p.IsOpen == 1).FirstOrDefault(); break; case 5: rule = db.IQueryable <AccountRuleEntity>(p => p.Standard == "早安中铝" && p.IsOpen == 1).FirstOrDefault(); break; case 6: //每个班组每月不得超过60分 rule = db.IQueryable <AccountRuleEntity>(p => p.Standard == "班前一题" && p.IsOpen == 1).FirstOrDefault(); if (rule == null) { throw new Exception("内置规则不存在,或未启用"); } var a = db.IQueryable <SafetyScoreEntity>(x => x.DeptId == user.DepartmentId && x.RuleId == rule.Id && x.CreateDate.Month == DateTime.Now.Month).Select(x => x.Score).ToList(); //查询用户所在的部门的总得分 var deptTotal = a.Sum(x => x); if (deptTotal >= 60) { return; } if ((deptTotal + rule.Score) > 60) { rule.Score = 60 - deptTotal; } break; case 7: rule = db.IQueryable <AccountRuleEntity>(p => p.Standard == "班前一课" && p.IsOpen == 1).FirstOrDefault(); if (rule == null) { throw new Exception("内置规则不存在,或未启用"); } var b = db.IQueryable <SafetyScoreEntity>(x => x.DeptId == user.DepartmentId && x.RuleId == rule.Id && x.CreateDate.Month == DateTime.Now.Month).Select(x => x.Score).ToList(); //查询用户所在的部门的总得分 var SubjectdeptTotal = b.Sum(x => x); if (SubjectdeptTotal >= 60) { return; } if ((SubjectdeptTotal + rule.Score) > 60) { rule.Score = 60 - SubjectdeptTotal; } break; default: throw new ArgumentException("规则类型不对"); } if (rule == null) { throw new Exception("内置规则不存在,或未启用"); } entity.Reasons = rule.Standard; entity.RuleId = rule.Id; entity.Score = rule.Score; db.Insert(entity); WriteLog.AddLog($"Service AddScore 添加安全积分成功:{JsonConvert.SerializeObject(entity)}", "SafetyScore"); } catch (Exception ex) { WriteLog.AddLog($"Service AddScore 错误:{JsonConvert.SerializeObject(ex)}", "SafetyScore"); throw; } }