Esempio n. 1
0
        public List <TaskWork> ChangeWorkflowApprovers(string projectId, ApproveUsers approver)
        {
            var workflowTasks = TaskWork.Search(e => e.RefID == projectId &&
                                                e.Status == TaskWorkStatus.UnFinish &&
                                                e.K2SN != null).ToList();
            var approveDiallogUsers = ApproveDialogUser.Search(e => e.ProjectId == projectId).ToList();

            ChangeWorkflowApprovers(workflowTasks, approveDiallogUsers, approver);

            ApproveDialogUser.Update(approveDiallogUsers.ToArray());
            TaskWork.Update(workflowTasks.ToArray());

            return(workflowTasks);
        }
Esempio n. 2
0
        public WFTempClosurePackage(TempClosurePackage entity, ApproveUsers approvers)
            : base(entity)
        {
            var    task       = TaskWork.FirstOrDefault(t => t.RefID == entity.ProjectId && t.TypeCode == FlowCode.TempClosure_ClosurePackage);
            string destMRMgrs = approvers.MarketMgr.Code;

            if (approvers.RegionalMgr != null)
            {
                destMRMgrs += ";" + approvers.RegionalMgr.Code;
            }
            K2Param.AddDataField("dest_Creator", entity.CreateUserAccount);
            K2Param.AddDataField("dest_MRMgrs", destMRMgrs);
            K2Param.AddDataField("dest_GMApprovers", string.Concat(approvers.MDD.Code, ";", approvers.GM.Code, ";", approvers.FC.Code));
            K2Param.AddDataField("dest_VPGM", approvers.VPGM.Code);
            //K2Param.AddDataField("dest_DevVP", Entity.DevVP); Cary: 没有这个环节了。2014-9-11
            K2Param.AddDataField("ProcessCode", ProcessCode);
            K2Param.AddDataField("ProjectTaskInfo", JsonConvert.SerializeObject(task));
        }
Esempio n. 3
0
        protected override void ChangeWorkflowApprovers(List <TaskWork> taskWorks, List <ApproveDialogUser> prevApprovers, ApproveUsers currApprover)
        {
            foreach (var taskWork in taskWorks)
            {
                List <ProcessDataField> dataFields = null;
                switch (taskWork.TypeCode)
                {
                case FlowCode.Renewal_Package:
                    var package = RenewalPackage.Get(taskWork.RefID);
                    package.AppUsers = currApprover;
                    dataFields       = package.SetWorkflowDataFields(null);
                    var packageApprovers =
                        prevApprovers.FirstOrDefault(e => e.FlowCode == FlowCode.Renewal_Package);
                    if (packageApprovers != null)
                    {
                        SimpleEmployee receiver = null;
                        if (taskWork.ReceiverAccount == packageApprovers.MarketMgrCode &&
                            packageApprovers.MarketMgrCode != currApprover.MarketMgr.Code)
                        {
                            receiver = currApprover.MarketMgr;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.RegionalMgrCode &&
                            packageApprovers.RegionalMgrCode != currApprover.RegionalMgr.Code)
                        {
                            receiver = currApprover.RegionalMgr;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.MDDCode &&
                            packageApprovers.MDDCode != currApprover.MDD.Code)
                        {
                            receiver = currApprover.MDD;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.GMCode &&
                            packageApprovers.GMCode != currApprover.GM.Code)
                        {
                            receiver = currApprover.GM;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.FCCode &&
                            packageApprovers.FCCode != currApprover.FC.Code)
                        {
                            receiver = currApprover.FC;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.VPGMCode &&
                            packageApprovers.VPGMCode != currApprover.VPGM.Code)
                        {
                            receiver = currApprover.VPGM;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.MCCLAssetDtrCode &&
                            packageApprovers.MCCLAssetDtrCode != currApprover.MCCLAssetDtr.Code)
                        {
                            receiver = currApprover.MCCLAssetDtr;
                        }

                        if (taskWork.ReceiverAccount == packageApprovers.CDOCode &&
                            packageApprovers.CDOCode != currApprover.CDO.Code)
                        {
                            receiver = currApprover.CDO;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.MngDirectorCode &&
                            packageApprovers.MngDirectorCode != currApprover.ManagingDirector.Code)
                        {
                            receiver = currApprover.ManagingDirector;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.CFOCode &&
                            packageApprovers.CFOCode != currApprover.CFO.Code)
                        {
                            receiver = currApprover.CFO;
                        }
                        else
                        {
                            if (taskWork.ProcInstID.HasValue)
                            {
                                UpdateWorkflowDataField(taskWork.ProcInstID.Value, dataFields);
                            }
                        }

                        if (receiver != null)
                        {
                            try
                            {
                                RedirectWorkflowTask(taskWork.K2SN, taskWork.ReceiverAccount, receiver.Code, dataFields);
                            }
                            catch (Exception ex)
                            {
                                Log4netHelper.WriteError(string.Format("【Redirect Workflow Task Error】:{0}",
                                                                       JsonConvert.SerializeObject(taskWork)));
                            }
                            taskWork.ReceiverAccount  = receiver.Code;
                            taskWork.ReceiverNameENUS = receiver.NameENUS;
                            taskWork.ReceiverNameZHCN = receiver.NameZHCN;
                        }
                        packageApprovers.MarketMgrCode = currApprover.MarketMgr.Code;
                        if (currApprover.RegionalMgr != null)
                        {
                            packageApprovers.RegionalMgrCode = currApprover.RegionalMgr.Code;
                        }
                        packageApprovers.GMCode           = currApprover.GM.Code;
                        packageApprovers.FCCode           = currApprover.FC.Code;
                        packageApprovers.MDDCode          = currApprover.MDD.Code;
                        packageApprovers.VPGMCode         = currApprover.VPGM.Code;
                        packageApprovers.MCCLAssetDtrCode = currApprover.MCCLAssetDtr.Code;
                        if (currApprover.CDO != null)
                        {
                            packageApprovers.CDOCode = currApprover.CDO.Code;
                        }
                        packageApprovers.MngDirectorCode = currApprover.ManagingDirector.Code;
                        packageApprovers.Update();
                    }
                    break;
                }
            }
        }
Esempio n. 4
0
        public static List <EmailSendingResultType> SendPackageApprovalEmail(RenewalInfo info, RenewalPackage entity, ApproveUsers approvers)
        {
            var project       = ProjectInfo.Get(entity.ProjectId, FlowCode.Renewal_Package);
            var storeBasic    = StoreBasicInfo.GetStorInfo(project.USCode);
            var storeContract = StoreContractInfo.Search(c => c.StoreCode == project.USCode).OrderByDescending(c => c.CreatedTime).FirstOrDefault();
            var assetMgr      = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetManager);
            var assetActor    = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
            var assetRep      = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetRep);
            var results       = new List <EmailSendingResultType>();

            using (EmailServiceClient emailClient = new EmailServiceClient())
            {
                List <SimpleEmployee> approveEmps = new List <SimpleEmployee> {
                    approvers.MarketMgr,
                    approvers.GM,
                    approvers.MDD,
                    approvers.FC,
                    approvers.MCCLAssetDtr
                };
                if (approvers.RegionalMgr != null)
                {
                    approveEmps.Add(approvers.RegionalMgr);
                }
                if (approvers.CDO != null)
                {
                    approveEmps.Add(approvers.CDO);
                }
                if (approvers.ManagingDirector != null)
                {
                    approveEmps.Add(approvers.ManagingDirector);
                }
                //邮件模板中的数据
                Dictionary <string, string> bodyValues = new Dictionary <string, string>();
                //邮件内容中的键值对
                bodyValues.Add("ApplicantName", ClientCookie.UserNameENUS);//--提交人
                bodyValues.Add("StoreCode", storeBasic.StoreCode);
                bodyValues.Add("StoreName", storeBasic.NameENUS + @" \ " + storeBasic.NameZHCN);
                bodyValues.Add("Actor", assetActor.UserNameENUS);     ////--呈递人
                //bodyValues.Add("WorkflowName", Constants.TempClosure_Package);////--流程名称
                bodyValues.Add("ProjectName", Constants.TempClosure); //项目名称
                var viewPage = string.Format("{0}/Renewal/Main#/Package/View/param?projectId={1}",
                                             HttpContext.Current.Request.Url.Authority, entity.ProjectId);
                bodyValues.Add("FormUrl", viewPage);
                Dictionary <string, string> templateFileds = entity.GetPrintTemplateFields();
                var approveRecords = ProjectComment.GetList("TempClosurePackage", entity.Id, ProjectCommentStatus.Submit).Select(pc => new SubmissionApprovalRecord
                {
                    OperatorID    = pc.UserAccount,
                    OperatorName  = pc.UserNameENUS,
                    OperatorTitle = pc.TitleNameENUS,
                    OperationDate = pc.CreateTime.HasValue ? pc.CreateTime.Value : DateTime.Now,
                    ActionName    = pc.ActivityName,
                    Comments      = pc.Content
                }).ToList();
                string imgPath = HtmlConversionUtility.HtmlConvertToPDF(HtmlTempalteType.Renewal, templateFileds, approveRecords);
                approveEmps.ForEach(e =>
                {
                    EmailMessage email           = new EmailMessage();
                    List <string> emailAddresses = new List <string>
                    {
                        e.Mail,
                        "*****@*****.**",
                        "*****@*****.**",
                        "*****@*****.**"
                    };
                    if (bodyValues.ContainsKey("ApproverName"))
                    {
                        bodyValues["ApproverName"] = e.NameENUS;
                    }
                    else
                    {
                        bodyValues.Add("ApproverName", e.NameENUS);//--提交人
                    }
                    email.EmailBodyValues = bodyValues;
                    email.To          = string.Join(";", emailAddresses);
                    email.Attachments = imgPath;
                    //var result =  emailClient.SendEmail(email);
                    results.Add(new EmailSendingResultType());
                });
                approvers.NoticeUsers.ForEach(e =>
                {
                    EmailMessage email           = new EmailMessage();
                    List <string> emailAddresses = new List <string>
                    {
                        e.Mail,
                        "*****@*****.**",
                        "*****@*****.**",
                        "*****@*****.**"
                    };
                    if (bodyValues.ContainsKey("ApproverName"))//--提交人
                    {
                        bodyValues["ApproverName"] = e.NameENUS;
                    }
                    else
                    {
                        bodyValues.Add("ApproverName", e.NameENUS);
                    }
                    email.EmailBodyValues = bodyValues;
                    email.To          = string.Join(";", emailAddresses);
                    email.Attachments = imgPath;
                    //var result = emailClient.SendEmail(email);
                    results.Add(new EmailSendingResultType());
                });
            }
            return(results);
        }
Esempio n. 5
0
        protected override void ChangeWorkflowApprovers(List <TaskWork> taskWorks, List <ApproveDialogUser> prevApprovers, ApproveUsers currApprover)
        {
            foreach (var taskWork in taskWorks)
            {
                List <ProcessDataField> dataFields = null;
                switch (taskWork.TypeCode)
                {
                case FlowCode.MajorLease_Package:
                    var package = new MajorLeaseChangePackage();
                    package.AppUsers = currApprover;
                    dataFields       = package.SetWorkflowDataFields(null);
                    var packageApprovers =
                        prevApprovers.FirstOrDefault(e => e.FlowCode == FlowCode.MajorLease_Package);
                    if (packageApprovers != null)
                    {
                        SimpleEmployee receiver = null;
                        if (taskWork.ReceiverAccount == packageApprovers.MarketMgrCode &&
                            packageApprovers.MarketMgrCode != currApprover.MarketMgr.Code)
                        {
                            receiver = currApprover.MarketMgr;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.RegionalMgrCode &&
                            packageApprovers.RegionalMgrCode != currApprover.RegionalMgr.Code)
                        {
                            receiver = currApprover.RegionalMgr;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.MDDCode &&
                            packageApprovers.MDDCode != currApprover.MDD.Code)
                        {
                            receiver = currApprover.MDD;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.GMCode &&
                            packageApprovers.GMCode != currApprover.GM.Code)
                        {
                            receiver = currApprover.GM;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.FCCode &&
                            packageApprovers.FCCode != currApprover.FC.Code)
                        {
                            receiver = currApprover.FC;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.RDDCode &&
                            packageApprovers.RDDCode != currApprover.RDD.Code)
                        {
                            receiver = currApprover.RDD;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.VPGMCode &&
                            packageApprovers.VPGMCode != currApprover.VPGM.Code)
                        {
                            receiver = currApprover.VPGM;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.MCCLAssetDtrCode &&
                            packageApprovers.MCCLAssetDtrCode != currApprover.MCCLAssetDtr.Code)
                        {
                            receiver = currApprover.MCCLAssetDtr;
                        }

                        if (taskWork.ReceiverAccount == packageApprovers.CDOCode &&
                            packageApprovers.CDOCode != currApprover.CDO.Code)
                        {
                            receiver = currApprover.CDO;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.CFOCode &&
                            packageApprovers.CFOCode != currApprover.CFO.Code)
                        {
                            receiver = currApprover.CFO;
                        }
                        else
                        {
                            if (taskWork.ProcInstID.HasValue)
                            {
                                UpdateWorkflowDataField(taskWork.ProcInstID.Value, dataFields);
                            }
                        }

                        if (receiver != null)
                        {
                            RedirectWorkflowTask(taskWork.K2SN, taskWork.ReceiverAccount, receiver.Code, dataFields);

                            taskWork.ReceiverAccount  = receiver.Code;
                            taskWork.ReceiverNameENUS = receiver.NameENUS;
                            taskWork.ReceiverNameZHCN = receiver.NameZHCN;
                        }

                        packageApprovers.MarketMgrCode = currApprover.MarketMgr.Code;
                        packageApprovers.MarketMgrCode = currApprover.RegionalMgr.Code;
                        packageApprovers.MarketMgrCode = currApprover.DD.Code;
                        packageApprovers.MarketMgrCode = currApprover.GM.Code;
                        packageApprovers.MarketMgrCode = currApprover.FC.Code;
                        packageApprovers.MarketMgrCode = currApprover.RDD.Code;
                        packageApprovers.MarketMgrCode = currApprover.VPGM.Code;
                        packageApprovers.MarketMgrCode = currApprover.MCCLAssetDtr.Code;
                        packageApprovers.MarketMgrCode = currApprover.CDO.Code;
                        packageApprovers.MarketMgrCode = currApprover.CFO.Code;
                    }


                    break;
                }
            }
        }
Esempio n. 6
0
 protected virtual void ChangeWorkflowApprovers(List <TaskWork> taskWorks, List <ApproveDialogUser> prevApprovers, ApproveUsers currApprover)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
        protected override void ChangeWorkflowApprovers(List <TaskWork> taskWorks, List <ApproveDialogUser> prevApprovers, ApproveUsers currApprover)
        {
            var packageApprovers =
                prevApprovers.FirstOrDefault(e => e.FlowCode == WorkflowCode &&
                                             e.RefTableID == Id.ToString());

            foreach (var taskWork in taskWorks)
            {
                List <ProcessDataField> dataFields = null;
                switch (taskWork.TypeCode)
                {
                case FlowCode.TempClosure_ClosurePackage:
                    var package = new TempClosurePackage();
                    package.AppUsers = currApprover;
                    dataFields       = package.SetWorkflowDataFields(null);
                    if (packageApprovers != null)
                    {
                        SimpleEmployee receiver = null;
                        if (taskWork.ReceiverAccount == packageApprovers.MarketMgrCode &&
                            packageApprovers.MarketMgrCode != currApprover.MarketMgr.Code)
                        {
                            receiver = currApprover.MarketMgr;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.RegionalMgrCode &&
                            packageApprovers.RegionalMgrCode != currApprover.RegionalMgr.Code)
                        {
                            receiver = currApprover.RegionalMgr;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.MDDCode &&
                            packageApprovers.MDDCode != currApprover.MDD.Code)
                        {
                            receiver = currApprover.MDD;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.GMCode &&
                            packageApprovers.GMCode != currApprover.GM.Code)
                        {
                            receiver = currApprover.GM;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.FCCode &&
                            packageApprovers.FCCode != currApprover.FC.Code)
                        {
                            receiver = currApprover.FC;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.RDDCode &&
                            packageApprovers.RDDCode != currApprover.RDD.Code)
                        {
                            receiver = currApprover.RDD;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.VPGMCode &&
                            packageApprovers.VPGMCode != currApprover.VPGM.Code)
                        {
                            receiver = currApprover.VPGM;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.MCCLAssetDtrCode &&
                            packageApprovers.MCCLAssetDtrCode != currApprover.MCCLAssetDtr.Code)
                        {
                            receiver = currApprover.MCCLAssetDtr;
                        }

                        if (taskWork.ReceiverAccount == packageApprovers.CDOCode &&
                            packageApprovers.CDOCode != currApprover.CDO.Code)
                        {
                            receiver = currApprover.CDO;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.CFOCode &&
                            packageApprovers.CFOCode != currApprover.CFO.Code)
                        {
                            receiver = currApprover.CFO;
                        }
                        else
                        {
                            if (taskWork.ProcInstID.HasValue)
                            {
                                UpdateWorkflowDataField(taskWork.ProcInstID.Value, dataFields);
                            }
                        }

                        if (receiver != null)
                        {
                            try
                            {
                                RedirectWorkflowTask(taskWork.K2SN, taskWork.ReceiverAccount, receiver.Code, dataFields);
                            }
                            catch (Exception ex)
                            {
                                Log4netHelper.WriteError(string.Format("【Redirect Workflow Task Error】:{0}",
                                                                       JsonConvert.SerializeObject(taskWork)));
                            }
                            finally
                            {
                                taskWork.ReceiverAccount  = receiver.Code;
                                taskWork.ReceiverNameENUS = receiver.NameENUS;
                                taskWork.ReceiverNameZHCN = receiver.NameZHCN;
                            }
                        }
                        if (currApprover.MarketMgr != null)
                        {
                            packageApprovers.MarketMgrCode = currApprover.MarketMgr.Code;
                        }
                        if (currApprover.RegionalMgr != null)
                        {
                            packageApprovers.RegionalMgrCode = currApprover.RegionalMgr.Code;
                        }
                        if (currApprover.DD != null)
                        {
                            packageApprovers.DDCode = currApprover.DD.Code;
                        }
                        if (currApprover.GM != null)
                        {
                            packageApprovers.GMCode = currApprover.GM.Code;
                        }
                        if (currApprover.FC != null)
                        {
                            packageApprovers.FCCode = currApprover.FC.Code;
                        }
                        if (currApprover.RDD != null)
                        {
                            packageApprovers.RDDCode = currApprover.RDD.Code;
                        }
                        if (currApprover.VPGM != null)
                        {
                            packageApprovers.VPGMCode = currApprover.VPGM.Code;
                        }
                        if (currApprover.MCCLAssetDtr != null)
                        {
                            packageApprovers.MCCLAssetDtrCode = currApprover.MCCLAssetDtr.Code;
                        }
                        if (currApprover.CDO != null)
                        {
                            packageApprovers.CDOCode = currApprover.CDO.Code;
                        }
                        if (currApprover.CFO != null)
                        {
                            packageApprovers.CFOCode = currApprover.CFO.Code;
                        }
                        if (currApprover.NoticeUsers != null)
                        {
                            packageApprovers.NoticeUsers = "";
                            foreach (var noticeUser in currApprover.NoticeUsers)
                            {
                                if (string.IsNullOrEmpty(packageApprovers.NoticeUsers))
                                {
                                    packageApprovers.NoticeUsers = noticeUser.Code;
                                }
                                else
                                {
                                    packageApprovers.NoticeUsers += ";" + noticeUser.Code;
                                }
                            }
                        }
                        if (currApprover.NecessaryNoticeUsers != null)
                        {
                            packageApprovers.NecessaryNoticeUsers = "";
                            foreach (var noticeUser in currApprover.NecessaryNoticeUsers)
                            {
                                if (string.IsNullOrEmpty(packageApprovers.NecessaryNoticeUsers))
                                {
                                    packageApprovers.NecessaryNoticeUsers = noticeUser.Code;
                                }
                                else
                                {
                                    packageApprovers.NecessaryNoticeUsers += ";" + noticeUser.Code;
                                }
                            }
                        }
                    }


                    break;
                }
            }
        }
Esempio n. 8
0
        public void Resubmit(string comment, string SerialNumber, ApproveUsers newApprover, Action onExecuting = null)
        {
            var    assetActor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
            string destMRMgrs = newApprover.MarketMgr.Code;

            if (newApprover.RegionalMgr != null)
            {
                destMRMgrs += ";" + newApprover.RegionalMgr.Code;
            }
            List <ProcessDataField> dataFields = new List <ProcessDataField>
            {
                new ProcessDataField("dest_Creator", this.CreateUserAccount),
                new ProcessDataField("dest_MRMgrs", destMRMgrs),
                new ProcessDataField("dest_GMApprovers", string.Concat(newApprover.MDD.Code, ";", newApprover.GM.Code, ";", newApprover.FC.Code)),
                new ProcessDataField("dest_VPGM", newApprover.VPGM.Code),
                new ProcessDataField("ProcessCode", this.WorkflowProcessCode)
            };

            K2FxContext.Current.ApprovalProcess(SerialNumber, ClientCookie.UserCode, "Resubmit", comment, dataFields);
            using (TransactionScope tranScope = new TransactionScope())
            {
                var project = ProjectInfo.Get(this.ProjectId, FlowCode.TempClosure_ClosurePackage);
                project.CreateUserAccount = ClientCookie.UserCode;
                project.Update();
                this.CreateUserAccount = ClientCookie.UserCode;
                Update(this);
                var approver = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());
                if (approver == null)
                {
                    approver = new ApproveDialogUser();
                }
                approver.ProjectId     = this.ProjectId;
                approver.RefTableID    = this.Id.ToString();
                approver.FlowCode      = this.WorkflowCode;
                approver.MarketMgrCode = newApprover.MarketMgr.Code;
                if (newApprover.RegionalMgr != null)
                {
                    approver.RegionalMgrCode = newApprover.RegionalMgr.Code;
                }
                else
                {
                    approver.RegionalMgrCode = null;
                }
                approver.MDDCode          = newApprover.MDD.Code;
                approver.GMCode           = newApprover.GM.Code;
                approver.FCCode           = newApprover.FC.Code;
                approver.VPGMCode         = newApprover.VPGM.Code;
                approver.MCCLAssetMgrCode = newApprover.MCCLAssetMgr.Code;
                approver.MCCLAssetDtrCode = newApprover.MCCLAssetDtr.Code;
                approver.NoticeUsers      = string.Join(";", newApprover.NoticeUsers.Select(u => u.Code).ToArray());
                approver.Save();
                ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.TempClosure_ClosurePackage_Input);
                var SavedComment = ProjectComment.GetSavedComment(this.Id, this.TableName, ClientCookie.UserCode);
                if (SavedComment != null)
                {
                    SavedComment.Status     = ProjectCommentStatus.Submit;
                    SavedComment.Action     = ProjectCommentAction.ReSubmit;
                    SavedComment.Content    = comment;
                    SavedComment.CreateTime = DateTime.Now;
                    SavedComment.Update();
                }
                else
                {
                    ProjectComment.AddComment(
                        ProjectCommentAction.ReSubmit,
                        comment,
                        this.Id,
                        this.TableName,
                        FlowCode.TempClosure,
                        this.ProcInstId,
                        ProjectCommentStatus.Submit
                        );
                }

                var task = TaskWork.FirstOrDefault(t => t.RefID == this.ProjectId && t.TypeCode == this.WorkflowCode && t.ReceiverAccount == assetActor.UserAccount);
                task.Finish();
                if (onExecuting != null)
                {
                    onExecuting();
                }
                tranScope.Complete();
            }
        }
Esempio n. 9
0
        public void Submit(string comment, ApproveUsers approvers, Action onExecuting = null)
        {
            var legal = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == this.ProjectId && pu.RoleCode == ProjectUserRoleCode.Legal);
            var task  = TaskWork.GetTaskWork(this.ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                             FlowCode.TempClosure, this.WorkflowCode);

            task.Status     = TaskWorkStatus.Finished;
            task.FinishTime = DateTime.Now;
            string destMRMgrs = approvers.MarketMgr.Code;

            if (approvers.RegionalMgr != null)
            {
                destMRMgrs += ";" + approvers.RegionalMgr.Code;
            }
            List <ProcessDataField> dataFields = new List <ProcessDataField>
            {
                new ProcessDataField("dest_Creator", this.CreateUserAccount),
                new ProcessDataField("dest_MRMgrs", destMRMgrs),
                new ProcessDataField("dest_GMApprovers", string.Concat(approvers.MDD.Code, ";", approvers.GM.Code, ";", approvers.FC.Code)),
                new ProcessDataField("dest_VPGM", approvers.VPGM.Code),
                new ProcessDataField("ProcessCode", this.WorkflowProcessCode),
                new ProcessDataField("ProjectTaskInfo", JsonConvert.SerializeObject(task))
            };
            var procInstId = K2FxContext.Current.StartProcess(WorkflowProcessCode, ClientCookie.UserCode, dataFields);

            if (procInstId > 0)
            {
                using (TransactionScope tranScope = new TransactionScope())
                {
                    TaskWork.Update(task);
                    var project = ProjectInfo.Get(this.ProjectId, FlowCode.TempClosure_ClosurePackage);
                    project.CreateUserAccount = ClientCookie.UserCode;
                    project.Update();
                    this.CreateUserAccount = ClientCookie.UserCode;
                    this.ProcInstId        = procInstId;
                    Update(this);
                    var approver = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());
                    if (approver == null)
                    {
                        approver = new ApproveDialogUser();
                    }
                    approver.ProjectId     = this.ProjectId;
                    approver.RefTableID    = this.Id.ToString();
                    approver.FlowCode      = FlowCode.TempClosure_ClosurePackage;
                    approver.MarketMgrCode = approvers.MarketMgr.Code;
                    if (approvers.RegionalMgr != null)
                    {
                        approver.RegionalMgrCode = approvers.RegionalMgr.Code;
                    }
                    approver.MDDCode  = approvers.MDD.Code;
                    approver.GMCode   = approvers.GM.Code;
                    approver.FCCode   = approvers.FC.Code;
                    approver.VPGMCode = approvers.VPGM.Code;
                    //approver.MCCLAssetMgrCode = approvers.MCCLAssetMgr.Code;
                    //approver.MCCLAssetDtrCode = approvers.MCCLAssetDtr.Code;
                    approver.NecessaryNoticeUsers = string.Join(";", approvers.NecessaryNoticeUsers.Select(u => u.Code).ToArray());
                    approver.NoticeUsers          = string.Join(";", approvers.NoticeUsers.Select(u => u.Code).ToArray());
                    approver.Save();
                    ProjectInfo.FinishNode(this.ProjectId, FlowCode.TempClosure_ClosurePackage, NodeCode.TempClosure_ClosurePackage_Input);
                    var SavedComment = ProjectComment.GetSavedComment(this.Id, this.TableName, ClientCookie.UserCode);
                    if (SavedComment != null)
                    {
                        SavedComment.Status     = ProjectCommentStatus.Submit;
                        SavedComment.Content    = comment;
                        SavedComment.CreateTime = DateTime.Now;
                        SavedComment.Update();
                    }
                    else
                    {
                        ProjectComment.AddComment(
                            ProjectCommentAction.Submit,
                            comment,
                            this.Id,
                            "TempClosurePackage",
                            FlowCode.TempClosure,
                            this.ProcInstId,
                            ProjectCommentStatus.Submit
                            );
                    }
                    if (onExecuting != null)
                    {
                        onExecuting();
                    }
                    tranScope.Complete();
                }
            }
        }
Esempio n. 10
0
        public static List <EmailSendingResultType> SendPackageApprovalEmail(TempClosureInfo tempClosureInfo, TempClosurePackage entity, ApproveUsers approvers)
        {
            var project       = ProjectInfo.Get(entity.ProjectId, FlowCode.TempClosure_ClosurePackage);
            var storeBasic    = StoreBasicInfo.GetStorInfo(project.USCode);
            var storeContract = StoreContractInfo.Search(c => c.StoreCode == project.USCode).OrderByDescending(c => c.CreatedTime).FirstOrDefault();
            var assetMgr      = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetManager);
            var assetActor    = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
            var assetRep      = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == entity.ProjectId && pu.RoleCode == ProjectUserRoleCode.AssetRep);
            var results       = new List <EmailSendingResultType>();

            using (EmailServiceClient emailClient = new EmailServiceClient())
            {
                List <SimpleEmployee> approveEmps = new List <SimpleEmployee> {
                    approvers.MarketMgr,
                    approvers.GM,
                    approvers.MDD,
                    approvers.FC,
                    approvers.VPGM
                    //approvers.MCCLAssetMgr,
                    //approvers.MCCLAssetDtr
                };
                if (approvers.RegionalMgr != null)
                {
                    approveEmps.Add(approvers.RegionalMgr);
                }
                //邮件模板中的数据
                Dictionary <string, string> bodyValues = new Dictionary <string, string>();
                //邮件内容中的键值对
                bodyValues.Add("ApplicantName", ClientCookie.UserNameENUS);//--提交人
                bodyValues.Add("StoreCode", storeBasic.StoreCode);
                bodyValues.Add("StoreName", storeBasic.NameENUS + @" \ " + storeBasic.NameZHCN);
                bodyValues.Add("Actor", assetActor.UserNameENUS);     ////--呈递人
                //bodyValues.Add("WorkflowName", Constants.TempClosure_Package);////--流程名称
                bodyValues.Add("ProjectName", Constants.TempClosure); //项目名称
                var viewPage = string.Format("{0}/TempClosure/Main#/ClosurePackage/View/param?projectId={1}",
                                             HttpContext.Current.Request.Url.Authority, entity.ProjectId);
                bodyValues.Add("FormUrl", viewPage);
                Dictionary <string, string> templateFileds = new Dictionary <string, string>();
                var flowInfo = FlowInfo.Get(FlowCode.TempClosure);
                templateFileds.Add("WorkflowName", flowInfo.NameENUS);
                templateFileds.Add("ProjectID", entity.ProjectId);
                templateFileds.Add("USCode", storeBasic.StoreCode);
                templateFileds.Add("City", storeBasic.CityZHCN);
                templateFileds.Add("Region", storeBasic.Region);
                templateFileds.Add("StoreNameEN", storeBasic.NameENUS);
                templateFileds.Add("Market", storeBasic.Market);
                templateFileds.Add("StoreNameCN", storeBasic.NameZHCN);
                templateFileds.Add("StoreAge", Math.Floor((DateTime.Now - storeBasic.OpenDate).TotalDays / 365D).ToString());
                templateFileds.Add("OpenDate", storeBasic.OpenDate.ToString("yyyy-MM-dd"));
                var storeInfo = StoreBasicInfo.GetStore(project.USCode);

                if (!string.IsNullOrEmpty(storeInfo.StoreContractInfo.EndYear))
                {
                    templateFileds.Add("CurrentLeaseENDYear", (int.Parse(storeInfo.StoreContractInfo.EndYear) - storeInfo.CurrentYear).ToString());
                }
                else
                {
                    templateFileds.Add("CurrentLeaseENDYear", "");
                }

                if (assetMgr != null)
                {
                    templateFileds.Add("AssetsManager", assetMgr.UserNameENUS);
                }
                templateFileds.Add("AssetsActor", assetActor.UserNameENUS);
                templateFileds.Add("AssetsRep", assetRep.UserNameENUS);
                templateFileds.Add("ClosureDate", tempClosureInfo.ActualTempClosureDate.ToString("yyyy-MM-dd"));
                templateFileds.Add("LeaseExpireDate", tempClosureInfo.LeaseExpireDate.HasValue ? tempClosureInfo.LeaseExpireDate.Value.ToString("yyyy-MM-dd") : "");
                templateFileds.Add("ReOpenDate", tempClosureInfo.ActualReopenDate.ToString("yyyy-MM-dd"));
                templateFileds.Add("RentFreeTerm", string.IsNullOrEmpty(entity.RentReliefClause) ? "否" : "是");
                templateFileds.Add("RentFreeStartDate", entity.RentReliefStartDate.HasValue ? entity.RentReliefStartDate.Value.ToString("yyyy-MM-dd") : "");
                templateFileds.Add("RentFreeEndDate", entity.RentReliefEndDate.HasValue ? entity.RentReliefEndDate.Value.ToString("yyyy-MM-dd") : "");
                templateFileds.Add("FreeRentTerm", entity.RentReliefClause);
                var approveRecords = ProjectComment.GetList("TempClosurePackage", entity.Id, ProjectCommentStatus.Submit).Select(pc => new SubmissionApprovalRecord
                {
                    OperatorID    = pc.UserAccount,
                    OperatorName  = pc.UserNameENUS,
                    OperatorTitle = pc.TitleNameENUS,
                    OperationDate = pc.CreateTime.HasValue ? pc.CreateTime.Value : DateTime.Now,
                    ActionName    = pc.ActivityName,
                    Comments      = pc.Content
                }).ToList();
                string imgPath = HtmlConversionUtility.HtmlConvertToPDF(HtmlTempalteType.TempClosure, templateFileds, approveRecords);
                approveEmps.ForEach(e =>
                {
                    EmailMessage email           = new EmailMessage();
                    List <string> emailAddresses = new List <string>
                    {
                        e.Mail,
                        "*****@*****.**",
                        "*****@*****.**",
                        "*****@*****.**"
                    };
                    if (bodyValues.ContainsKey("ApproverName"))
                    {
                        bodyValues["ApproverName"] = e.NameENUS;
                    }
                    else
                    {
                        bodyValues.Add("ApproverName", e.NameENUS);//--提交人
                    }
                    email.EmailBodyValues = bodyValues;
                    email.To          = string.Join(";", emailAddresses);
                    email.Attachments = imgPath;
                    //var result =  emailClient.SendEmail(email);
                    results.Add(new EmailSendingResultType());
                });
                approvers.NoticeUsers.ForEach(e =>
                {
                    EmailMessage email           = new EmailMessage();
                    List <string> emailAddresses = new List <string>
                    {
                        e.Mail,
                        "*****@*****.**",
                        "*****@*****.**",
                        "*****@*****.**"
                    };
                    if (bodyValues.ContainsKey("ApproverName"))//--提交人
                    {
                        bodyValues["ApproverName"] = e.NameENUS;
                    }
                    else
                    {
                        bodyValues.Add("ApproverName", e.NameENUS);
                    }
                    email.EmailBodyValues = bodyValues;
                    email.To          = string.Join(";", emailAddresses);
                    email.Attachments = imgPath;
                    //var result = emailClient.SendEmail(email);
                    results.Add(new EmailSendingResultType());
                });
            }
            return(results);
        }
Esempio n. 11
0
        protected override void ChangeWorkflowApprovers(List <TaskWork> taskWorks, List <ApproveDialogUser> prevApprovers, ApproveUsers currApprover)
        {
            RebuildPackage packageInfo = null;

            if (taskWorks.Count > 0)
            {
                string refID = taskWorks[0].RefID;
                packageInfo = RebuildPackage.FirstOrDefault(i => i.ProjectId == refID && i.IsHistory == false);
            }
            foreach (var taskWork in taskWorks)
            {
                List <ProcessDataField> dataFields = null;
                switch (taskWork.TypeCode)
                {
                case FlowCode.Rebuild_Package:
                    var package = new RebuildPackage();
                    package.AppUsers = currApprover;
                    dataFields       = package.SetWorkflowDataFields(null);
                    ApproveDialogUser packageApprovers = null;
                    if (packageInfo == null)
                    {
                        packageApprovers = prevApprovers.FirstOrDefault(e => e.FlowCode == FlowCode.Rebuild_Package);
                    }
                    else
                    {
                        packageApprovers = prevApprovers.FirstOrDefault(e => e.RefTableID == packageInfo.Id.ToString());
                    }
                    if (packageApprovers != null)
                    {
                        SimpleEmployee receiver = null;
                        if (taskWork.ReceiverAccount == packageApprovers.MarketMgrCode &&
                            packageApprovers.MarketMgrCode != currApprover.MarketMgr.Code)
                        {
                            receiver = currApprover.MarketMgr;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.RegionalMgrCode &&
                            packageApprovers.RegionalMgrCode != currApprover.RegionalMgr.Code)
                        {
                            receiver = currApprover.RegionalMgr;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.MDDCode &&
                            packageApprovers.MDDCode != currApprover.MDD.Code)
                        {
                            receiver = currApprover.MDD;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.GMCode &&
                            packageApprovers.GMCode != currApprover.GM.Code)
                        {
                            receiver = currApprover.GM;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.FCCode &&
                            packageApprovers.FCCode != currApprover.FC.Code)
                        {
                            receiver = currApprover.FC;
                        }
                        //if (taskWork.ReceiverAccount == packageApprovers.RDDCode
                        //     && packageApprovers.RDDCode != currApprover.RDD.Code)
                        //{
                        //    receiver = currApprover.RDD;
                        //}
                        if (taskWork.ReceiverAccount == packageApprovers.VPGMCode &&
                            packageApprovers.VPGMCode != currApprover.VPGM.Code)
                        {
                            receiver = currApprover.VPGM;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.MCCLAssetDtrCode &&
                            packageApprovers.MCCLAssetDtrCode != currApprover.MCCLAssetDtr.Code)
                        {
                            receiver = currApprover.MCCLAssetDtr;
                        }

                        if (taskWork.ReceiverAccount == packageApprovers.CDOCode &&
                            packageApprovers.CDOCode != currApprover.CDO.Code)
                        {
                            receiver = currApprover.CDO;
                        }
                        if (taskWork.ReceiverAccount == packageApprovers.CFOCode &&
                            packageApprovers.CFOCode != currApprover.CFO.Code)
                        {
                            receiver = currApprover.CFO;
                        }
                        else
                        {
                            if (taskWork.ProcInstID.HasValue)
                            {
                                UpdateWorkflowDataField(taskWork.ProcInstID.Value, dataFields);
                            }
                        }

                        if (receiver != null)
                        {
                            RedirectWorkflowTask(taskWork.K2SN, taskWork.ReceiverAccount, receiver.Code, dataFields);

                            taskWork.ReceiverAccount  = receiver.Code;
                            taskWork.ReceiverNameENUS = receiver.NameENUS;
                            taskWork.ReceiverNameZHCN = receiver.NameZHCN;
                        }

                        if (currApprover.MarketMgr != null)
                        {
                            packageApprovers.MarketMgrCode = currApprover.MarketMgr.Code;
                        }
                        if (currApprover.RegionalMgr != null)
                        {
                            packageApprovers.RegionalMgrCode = currApprover.RegionalMgr.Code;
                        }
                        if (currApprover.DD != null)
                        {
                            packageApprovers.DDCode = currApprover.DD.Code;
                        }
                        if (currApprover.MDD != null)
                        {
                            packageApprovers.MDDCode = currApprover.MDD.Code;
                        }
                        if (currApprover.GM != null)
                        {
                            packageApprovers.GMCode = currApprover.GM.Code;
                        }
                        if (currApprover.FC != null)
                        {
                            packageApprovers.FCCode = currApprover.FC.Code;
                        }
                        if (currApprover.RDD != null)
                        {
                            packageApprovers.RDDCode = currApprover.RDD.Code;
                        }
                        if (currApprover.VPGM != null)
                        {
                            packageApprovers.VPGMCode = currApprover.VPGM.Code;
                        }
                        if (currApprover.MCCLAssetDtr != null)
                        {
                            packageApprovers.MCCLAssetDtrCode = currApprover.MCCLAssetDtr.Code;
                        }
                        if (currApprover.CDO != null)
                        {
                            packageApprovers.CDOCode = currApprover.CDO.Code;
                        }
                        if (currApprover.CFO != null)
                        {
                            packageApprovers.CFOCode = currApprover.CFO.Code;
                        }
                        packageApprovers.NoticeUsers = "";
                        foreach (var noticeUser in currApprover.NoticeUsers)
                        {
                            if (string.IsNullOrEmpty(packageApprovers.NoticeUsers))
                            {
                                packageApprovers.NoticeUsers = noticeUser.Code;
                            }
                            else
                            {
                                packageApprovers.NoticeUsers += ";" + noticeUser.Code;
                            }
                        }
                        packageApprovers.NecessaryNoticeUsers = "";
                        foreach (var noticeUser in currApprover.NecessaryNoticeUsers)
                        {
                            if (string.IsNullOrEmpty(packageApprovers.NecessaryNoticeUsers))
                            {
                                packageApprovers.NecessaryNoticeUsers = noticeUser.Code;
                            }
                            else
                            {
                                packageApprovers.NecessaryNoticeUsers += ";" + noticeUser.Code;
                            }
                        }
                        packageApprovers.Update();
                    }


                    break;
                }
            }
        }