Exemplo n.º 1
0
        public IHttpActionResult GetAvailableUserCodes(string storeCode, string flowCode, string userCode = "")
        {
            var config = NecessaryNoticeConfig.Search(i => i.FlowCode == flowCode);

            if (config == null)
            {
                return(Ok());
            }
            var resultCodes = string.Empty;
            var arry        = config.Select(i => i.NecessaryNoticeRoles).ToArray();
            var dictionary  = Employee.GetStoreEmployeesRoleCodeByMultiRoles(storeCode, arry);
            var roleUser    = new List <object>();

            foreach (var dictItem in dictionary)
            {
                if (string.IsNullOrEmpty(resultCodes))
                {
                    resultCodes += dictItem.Key;
                }
                else
                {
                    resultCodes += "," + dictItem.Key;
                }
                roleUser.Add(new
                {
                    UserCode = dictItem.Key,
                    RoleName = dictItem.Value
                });
            }
            return(Ok(new
            {
                UserCodes = resultCodes,
                RoleNames = String.Join(",", arry),
                RoleUser = roleUser
            }));
        }
Exemplo n.º 2
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));
        }