Esempio n. 1
0
        public IHttpActionResult GetRebuildApprovers(string flowCode, string projectId = "", bool isNeedEntity = false)
        {
            if (string.IsNullOrEmpty(flowCode))
            {
                throw new Exception("flowCode is NULL");
            }

            RebuildInfo rbdInfo = null;

            if (!string.IsNullOrEmpty(projectId))
            {
                rbdInfo = RebuildInfo.Search(e => e.ProjectId.Equals(projectId)).FirstOrDefault();
            }
            if (rbdInfo == null)
            {
                throw new Exception("Could not find the Rebuild Info, please check it!");
            }
            var          dicUsers     = new Dictionary <string, List <SimpleEmployee> >();
            BaseWFEntity returnEntity = null;

            switch (flowCode)
            {
            case FlowCode.Rebuild_LegalReview:
                dicUsers.Add("Legals", new List <SimpleEmployee>()
                {
                    new SimpleEmployee()
                    {
                        Code     = rbdInfo.LegalAccount,
                        NameENUS = rbdInfo.LegalNameENUS,
                        NameZHCN = rbdInfo.LegalNameZHCN
                    }
                });
                if (isNeedEntity)
                {
                    var entity = RebuildLegalReview.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        RebuildLegalReview.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;

            case FlowCode.Rebuild_FinanceAnalysis:
                dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Manager));
                if (isNeedEntity)
                {
                    var entity = RebuildFinancAnalysis.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        RebuildFinancAnalysis.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;

            case FlowCode.Rebuild_ConsInfo:
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Cons_Mgr));
                dicUsers.Add("MCCLConsManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.MCCL_Cons_Manager));
                if (isNeedEntity)
                {
                    var entity = RebuildConsInfo.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        RebuildConsInfo.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;

            case FlowCode.Rebuild_Package:
                dicUsers.Add("MarketMgrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Market_Asset_Mgr));
                dicUsers.Add("RegionalMgrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Regional_Asset_Mgr));
                dicUsers.Add("MDDs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Market_DD));
                dicUsers.Add("GMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.GM));
                dicUsers.Add("FCs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Controller));
                dicUsers.Add("RDDs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Regional_DD));
                dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.VPGM));
                dicUsers.Add("CDOs", Employee.GetEmployeesByRole(RoleCode.CDO));
                dicUsers.Add("CFOs", Employee.GetEmployeesByRole(RoleCode.CFO));
                dicUsers.Add("MngDirectors", Employee.GetEmployeesByRole(RoleCode.MD));
                if (isNeedEntity)
                {
                    var entity = RebuildPackage.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        RebuildPackage.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;

            case FlowCode.Rebuild_ConsInvtChecking:
                //dicUsers.Add("FMs", new List<SimpleEmployee>()
                //{
                //    new SimpleEmployee()
                //    {
                //        Code = rbdInfo.FinanceAccount,
                //        NameENUS = rbdInfo.FinanceNameENUS,
                //        NameZHCN = rbdInfo.FinanceNameZHCN
                //    }
                //});
                dicUsers.Add("FMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Manager));
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Cons_Mgr));
                dicUsers.Add("FinanceControllers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Finance_Controller));
                dicUsers.Add("VPGMs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.VPGM));
                if (isNeedEntity)
                {
                    var entity = RebuildConsInvtChecking.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        RebuildConsInvtChecking.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;

            case FlowCode.Rebuild_GBMemo:
                dicUsers.Add("ConstructionManagers", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.Cons_Mgr));
                if (isNeedEntity)
                {
                    var entity = GBMemo.FirstOrDefault((e => e.ProjectId.Equals(projectId) && !e.IsHistory));
                    if (entity != null)
                    {
                        GBMemo.PopulateAppUsers(entity);
                        returnEntity = entity;
                    }
                }
                break;
            }
            dicUsers.Add("MCCLAssetMgrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.MCCL_Asset_Mgr));
            dicUsers.Add("MCCLAssetDtrs", Employee.GetStoreEmployeesByRole(rbdInfo.USCode, RoleCode.MCCL_Asset_Director));


            return(Ok(new
            {
                dicUsers,
                returnEntity,
                rbdInfo
            }));
        }
Esempio n. 2
0
        public Guid?GetRefId(string projectId, string flowTable)
        {
            Guid?refId = null;

            switch (flowTable)
            {
            case "MajorLeaseConsInfo":
                var majorConsInfo = MajorLeaseConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory);
                if (majorConsInfo != null && majorConsInfo.Id != Guid.Empty)
                {
                    refId = majorConsInfo.Id;
                }
                else
                {
                    refId         = Guid.NewGuid();
                    majorConsInfo = new MajorLeaseConsInfo
                    {
                        Id         = refId.Value,
                        ProjectId  = projectId,
                        CreateTime = DateTime.Now,
                        IsHistory  = false
                    };
                    MajorLeaseConsInfo.Add(majorConsInfo);
                }
                break;

            case "MajorLeaseConsInvtChecking":
                var checkInfo = MajorLeaseConsInvtChecking.Search(e => e.ProjectId == projectId && !e.IsHistory).FirstOrDefault();
                if (checkInfo != null && checkInfo.Id != Guid.Empty)
                {
                    refId = checkInfo.Id;
                }
                else
                {
                    refId     = Guid.NewGuid();
                    checkInfo = new MajorLeaseConsInvtChecking
                    {
                        Id         = refId.Value,
                        ProjectId  = projectId,
                        CreateTime = DateTime.Now,
                        IsHistory  = false
                    };

                    MajorLeaseConsInvtChecking.Add(checkInfo);
                }
                break;

            case "ReimageConsInfo":
                var reimageConsInfo = ReimageConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory);
                if (reimageConsInfo != null && reimageConsInfo.Id != Guid.Empty)
                {
                    refId = reimageConsInfo.Id;
                }
                else
                {
                    refId           = Guid.NewGuid();
                    reimageConsInfo = new ReimageConsInfo
                    {
                        Id                = refId.Value,
                        ProjectId         = projectId,
                        IsHistory         = false,
                        CreateTime        = DateTime.Now,
                        CreateUserAccount = ClientCookie.UserCode
                    };
                    ReimageConsInfo.Add(reimageConsInfo);
                }
                break;

            case "ReimageConsInvtChecking":
                var reimageCheckInfo = ReimageConsInvtChecking.Search(e => e.ProjectId == projectId && !e.IsHistory).FirstOrDefault();
                if (reimageCheckInfo != null && reimageCheckInfo.Id != Guid.Empty)
                {
                    refId = reimageCheckInfo.Id;
                }
                else
                {
                    refId            = Guid.NewGuid();
                    reimageCheckInfo = new ReimageConsInvtChecking
                    {
                        Id         = refId.Value,
                        ProjectId  = projectId,
                        CreateTime = DateTime.Now,
                        IsHistory  = false
                    };

                    ReimageConsInvtChecking.Add(reimageCheckInfo);
                }
                break;

            case "RebuildConsInfo":
                var rbdConsInfo = RebuildConsInfo.FirstOrDefault(e => e.ProjectId == projectId && !e.IsHistory);
                if (rbdConsInfo != null && rbdConsInfo.Id != Guid.Empty)
                {
                    refId = rbdConsInfo.Id;
                }
                else
                {
                    refId       = Guid.NewGuid();
                    rbdConsInfo = new RebuildConsInfo
                    {
                        Id                 = refId.Value,
                        ProjectId          = projectId,
                        IsHistory          = false,
                        CreateTime         = DateTime.Now,
                        LastUpdateTime     = DateTime.Now,
                        CreateUserAccount  = ClientCookie.UserCode,
                        CreateUserNameENUS = ClientCookie.UserNameENUS,
                        CreateUserNameZHCN = ClientCookie.UserNameZHCN
                    };
                    RebuildConsInfo.Add(rbdConsInfo);
                }
                break;

            case "RebuildConsInvtChecking":
                var rbdCheckInfo = RebuildConsInvtChecking.Search(e => e.ProjectId == projectId && !e.IsHistory).FirstOrDefault();
                if (rbdCheckInfo != null && rbdCheckInfo.Id != Guid.Empty)
                {
                    refId = rbdCheckInfo.Id;
                }
                else
                {
                    refId        = Guid.NewGuid();
                    rbdCheckInfo = new RebuildConsInvtChecking
                    {
                        Id                 = refId.Value,
                        ProjectId          = projectId,
                        IsHistory          = false,
                        CreateTime         = DateTime.Now,
                        LastUpdateTime     = DateTime.Now,
                        CreateUserAccount  = ClientCookie.UserCode,
                        CreateUserNameENUS = ClientCookie.UserNameENUS,
                        CreateUserNameZHCN = ClientCookie.UserNameZHCN
                    };

                    RebuildConsInvtChecking.Add(rbdCheckInfo);
                }
                ProjectInfo.FinishNode(projectId, FlowCode.Rebuild_ConsInvtChecking,
                                       NodeCode.Rebuild_ConsInvtChecking_Downlod);
                ProjectInfo.FinishNode(projectId, FlowCode.Rebuild_ConsInvtChecking,
                                       NodeCode.Rebuild_ConsInvtChecking_Input);
                ProjectInfo.FinishNode(projectId, FlowCode.Rebuild_ConsInvtChecking,
                                       NodeCode.Rebuild_ConsInvtChecking_Upload);
                break;

            case "ClosureWOCheckList":
                var closureWOCheckList = ClosureWOCheckList.Get(projectId);
                if (closureWOCheckList != null && closureWOCheckList.Id != Guid.Empty)
                {
                    refId        = closureWOCheckList.Id;
                    _woCheckList = closureWOCheckList;
                }
                else
                {
                    refId = Guid.NewGuid();
                    closureWOCheckList = new ClosureWOCheckList
                    {
                        Id                = refId.Value,
                        ProjectId         = projectId,
                        CreateTime        = DateTime.Now,
                        CreateUserAccount = ClientCookie.UserCode,
                        CreateUserName    = ClientCookie.UserNameENUS,
                        IsHistory         = false
                    };
                    ClosureWOCheckList.Add(closureWOCheckList);
                }
                break;
            }

            return(refId);
        }