Пример #1
0
        public static void PopulateAppUsers(RenewalGBMemo entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.ConstructionManagerCode
                };
                entity.AppUsers.ConstructionManager = simp;
            }
            else
            {
                if (entity.Info != null)
                {
                    var simp = new SimpleEmployee
                    {
                        Code = entity.Info.CMAccount
                    };
                    entity.AppUsers.ConstructionManager = simp;
                }
            }
        }
Пример #2
0
        public static void PopulateAppUsers(GBMemo entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.ConstructionManagerCode
                };
                entity.AppUsers.ConstructionManager = simp;
            }
            else
            {
                var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == entity.ProjectId);
                if (rbdInfo != null)
                {
                    var simp = new SimpleEmployee
                    {
                        Code = rbdInfo.CMAccount
                    };
                    entity.AppUsers.ConstructionManager = simp;
                }
            }
        }
Пример #3
0
 public void Resubmit(string comment, string SerialNumber)
 {
     K2FxContext.Current.ApprovalProcess(SerialNumber, ClientCookie.UserCode, "Resubmit", comment);
     using (TransactionScope tranScope = new TransactionScope())
     {
         this.CreateUserAccount = ClientCookie.UserCode;
         this.Update();
         var approveDialogUser = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());
         approveDialogUser.LegalCode = AppUsers.Legal.Code;
         //approveDialogUser.GeneralCounselCode = AppUsers.GeneralCounsel.Code;
         approveDialogUser.LastUpdateDate        = DateTime.Now;
         approveDialogUser.LastUpdateUserAccount = ClientCookie.UserCode;
         approveDialogUser.Update();
         ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.Renewal_LegalApproval_Input);
         ProjectComment.AddComment(
             ProjectCommentAction.ReSubmit,
             comment,
             this.Id,
             this.TableName,
             FlowCode.Renewal,
             this.ProcInstId,
             ProjectCommentStatus.Submit
             );
         tranScope.Complete();
     }
 }
Пример #4
0
 private void SaveApproveUsers(string actionName)
 {
     switch (actionName)
     {
     case ProjectAction.Submit:
     case ProjectAction.ReSubmit:
         var approveUser = ApproveDialogUser.GetApproveDialogUser(Id.ToString());
         if (approveUser == null)
         {
             approveUser            = new ApproveDialogUser();
             approveUser.Id         = Guid.Empty;
             approveUser.RefTableID = Id.ToString();
             approveUser.ProjectId  = ProjectId;
             approveUser.FlowCode   = FlowCode.Reimage_ConsInfo;
         }
         if (!CheckIfHasNoReinvestment())
         {
             approveUser.ConstructionManagerCode = AppUsers.ConstructionManager.Code;
             approveUser.MCCLConsManagerCode     = AppUsers.MCCLConsManager.Code;
         }
         approveUser.LastUpdateDate        = DateTime.Now;
         approveUser.LastUpdateUserAccount = ClientCookie.UserCode;
         approveUser.Save();
         break;
     }
 }
Пример #5
0
        private void SaveApprovers()
        {
            bool isNew = false;
            ApproveDialogUser approvers = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());

            if (approvers == null)
            {
                approvers            = new ApproveDialogUser();
                approvers.Id         = Guid.NewGuid();
                approvers.ProjectId  = this.ProjectId;
                approvers.FlowCode   = this.WorkflowCode;
                approvers.RefTableID = this.Id.ToString();
                isNew = true;
            }
            approvers.LastUpdateDate          = DateTime.Now;
            approvers.LastUpdateUserAccount   = ClientCookie.UserCode;
            approvers.ConstructionManagerCode = AppUsers.ConstructionManager.Code;
            approvers.MCCLConsManagerCode     = AppUsers.MCCLConsManager.Code;
            if (isNew)
            {
                approvers.Add();
            }
            else
            {
                approvers.Update();
            }
        }
Пример #6
0
 private void SaveApproveUsers(string actionName)
 {
     switch (actionName)
     {
     case ProjectAction.Submit:
     case ProjectAction.ReSubmit:
         var approveUser = ApproveDialogUser.GetApproveDialogUser(Id.ToString());
         if (approveUser == null)
         {
             approveUser            = new ApproveDialogUser();
             approveUser.Id         = Guid.Empty;
             approveUser.RefTableID = Id.ToString();
             approveUser.ProjectId  = ProjectId;
             approveUser.FlowCode   = FlowCode.Reimage_ConsInvtChecking;
         }
         approveUser.ConstructionManagerCode = AppUsers.ConstructionManager.Code;
         approveUser.FMCode = AppUsers.FM.Code;
         approveUser.FinanceControllerCode = AppUsers.FinanceController.Code;
         approveUser.VPGMCode              = AppUsers.VPGM.Code;
         approveUser.LastUpdateDate        = DateTime.Now;
         approveUser.LastUpdateUserAccount = ClientCookie.UserCode;
         approveUser.Save();
         break;
     }
 }
Пример #7
0
        public void Submit(string comment, Action onExecuting = null)
        {
            var actor = ProjectUsers.GetProjectUser(this.ProjectId, ProjectUserRoleCode.AssetActor);
            var task  = TaskWork.GetTaskWork(ProjectId, ClientCookie.UserCode, TaskWorkStatus.UnFinish,
                                             FlowCode.Renewal, WorkflowCode);
            var dataFields = SetWorkflowDataFields(task);
            var procInstId = K2FxContext.Current.StartProcess(WorkflowProcessCode, ClientCookie.UserCode, dataFields);

            if (procInstId > 0)
            {
                using (TransactionScope tranScope = new TransactionScope())
                {
                    this.ProcInstId        = procInstId;
                    this.CreateTime        = DateTime.Now;
                    this.CreateUserAccount = ClientCookie.UserCode;
                    this.Update();
                    var approveDialogUser = new ApproveDialogUser();
                    approveDialogUser.Id         = Guid.NewGuid();
                    approveDialogUser.LegalCode  = AppUsers.Legal.Code;
                    approveDialogUser.ProjectId  = this.ProjectId;
                    approveDialogUser.FlowCode   = this.WorkflowCode;
                    approveDialogUser.RefTableID = this.Id.ToString();
                    approveDialogUser.Add();
                    var project = ProjectInfo.Get(this.ProjectId, this.WorkflowCode);
                    project.CreateUserAccount = ClientCookie.UserCode;
                    project.Update();
                    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,
                            this.TableName,
                            FlowCode.Renewal,
                            procInstId,
                            ProjectCommentStatus.Submit
                            );
                    }
                    ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.Renewal_LegalApproval_Input);
                    if (onExecuting != null)
                    {
                        onExecuting();
                    }
                    tranScope.Complete();
                }
            }
        }
Пример #8
0
        private void SaveApprovers()
        {
            bool isNew = false;
            ApproveDialogUser approvers = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());

            if (approvers == null)
            {
                approvers            = new ApproveDialogUser();
                approvers.Id         = Guid.NewGuid();
                approvers.ProjectId  = this.ProjectId;
                approvers.FlowCode   = this.WorkflowCode;
                approvers.RefTableID = this.Id.ToString();
                isNew = true;
            }
            approvers.MarketMgrCode = AppUsers.MarketMgr.Code;
            if (AppUsers.RegionalMgr != null)
            {
                approvers.RegionalMgrCode = AppUsers.RegionalMgr.Code;
            }
            approvers.MDDCode = AppUsers.MDD.Code;
            if (AppUsers.GM != null)
            {
                approvers.GMCode = AppUsers.GM.Code;
            }
            approvers.FCCode           = AppUsers.FC.Code;
            approvers.VPGMCode         = AppUsers.VPGM.Code;
            approvers.MCCLAssetDtrCode = AppUsers.MCCLAssetDtr.Code;
            if (AppUsers.CDO != null)
            {
                approvers.CDOCode = AppUsers.CDO.Code;
            }
            approvers.MngDirectorCode = AppUsers.ManagingDirector.Code;
            if (AppUsers.MCCLAssetMgr != null)
            {
                approvers.MCCLAssetMgrCode = AppUsers.MCCLAssetMgr.Code;
            }
            if (AppUsers.NecessaryNoticeUsers != null)
            {
                approvers.NecessaryNoticeUsers = string.Join(";", AppUsers.NecessaryNoticeUsers.Select(u => u.Code).ToArray());
            }
            if (AppUsers.NoticeUsers != null)
            {
                approvers.NoticeUsers = string.Join(";", AppUsers.NoticeUsers.Select(u => u.Code).ToArray());
            }
            if (isNew)
            {
                approvers.Add();
            }
            else
            {
                approvers.Update();
            }
        }
Пример #9
0
        private void PopulateAppUsers(MajorLeaseFinancAnalysis entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.FMCode
                };
                entity.AppUsers.FM = simp;
            }
        }
Пример #10
0
        public static void PopulateAppUsers(RebuildLegalReview entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.LegalCode
                };
                entity.AppUsers.Legal = simp;
            }
        }
Пример #11
0
        public static void PopulateAppUsers(RebuildFinancAnalysis entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.FMCode
                };
                entity.AppUsers.FM = simp;
            }
        }
Пример #12
0
        public override ApproveDialogUser GetApproveDialogUser()
        {
            var approvers = ApproveDialogUser.FirstOrDefault(e => e.RefTableID == Id.ToString());

            if (approvers == null)
            {
                approvers = new ApproveDialogUser();
                var majorLeaesInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId == ProjectId);
                if (majorLeaesInfo != null)
                {
                    approvers.ConstructionManagerCode = majorLeaesInfo.CMAccount;
                }
            }
            return(approvers);
        }
Пример #13
0
        public static ProjectDto GetApproverAndNoticeUsers(string projectId)
        {
            var approver = ApproveDialogUser.GetApproveDialogUser(projectId, FlowCode.TempClosure_ClosurePackage);

            if (approver != null)
            {
                return(new ProjectDto
                {
                    ApproveUsers = new ApproveUsers
                    {
                        MarketMgr = Employee.GetSimpleEmployeeByCode(approver.MarketMgrCode),
                        RegionalMgr = Employee.GetSimpleEmployeeByCode(approver.RegionalMgrCode),
                        MDD = Employee.GetSimpleEmployeeByCode(approver.MDDCode),
                        GM = Employee.GetSimpleEmployeeByCode(approver.GMCode),
                        FC = Employee.GetSimpleEmployeeByCode(approver.FCCode),
                        VPGM = Employee.GetSimpleEmployeeByCode(approver.VPGMCode),
                        MCCLAssetMgr = Employee.GetSimpleEmployeeByCode(approver.MCCLAssetMgrCode),
                        MCCLAssetDtr = Employee.GetSimpleEmployeeByCode(approver.MCCLAssetDtrCode),
                        NoticeUsers = string.IsNullOrEmpty(approver.NoticeUsers.TrimEnd(';')) ? new List <SimpleEmployee>() : Employee.GetSimpleEmployeeByCodes(approver.NoticeUsers.TrimEnd(';').Split(';')),

                        NecessaryNoticeUsers = string.IsNullOrEmpty(approver.NecessaryNoticeUsers.TrimEnd(';')) ? new List <SimpleEmployee>() : Employee.GetSimpleEmployeeByCodes(approver.NecessaryNoticeUsers.TrimEnd(';').Split(';'))
                    },
                    FlowCode = FlowCode.TempClosure_ClosurePackage,
                    ProjectId = projectId
                });
            }
            else
            {
                return(new ProjectDto
                {
                    ApproveUsers = new ApproveUsers
                    {
                        MarketMgr = null,
                        RegionalMgr = null,
                        MDD = null,
                        GM = null,
                        FC = null,
                        VPGM = null,
                        MCCLAssetMgr = null,
                        MCCLAssetDtr = null,
                        NoticeUsers = new List <SimpleEmployee>(),
                        NecessaryNoticeUsers = Employee.GetSimpleEmployeeByCodes(NecessaryNoticeConfig.Search(i => i.FlowCode == FlowCode.TempClosure_ClosurePackage && !string.IsNullOrEmpty(i.DefaultUserCode)).Select(i => i.DefaultUserCode).ToArray())
                    },
                    FlowCode = FlowCode.TempClosure_ClosurePackage,
                    ProjectId = projectId
                });
            }
        }
Пример #14
0
        private void PopulateAppUsers(ReimageConsInvtChecking entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.ConstructionManagerCode
                };
                entity.AppUsers.ConstructionManager = simp;

                entity.AppUsers = new ApproveUsers();
                simp            = new SimpleEmployee
                {
                    Code = approvedUsers.FMCode
                };
                entity.AppUsers.FM = simp;

                entity.AppUsers = new ApproveUsers();
                simp            = new SimpleEmployee
                {
                    Code = approvedUsers.FinanceControllerCode
                };
                entity.AppUsers.FinanceController = simp;

                entity.AppUsers = new ApproveUsers();
                simp            = new SimpleEmployee
                {
                    Code = approvedUsers.VPGMCode
                };
                entity.AppUsers.VPGM = simp;
            }
            else
            {
                var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == ProjectId);
                if (reimageInfo != null)
                {
                    entity.AppUsers.ConstructionManager = new SimpleEmployee
                    {
                        Code = reimageInfo.CMAccount
                    };
                }
            }
        }
Пример #15
0
        private void PopulateAppUsers()
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());

            this.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.ConstructionManagerCode
                };
                this.AppUsers.ConstructionManager = simp;

                simp = new SimpleEmployee
                {
                    Code = approvedUsers.MCCLConsManagerCode
                };
                this.AppUsers.MCCLConsManager = simp;

                //simp = new SimpleEmployee
                //{
                //    Code = approvedUsers.MCCLAssetMgrCode
                //};
                //entity.AppUsers.MCCLAssetMgr = simp;

                //simp = new SimpleEmployee
                //{
                //    Code = approvedUsers.MCCLAssetDtrCode
                //};
                //entity.AppUsers.MCCLAssetDtr = simp;
            }
            else
            {
                var reimageInfo = ReimageInfo.FirstOrDefault(e => e.ProjectId == ProjectId);
                if (reimageInfo != null)
                {
                    this.AppUsers.ConstructionManager = new SimpleEmployee
                    {
                        Code = reimageInfo.CMAccount
                    };
                }
            }
        }
Пример #16
0
        private void PopulateAppUsers(MajorLeaseConsInfo entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.ConstructionManagerCode
                };
                entity.AppUsers.ConstructionManager = simp;

                simp = new SimpleEmployee
                {
                    Code = approvedUsers.MCCLConsManagerCode
                };
                entity.AppUsers.MCCLConsManager = simp;

                //simp = new SimpleEmployee
                //{
                //    Code = approvedUsers.MCCLAssetMgrCode
                //};
                //entity.AppUsers.MCCLAssetMgr = simp;

                //simp = new SimpleEmployee
                //{
                //    Code = approvedUsers.MCCLAssetDtrCode
                //};
                //entity.AppUsers.MCCLAssetDtr = simp;
            }
            else
            {
                var majorLeaesInfo = MajorLeaseInfo.FirstOrDefault(e => e.ProjectId == ProjectId);
                if (majorLeaesInfo != null)
                {
                    entity.AppUsers.ConstructionManager = new SimpleEmployee()
                    {
                        Code = majorLeaesInfo.CMAccount
                    };
                }
            }
        }
Пример #17
0
 private void SaveApproveUsers(string actionName)
 {
     switch (actionName)
     {
     case ProjectAction.Submit:
     case ProjectAction.ReSubmit:
         var approveUser = ApproveDialogUser.GetApproveDialogUser(Id.ToString());
         if (approveUser == null)
         {
             approveUser            = new ApproveDialogUser();
             approveUser.Id         = Guid.Empty;
             approveUser.RefTableID = Id.ToString();
             approveUser.ProjectId  = ProjectId;
             approveUser.FlowCode   = FlowCode.Rebuild_LegalReview;
         }
         approveUser.LegalCode             = AppUsers.Legal.Code;
         approveUser.LastUpdateDate        = DateTime.Now;
         approveUser.LastUpdateUserAccount = ClientCookie.UserCode;
         approveUser.Save();
         break;
     }
 }
Пример #18
0
        public static RenewalLegalApprovalDTO InitPage(string projectId, string id = null)
        {
            RenewalLegalApprovalDTO dto = new RenewalLegalApprovalDTO();
            var entity  = Get(projectId, id);
            var info    = RenewalInfo.Get(projectId);
            var isActor = ClientCookie.UserCode == info.AssetActorAccount;

            entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId);
            var nextRefTableId  = new Guid(FlowInfo.GetRefTableId(entity.TableName, projectId));
            var nextFlowStarted = ProjectInfo.IsFlowStarted(projectId, FlowCode.Renewal_Package);
            var haveTask        = TaskWork.Any(t => t.RefID == projectId && t.TypeCode == FlowCode.Renewal_LegalApproval && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount == ClientCookie.UserCode);
            var projectComment  = ProjectComment.GetSavedComment(entity.Id, entity.TableName, ClientCookie.UserCode);
            var appUser         = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            dto.Info             = info;
            dto.Entity           = entity;
            dto.ProjectComment   = projectComment != null ? projectComment.Content : "";
            dto.IsGeneralCounsel = appUser != null && appUser.GeneralCounselCode == ClientCookie.UserCode;
            dto.Editable         = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_LegalApproval);
            dto.Recallable       = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_LegalApproval);
            dto.Savable          = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_LegalApproval) && string.IsNullOrEmpty(id);
            return(dto);
        }
Пример #19
0
 public void Approve(string comment, string SerialNumber, bool isGeneralCouncel)
 {
     if (isGeneralCouncel)
     {
         K2FxContext.Current.ApprovalProcess(SerialNumber, ClientCookie.UserCode, "Approve", comment);
     }
     else
     {
         K2FxContext.Current.ApprovalProcess(SerialNumber, ClientCookie.UserCode, "Approve", comment, SetWorkflowDataFieldsByLegal());
     }
     using (TransactionScope tranScope = new TransactionScope())
     {
         if (!isGeneralCouncel)
         {
             var approveDialogUser = ApproveDialogUser.GetApproveDialogUser(this.Id.ToString());
             approveDialogUser.GeneralCounselCode = AppUsers.GeneralCounsel.Code;
             approveDialogUser.Update();
         }
         this.LastUpdateTime        = DateTime.Now;
         this.LastUpdateUserAccount = ClientCookie.UserCode;
         this.Update();
         ProjectComment.AddComment(
             ProjectCommentAction.Approve,
             comment,
             this.Id,
             this.TableName,
             FlowCode.Renewal,
             this.ProcInstId,
             ProjectCommentStatus.Submit
             );
         if (!isGeneralCouncel)
         {
             ProjectInfo.FinishNode(this.ProjectId, this.WorkflowCode, NodeCode.Renewal_LegalApproval_LegalReview);
         }
         tranScope.Complete();
     }
 }
Пример #20
0
        public void SaveApproveUsers(string actionName)
        {
            switch (actionName)
            {
            case ProjectAction.Submit:
            case ProjectAction.ReSubmit:
                var approveUser = ApproveDialogUser.GetApproveDialogUser(Id.ToString());
                if (approveUser == null)
                {
                    approveUser            = new ApproveDialogUser();
                    approveUser.Id         = Guid.Empty;
                    approveUser.RefTableID = Id.ToString();
                    approveUser.ProjectId  = ProjectId;
                    approveUser.FlowCode   = FlowCode.Closure_ClosurePackage;
                }
                if (!string.IsNullOrEmpty(MarketMgrCode))
                {
                    approveUser.MarketMgrCode = MarketMgrCode;
                }
                else
                {
                    approveUser.MarketMgrCode = string.Empty;
                }
                if (!string.IsNullOrEmpty(RegionalMgrCode))
                {
                    approveUser.RegionalMgrCode = RegionalMgrCode;
                }
                else
                {
                    approveUser.RegionalMgrCode = string.Empty;
                }
                if (!string.IsNullOrEmpty(MDD))
                {
                    approveUser.MDDCode = MDD;
                }
                else
                {
                    approveUser.MDDCode = string.Empty;
                }
                if (!string.IsNullOrEmpty(GM))
                {
                    approveUser.GMCode = GM;
                }
                else
                {
                    approveUser.GMCode = string.Empty;
                }
                if (!string.IsNullOrEmpty(FC))
                {
                    approveUser.FCCode = FC;
                }
                else
                {
                    approveUser.FCCode = string.Empty;
                }
                if (!string.IsNullOrEmpty(RDD))
                {
                    approveUser.RDDCode = RDD;
                }
                else
                {
                    approveUser.RDDCode = string.Empty;
                }

                if (!string.IsNullOrEmpty(VPGM))
                {
                    approveUser.VPGMCode = VPGM;
                }
                else
                {
                    approveUser.VPGMCode = string.Empty;
                }

                if (!string.IsNullOrEmpty(CDO))
                {
                    approveUser.CDOCode = CDO;
                }
                else
                {
                    approveUser.CDOCode = string.Empty;
                }

                if (!string.IsNullOrEmpty(CFO))
                {
                    approveUser.CFOCode = CFO;
                }
                else
                {
                    approveUser.CFOCode = string.Empty;
                }

                if (!string.IsNullOrEmpty(MngDirector))
                {
                    approveUser.MngDirectorCode = MngDirector;
                }
                else
                {
                    approveUser.MngDirectorCode = string.Empty;
                }

                if (!string.IsNullOrEmpty(MCCLAssetMgr))
                {
                    approveUser.MCCLAssetMgrCode = MCCLAssetMgr;
                }
                else
                {
                    approveUser.MCCLAssetMgrCode = string.Empty;
                }
                if (!string.IsNullOrEmpty(MCCLAssetDtr))
                {
                    approveUser.MCCLAssetDtrCode = MCCLAssetDtr;
                }
                else
                {
                    approveUser.MCCLAssetDtrCode = string.Empty;
                }
                if (NoticeUsers != null && NoticeUsers.Count > 0)
                {
                    approveUser.NoticeUsers = string.Join(";", NoticeUsers.Select(e => e.Code).ToArray());
                }
                else
                {
                    approveUser.NoticeUsers = string.Empty;
                }
                if (NecessaryNoticeUsers != null && NecessaryNoticeUsers.Count > 0)
                {
                    approveUser.NecessaryNoticeUsers = string.Join(";", NecessaryNoticeUsers.Select(e => e.Code).ToArray());
                }
                else
                {
                    approveUser.NecessaryNoticeUsers = string.Empty;
                }
                approveUser.LastUpdateDate        = DateTime.Now;
                approveUser.LastUpdateUserAccount = ClientCookie.UserCode;
                approveUser.Save();
                break;
            }
        }
Пример #21
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;
                }
            }
        }
Пример #22
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();
                }
            }
        }
Пример #23
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();
            }
        }
Пример #24
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);
        }