Exemplo n.º 1
0
        protected override void ChangeProjectApprover(List <TaskWork> taskWorks, ProjectTeamMembers projectTeamMembers)
        {
            foreach (var taskWork in taskWorks)
            {
                var work = taskWork;
                var approveDialogUser =
                    ApproveDialogUser.FirstOrDefault(
                        e => e.RefTableID == work.RefTableId.ToString() && e.FlowCode == work.TypeCode);

                List <ProcessDataField> dataFields = null;
                switch (taskWork.TypeCode)
                {
                case FlowCode.MajorLease_LegalReview:
                    var legalReview = new MajorLeaseLegalReview();
                    legalReview.AppUsers = new ApproveUsers()
                    {
                        Legal = new SimpleEmployee()
                        {
                            Code     = projectTeamMembers.Legal.UserAccount,
                            NameENUS = projectTeamMembers.Legal.UserNameENUS,
                            NameZHCN = projectTeamMembers.Legal.UserNameZHCN
                        }
                    };

                    dataFields = legalReview.SetWorkflowDataFields(null);

                    if (projectTeamMembers.Legal.UserAccount != LegalAccount &&
                        taskWork.ReceiverAccount == LegalAccount)
                    {
                        RedirectWorkflowTask(taskWork.K2SN, taskWork.ReceiverAccount, projectTeamMembers.Legal.UserAccount,
                                             dataFields);

                        taskWork.ReceiverAccount  = projectTeamMembers.Legal.UserAccount;
                        taskWork.ReceiverNameENUS = projectTeamMembers.Legal.UserNameENUS;
                        taskWork.ReceiverNameZHCN = projectTeamMembers.Legal.UserNameZHCN;
                    }
                    else
                    {
                        if (taskWork.ProcInstID.HasValue)
                        {
                            UpdateWorkflowDataField(taskWork.ProcInstID.Value, dataFields);
                        }
                    }
                    if (approveDialogUser != null)
                    {
                        approveDialogUser.LegalCode = projectTeamMembers.Legal.UserAccount;
                        ApproveDialogUser.Update(approveDialogUser);
                    }
                    break;
                }
            }

            LegalAccount  = projectTeamMembers.Legal.UserAccount;
            LegalNameENUS = projectTeamMembers.Legal.UserNameENUS;
            LegalNameZHCN = projectTeamMembers.Legal.UserNameZHCN;

            if (projectTeamMembers.AssetActor != null)
            {
                AssetActorAccount  = projectTeamMembers.AssetActor.UserAccount;
                AssetActorNameENUS = projectTeamMembers.AssetActor.UserNameENUS;
                AssetActorNameZHCN = projectTeamMembers.AssetActor.UserNameZHCN;
            }

            AssetRepAccount  = projectTeamMembers.AssetRep.UserAccount;
            AssetRepNameENUS = projectTeamMembers.AssetRep.UserNameENUS;
            AssetRepNameZHCN = projectTeamMembers.AssetRep.UserNameZHCN;

            FinanceAccount  = projectTeamMembers.Finance.UserAccount;
            FinanceNameENUS = projectTeamMembers.Finance.UserNameENUS;
            FinanceNameZHCN = projectTeamMembers.Finance.UserNameZHCN;

            PMAccount  = projectTeamMembers.PM.UserAccount;
            PMNameENUS = projectTeamMembers.PM.UserNameENUS;
            PMNameZHCN = projectTeamMembers.PM.UserNameZHCN;

            Update(this);
        }
Exemplo n.º 2
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;
                }
            }
        }