public JsonResult ToExamine(int ToExamineStatues, string Reason, int EntryId) { OperationResult oper = new OperationResult(OperationResultType.Error); ResignationToExamine ete = new ResignationToExamine(); ete.AdminId = AuthorityHelper.OperatorId.Value; ete.Reason = Reason; ete.ResignationId = EntryId; ete.AuditStatus = ToExamineStatues; ete.AuditTime = DateTime.Now; ete.OperatorId = AuthorityHelper.OperatorId; oper = _resignationToExamineContract.Insert(ete); if (oper.ResultType == OperationResultType.Success) { oper = _resignationContract.ToExamine(ToExamineStatues, EntryId); if (oper.ResultType == OperationResultType.Success) { var dtoM = _resignationContract.Resignations.Where(x => x.Id == EntryId).FirstOrDefault(); int NotificationId = _templateNotificationContract.templateNotifications.Where(x => x.Name == "离职审核未通过").Select(x => x.Id).FirstOrDefault(); var orgContent = _templateContract.Templates.Where(x => !x.IsDeleted && x.IsEnabled && x.TemplateNotificationId == NotificationId) .Select(x => x.TemplateHtml).FirstOrDefault(); var title = _templateContract.Templates.Where(x => !x.IsDeleted && x.IsEnabled && x.TemplateNotificationId == NotificationId) .Select(x => x.TemplateName).FirstOrDefault(); List <int> AuthorityList = new List <int>(); var receiveAdminIds = 0; if (ToExamineStatues == -3) { receiveAdminIds = _resignationToExamineContract.EntryToExamines.Where(x => x.ResignationId == EntryId && x.AuditStatus == 2) .OrderByDescending(x => x.CreatedTime).Select(x => x.AdminId).FirstOrDefault(); } else if (ToExamineStatues == -2 || ToExamineStatues == -5) { receiveAdminIds = _resignationToExamineContract.EntryToExamines.Where(x => x.ResignationId == EntryId && x.AuditStatus == 1) .OrderByDescending(x => x.CreatedTime).Select(x => x.AdminId).FirstOrDefault(); } else if (ToExamineStatues == -1 || ToExamineStatues == -6) { receiveAdminIds = _resignationContract.Resignations.Where(x => x.Id == EntryId).Select(x => x.operationId ?? (AuthorityHelper.OperatorId ?? 0)).FirstOrDefault(); } var dicPC = new Dictionary <string, object>(); dicPC.Add("entryName", dtoM.ResignationModel?.Member?.RealName ?? string.Empty); dicPC.Add("entryDep", dtoM.Department?.DepartmentName ?? string.Empty); dicPC.Add("ToExamine", AuthorityHelper.RealName); var content = NVelocityHelper.Generate(orgContent, dicPC, "Entry_PC"); List <int> lAdmin = new List <int>(); lAdmin.Add(receiveAdminIds); _notificationContract.Insert(sendNotificationAction, new NotificationDto() { Title = title, AdministratorIds = lAdmin, Description = content, IsEnableApp = true, NoticeTargetType = (int)NoticeTargetFlag.Admin, NoticeType = (int)NoticeFlag.Immediate }); } } return(Json(oper)); }
public ActionResult Update(ResignationDto dto) { dto.ToExamineResult = 0; dto.operationId = AuthorityHelper.OperatorId; OperationResult oper = _resignationContract.Update(dto); if (oper.ResultType == OperationResultType.Success) { int NotificationId = _templateNotificationContract.templateNotifications.Where(x => x.Name == "离职通知").Select(x => x.Id).FirstOrDefault(); var mod = _templateContract.Templates.Where(x => !x.IsDeleted && x.IsEnabled && x.TemplateNotificationId == NotificationId).Select(s => new { s.Id, s.TemplateHtml, s.TemplateName, s.EnabledPerNotifi }).FirstOrDefault(); List <int> AuthorityList = new List <int>() { 1, 4, 5, 7 }; var resign = _administratorContract.Administrators.Where(x => x.Id == dto.ResignationId).FirstOrDefault(); var dicPC = new Dictionary <string, object>(); dicPC.Add("entryName", resign?.Member?.RealName ?? string.Empty); dicPC.Add("entryDep", resign?.Department?.DepartmentName ?? string.Empty); dicPC.Add("ToExamine", ""); var content = NVelocityHelper.Generate(mod.TemplateHtml, dicPC, "Entry_PC"); var dtoNoti = new NotificationDto() { Title = mod.TemplateName, Description = content, IsEnableApp = true, NoticeType = (int)NoticeFlag.Immediate, NoticeTargetType = mod.EnabledPerNotifi ? (int)NoticeTargetFlag.Admin : (int)NoticeTargetFlag.Department }; if (mod.EnabledPerNotifi) { var receiveAdminIds = _administratorContract.Administrators.Where(x => x.IsEnabled && !x.IsDeleted && AuthorityList.Contains(x.JobPosition.Auditauthority.Value)).Select(s => s.Id).ToList(); dtoNoti.AdministratorIds = receiveAdminIds; } else { var depids = _templateContract.GetNotificationDepartIds(mod.Id); dtoNoti.DepartmentIds = depids; } _notificationContract.Insert(sendNotificationAction, dtoNoti); } return(Json(oper)); }
public ActionResult CheckValid(string content) { string strResult = ""; var modPro = _productOrigNumberContract.OrigNumbs.FirstOrDefault(); var modAdmin = _administratorContract.View(AuthorityHelper.OperatorId.Value); if (modPro.IsNotNull()) { var dic = new Dictionary <string, object>(); dic.Add("PONInfo", modPro); dic.Add("AdminInfo", modAdmin); strResult = NVelocityHelper.Generate(content, dic, "checkValid"); #region 弃用 //StringTemplate strTemplate = new StringTemplate(content); //strTemplate.SetAttribute("PONInfo", modPro); //strResult = strTemplate.ToString(); #endregion } strResult = strResult.IsNullOrEmpty() ? "内容建设中..." : strResult; return(Json(strResult)); }
public JsonResult TechnologyDetaile(ResignationDto dto) { OperationResult oper = _resignationContract.Update(dto); if (oper.ResultType == OperationResultType.Success) { if (dto.ToExamineResult == 3) { oper = _administratorContract.Disable(dto.ResignationId.Value); } ResignationToExamine ete = new ResignationToExamine(); ete.AdminId = AuthorityHelper.OperatorId.Value; ete.Reason = ""; ete.ResignationId = dto.Id; ete.AuditStatus = 2; ete.AuditTime = DateTime.Now; ete.OperatorId = AuthorityHelper.OperatorId; oper = _resignationToExamineContract.Insert(ete); if (oper.ResultType == OperationResultType.Success) { var dtoM = _resignationContract.Resignations.Where(x => x.Id == dto.Id).FirstOrDefault(); string title = string.Empty; string orgContent = string.Empty; List <int> AuthorityList = new List <int>() { 3, 7 }; var dicPC = new Dictionary <string, object>(); dicPC.Add("entryName", dtoM.ResignationModel?.Member?.RealName ?? string.Empty); dicPC.Add("entryDep", dtoM.Department?.DepartmentName ?? string.Empty); dicPC.Add("ToExamine", AuthorityHelper.RealName); var dtoNoti = new NotificationDto() { IsEnableApp = true, NoticeType = (int)NoticeFlag.Immediate, //NoticeTargetType = mod.EnabledPerNotifi ? (int)NoticeTargetFlag.Admin : (int)NoticeTargetFlag.Department }; if (dto.ToExamineResult == 3) { int NotificationId = _templateNotificationContract.templateNotifications.Where(x => x.Name == "离职通知-财务审核").Select(x => x.Id).FirstOrDefault(); var mod = _templateContract.Templates.Where(x => !x.IsDeleted && x.IsEnabled && x.TemplateNotificationId == NotificationId).Select(s => new { s.Id, s.TemplateHtml, s.TemplateName, s.EnabledPerNotifi }).FirstOrDefault(); orgContent = mod.TemplateHtml; title = mod.TemplateName; dicPC.Add("time", dto.ResignationDate.ToLongDateString()); if (mod.EnabledPerNotifi) { var receiveAdminIds = _administratorContract.Administrators.Where(x => x.IsEnabled && !x.IsDeleted).Select(s => s.Id).ToList(); dtoNoti.AdministratorIds = receiveAdminIds; } else { var depids = _templateContract.GetNotificationDepartIds(mod.Id); dtoNoti.DepartmentIds = depids; } dtoNoti.NoticeTargetType = mod.EnabledPerNotifi ? (int)NoticeTargetFlag.Admin : (int)NoticeTargetFlag.Department; } else { int NotificationId = _templateNotificationContract.templateNotifications.Where(x => x.Name == "离职通知").Select(x => x.Id).FirstOrDefault(); var mod = _templateContract.Templates.Where(x => !x.IsDeleted && x.IsEnabled && x.TemplateNotificationId == NotificationId).Select(s => new { s.Id, s.TemplateHtml, s.TemplateName, s.EnabledPerNotifi }).FirstOrDefault(); orgContent = mod.TemplateHtml; title = mod.TemplateName; if (mod.EnabledPerNotifi) { var receiveAdminIds = _administratorContract.Administrators.Where(x => x.IsEnabled && !x.IsDeleted && AuthorityList.Contains(x.JobPosition.Auditauthority.Value)).Select(s => s.Id).ToList(); dtoNoti.AdministratorIds = receiveAdminIds; } else { var depids = _templateContract.GetNotificationDepartIds(mod.Id); dtoNoti.DepartmentIds = depids; } dtoNoti.NoticeTargetType = mod.EnabledPerNotifi ? (int)NoticeTargetFlag.Admin : (int)NoticeTargetFlag.Department; } var content = NVelocityHelper.Generate(orgContent, dicPC, "Entry_PC"); dtoNoti.Title = title; dtoNoti.Description = content; _notificationContract.Insert(sendNotificationAction, dtoNoti); } } return(Json(oper)); }