示例#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);
        }
示例#2
0
        public WFTempClosurePackage(TempClosurePackage entity)
            : base(entity)
        {
            var approvers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());
            var task      = TaskWork.FirstOrDefault(t => t.RefID == entity.ProjectId && t.TypeCode == FlowCode.TempClosure_ClosurePackage);

            K2Param.AddDataField("dest_Creator", Entity.CreateUserAccount);
            K2Param.AddDataField("dest_MRMgrs", string.Concat(approvers.MarketMgrCode, ";", !string.IsNullOrEmpty(approvers.RegionalMgrCode) ? approvers.RegionalMgrCode : ""));
            K2Param.AddDataField("dest_GMApprovers", string.Concat(approvers.MDDCode, ";", approvers.GMCode, ";", approvers.FCCode));
            K2Param.AddDataField("dest_VPGM", approvers.VPGMCode);
            //K2Param.AddDataField("dest_DevVP", Entity.DevVP); Cary: 没有这个环节了。2014-9-11
            K2Param.AddDataField("ProcessCode", ProcessCode);
            K2Param.AddDataField("ProjectTaskInfo", JsonConvert.SerializeObject(task));
        }
示例#3
0
        public IHttpActionResult Get(string projectId, Guid?Id = null)
        {
            var project     = ProjectInfo.Get(projectId, FlowCode.TempClosure_ClosurePackage);
            var tempClosure = TempClosureInfo.FirstOrDefault(tc => tc.ProjectId == projectId);
            var isActor     = ProjectUsers.IsRole(projectId, ClientCookie.UserCode, ProjectUserRoleCode.AssetActor);
            TempClosurePackage entity;

            if (Id != null)
            {
                entity = TempClosurePackage.Get(Id.Value);
            }
            else
            {
                entity = TempClosurePackage.Get(projectId);
            }
            if (entity != null)
            {
                entity.IsProjectFreezed = entity.CheckIfFreezeProject(projectId);
                var SavedComment = ProjectComment.GetSavedComment(entity.Id, "TempClosurePackage", ClientCookie.UserCode);
                var hasValidTask = TaskWork.Any(t => t.RefID == projectId && t.Status == TaskWorkStatus.UnFinish && t.ReceiverAccount != ClientCookie.UserCode);
                return(Ok(new
                {
                    Info = tempClosure,
                    ClosurePackage = entity,
                    Approver = ApproveDialogUser.GetApproveDialogUser(projectId, FlowCode.TempClosure_ClosurePackage),
                    ProjectComment = SavedComment != null ? SavedComment.Content : "",
                    Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.TempClosure_ClosurePackage),
                    Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.TempClosure_ClosurePackage),
                    Rejectable = ApproveDialogUser.Any(u => u.ProjectId == projectId && u.FlowCode == FlowCode.TempClosure_ClosurePackage && u.VPGMCode == ClientCookie.UserCode),
                    Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.TempClosure_ClosurePackage)
                }));
            }
            else
            {
                entity = TempClosurePackage.Create(projectId);
                return(Ok(new
                {
                    Info = tempClosure,
                    ClosurePackage = entity,
                    Approver = ApproveDialogUser.GetApproveDialogUser(projectId, FlowCode.TempClosure_ClosurePackage),
                    ProjectComment = "",
                    Editable = (project.Status == ProjectStatus.Finished || project.Status == ProjectStatus.Rejected) && isActor && !entity.IsHistory,
                    Recallable = project.Status == ProjectStatus.UnFinish && isActor && project.NodeCode != NodeCode.Start,
                    Rejectable = ApproveDialogUser.Any(u => u.ProjectId == projectId && u.FlowCode == FlowCode.TempClosure_ClosurePackage && u.VPGMCode == ClientCookie.UserCode),
                    Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.TempClosure_ClosurePackage)
                }));
            }
        }
示例#4
0
        public IHttpActionResult ApprovePackage(ReimagePackage entity)
        {
            entity.ApprovePackage(ClientCookie.UserCode);
            var app = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            if (app != null && app.FinanceControllerCode == ClientCookie.UserCode)
            {
                try
                {
                    SendEmail(entity.ProjectId, entity.SerialNumber, entity.ProcInstID, app.VPGMCode);
                }
                catch (Exception e)
                {
                }
            }
            return(Ok(entity));
        }
 public IHttpActionResult SaveApproveDialogUsers(ApproveDialogUser users)
 {
     users.Save();
     return(Ok());
 }
        public IHttpActionResult GetApproveDialogUsers(string ProjectId, string FlowCode)
        {
            var approvUser = ApproveDialogUser.GetApproveDialogUser(ProjectId, FlowCode);

            return(Ok(approvUser));
        }
示例#7
0
        public IHttpActionResult GetRenewalApprovers(string flowCode, string projectId = "")
        {
            if (string.IsNullOrEmpty(flowCode))
            {
                return(BadRequest("flowCode is NULL"));
            }

            RenewalInfo renewalInfo = RenewalInfo.Get(projectId);

            if (renewalInfo == null)
            {
                return(BadRequest("Could not find the Renewal Info, please check it!"));
            }
            var dicUsers = new Dictionary <string, object>();
            var consMgr  = ProjectUsers.GetProjectUser(projectId, ProjectUserRoleCode.CM);

            switch (flowCode)
            {
            case FlowCode.Renewal_Letter:
            {
                var info = RenewalInfo.Get(projectId);
                dicUsers.Add("AssetManagerCode", info.AssetManagerAccount);
                dicUsers.Add("AssetManagers", new[] { Employee.GetSimpleEmployeeByCode(info.AssetManagerAccount) });
            }
            break;

            case FlowCode.Renewal_GBMemo:
            {
                var refTableId = RenewalInfo.GetRefTableId("RenewalGBMemo", projectId);
                var approvers  = ApproveDialogUser.GetApproveDialogUser(refTableId) ?? new ApproveDialogUser();
                dicUsers.Add("ConstructionManagerCode", approvers.ConstructionManagerCode);
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.Cons_Mgr));
            }
            break;

            case FlowCode.Renewal_ConsInfo:
            {
                var refTableId = RenewalInfo.GetRefTableId("RenewalConsInfo", projectId);
                var approvers  = ApproveDialogUser.GetApproveDialogUser(refTableId) ?? new ApproveDialogUser();
                dicUsers.Add("ConstructionManagerCode", approvers.ConstructionManagerCode);
                dicUsers.Add("MCCLConsManagerCode", approvers.MCCLConsManagerCode);
                dicUsers.Add("ConstructionManagers", new List <SimpleEmployee> {
                        new SimpleEmployee {
                            Code = consMgr.UserAccount, NameENUS = consMgr.UserNameENUS, NameZHCN = consMgr.UserNameZHCN
                        }
                    });
                dicUsers.Add("MCCLConsManagers", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.MCCL_Cons_Manager));
            }
            break;

            case FlowCode.Renewal_Tool:
            {
                var refTableId = RenewalInfo.GetRefTableId("RenewalTool", projectId);
                var approvers  = ApproveDialogUser.GetApproveDialogUser(refTableId) ?? new ApproveDialogUser();
                dicUsers.Add("FMCode", approvers.FMCode);
                dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.Finance_Manager));
            }
            break;

            case FlowCode.Renewal_LegalApproval:
            {
                var legal      = ProjectUsers.GetProjectUser(projectId, ProjectUserRoleCode.Legal);
                var refTableId = RenewalInfo.GetRefTableId("RenewalLegalApproval", projectId);
                var approvers  = ApproveDialogUser.GetApproveDialogUser(refTableId) ?? new ApproveDialogUser();
                dicUsers.Add("LegalCode", legal.UserAccount);
                dicUsers.Add("Legals", new List <SimpleEmployee> {
                        new SimpleEmployee {
                            Code = legal.UserAccount, NameENUS = legal.UserNameENUS, NameZHCN = legal.UserNameZHCN
                        }
                    });
                dicUsers.Add("GeneralCounselCode", approvers.GeneralCounselCode);
                dicUsers.Add("GeneralCounsels", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.Legal_GeneralCounsel));
            }
            break;

            case FlowCode.Renewal_Package:
            {
                var refTableId = RenewalInfo.GetRefTableId("RenewalPackage", projectId);
                var approvers  = ApproveDialogUser.GetApproveDialogUser(refTableId) ?? new ApproveDialogUser();
                dicUsers.Add("MarketMgrCode", approvers.MarketMgrCode);
                dicUsers.Add("MarketMgrs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.Market_Asset_Mgr));
                dicUsers.Add("RegionalMgrCode", approvers.RegionalMgrCode);
                dicUsers.Add("RegionalMgrs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.Regional_Asset_Mgr));
                dicUsers.Add("MDDCode", approvers.MDDCode);
                dicUsers.Add("MDDs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.Market_DD));
                dicUsers.Add("GMCode", approvers.GMCode);
                dicUsers.Add("GMs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.GM));
                dicUsers.Add("FCCode", approvers.FCCode);
                dicUsers.Add("FCs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.Finance_Controller));
                dicUsers.Add("RDDCode", approvers.RDDCode);
                dicUsers.Add("RDDs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.Regional_DD));
                dicUsers.Add("VPGMCode", approvers.VPGMCode);
                dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.VPGM));
                dicUsers.Add("MCCLAssetDtrCode", approvers.MCCLAssetDtrCode);
                dicUsers.Add("MCCLAssetDtrs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.MCCL_Asset_Director));
                dicUsers.Add("CDOCode", approvers.CDOCode);
                dicUsers.Add("CDOs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.CDO));
                dicUsers.Add("ManagingDirectorCode", approvers.MngDirectorCode);
                dicUsers.Add("ManagingDirectors", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.MD));        //MCCL_Cons_Director
                dicUsers.Add("MCCLAssetMgrCode", approvers.MCCLAssetMgrCode);
                dicUsers.Add("MCCLAssetMgrs", Employee.GetStoreEmployeesByRole(renewalInfo.USCode, RoleCode.MCCL_Asset_Mgr));
                dicUsers.Add("NoticeUsers", !string.IsNullOrEmpty(approvers.NoticeUsers) ? Employee.GetSimpleEmployeeByCodes(approvers.NoticeUsers.Split(';')) : null);
                dicUsers.Add("NecessaryNoticeUsers", !string.IsNullOrEmpty(approvers.NecessaryNoticeUsers) ? Employee.GetSimpleEmployeeByCodes(approvers.NecessaryNoticeUsers.Split(';')) : Employee.GetSimpleEmployeeByCodes(NecessaryNoticeConfig.Search(i => i.FlowCode == FlowCode.Renewal_Package && !string.IsNullOrEmpty(i.DefaultUserCode)).Select(i => i.DefaultUserCode).ToArray()));
            }
            break;
            }
            return(Ok(dicUsers));
        }