Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }