Exemplo n.º 1
0
        public IHttpActionResult Upload(string projectId, string refTableName, Guid?requirementId = null)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var refTableId = Attachment.GetRefTableId(refTableName, projectId);
                if (refTableId == Guid.Empty.ToString())
                {
                    var newId = Guid.NewGuid();
                    refTableId = newId.ToString();
                    switch (refTableName)
                    {
                    case "MajorLeaseChangePackage":
                    {
                        var entity = new MajorLeaseChangePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimageSummary":
                    {
                        var entity = new ReimageSummary();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimageConsInfo":
                    {
                        var entity = new ReimageConsInfo();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimagePackage":
                    {
                        var entity = new ReimagePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "RebuildLegalReview":
                    {
                        var entity = new RebuildLegalReview();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ClosureLegalReview":
                    {
                        var entity = new ClosureLegalReview();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ClosureExecutiveSummary":
                    {
                        var entity = new ClosureExecutiveSummary();
                        entity.ProjectId      = projectId;
                        entity.Id             = newId;
                        entity.CreateTime     = DateTime.Now;
                        entity.CreatorAccount = ClientCookie.UserCode;
                        entity.IsHistory      = false;
                        entity.Add();
                    }
                    break;

                    case "ClosurePackage":
                    {
                        var entity = new ClosurePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;
                    }
                }
                var userRole = ProjectUsers.Get(ClientCookie.UserCode, projectId);
                var files    = HttpContext.Current.Request.Files;
                if (requirementId.HasValue)
                {
                    var attReq      = AttachmentRequirement.Get(requirementId.Value);
                    var projectInfo = ProjectInfo.Get(projectId, attReq.FlowCode);
                    var store       = StoreBasicInfo.GetStorInfo(projectInfo.USCode);
                    var attachNode  = NodeInfo.FirstOrDefault(n => n.FlowCode == attReq.FlowCode && n.Code == attReq.NodeCode);
                    if (attachNode != null)
                    {
                        ProjectInfo.FinishNode(projectId, attReq.FlowCode, attReq.NodeCode);
                    }
                    var    file          = files[0];
                    string fileName      = Path.GetFileName(file.FileName);
                    string fileExtension = Path.GetExtension(file.FileName);
                    var    current       = System.Web.HttpContext.Current;
                    string internalName  = Guid.NewGuid() + fileExtension;
                    string absolutePath  = current.Server.MapPath("~/") + "UploadFiles/" + internalName;

                    file.SaveAs(absolutePath);

                    Attachment att = Attachment.Get(refTableId, requirementId.Value);

                    if (att == null)
                    {
                        att = new Attachment();
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        att.ID            = Guid.NewGuid();
                        att.RequirementId = requirementId;
                        att.TypeCode      = "";
                        Attachment.Add(att);
                    }
                    else
                    {
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        Attachment.Update(att);
                    }
                    //TempClosure上传SignAgreement
                    //if (requirementId.Value.Equals(new Guid("1E9B17AF-357A-4DC9-8A60-17766663FB75")))
                    //{
                    //    var url = "/TempClosure/Main#/ClosureMemo?projectId=" + projectId;
                    //    var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == projectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                    //    var title = string.Concat(projectId, " ", store.NameZHCN, " ", store.NameENUS);
                    //    TaskWork.Finish(t => t.ReceiverAccount == ClientCookie.UserCode && t.RefID == projectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == FlowCode.TempClosure_ClosurePackage);
                    //    //TaskWork.SendTask(projectId, title, projectInfo.USCode, url, actor, FlowCode.TempClosure, FlowCode.TempClosure_ClosureMemo, "Start");
                    //}
                }
                else
                {
                    List <Attachment> attachments = new List <Attachment>();
                    string            typeCode    = "";
                    if (refTableName == "RebuildLegalReview")
                    {
                        typeCode = "Contract";
                    }
                    for (int i = 0; i < files.Count; i++)
                    {
                        var    file          = files[i];
                        string fileName      = Path.GetFileName(file.FileName);
                        string fileExtension = Path.GetExtension(file.FileName);
                        var    current       = System.Web.HttpContext.Current;
                        string internalName  = Guid.NewGuid() + fileExtension;
                        string absolutePath  = current.Server.MapPath("~/") + "UploadFiles/" + internalName;

                        file.SaveAs(absolutePath);

                        Attachment att = new Attachment();
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        att.ID            = Guid.NewGuid();
                        att.RequirementId = requirementId;
                        att.TypeCode      = typeCode;
                        attachments.Add(att);
                    }
                    Attachment.Add(attachments.ToArray());
                }
                tranScope.Complete();
                return(Ok());
            }
        }
Exemplo n.º 2
0
        protected static BaseWFEntity GetEmptyWorkflowEntity(string flowCode)
        {
            BaseWFEntity wfEntity = null;

            switch (flowCode)
            {
            case FlowCode.MajorLease:
                wfEntity = new MajorLeaseInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.MajorLease_LegalReview:
                wfEntity = new MajorLeaseLegalReview();
                break;

            case FlowCode.MajorLease_FinanceAnalysis:
                wfEntity = new MajorLeaseFinancAnalysis();
                break;

            case FlowCode.MajorLease_ConsInfo:
                wfEntity = new MajorLeaseConsInfo();
                break;

            case FlowCode.MajorLease_Package:
                wfEntity = new MajorLeaseChangePackage();
                break;

            case FlowCode.MajorLease_ConsInvtChecking:
                wfEntity = new MajorLeaseConsInvtChecking();
                break;

            case FlowCode.MajorLease_GBMemo:
                wfEntity = new MajorLeaseGBMemo();
                break;

            case FlowCode.Closure:
                wfEntity = new ClosureInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Closure_ClosurePackage:
                wfEntity = new ClosurePackage();
                break;

            case FlowCode.Closure_ClosureTool:
                wfEntity = new ClosureTool();
                break;

            case FlowCode.Closure_ConsInvtChecking:
                wfEntity = new ClosureConsInvtChecking();
                break;

            case FlowCode.Closure_LegalReview:
                wfEntity = new ClosureLegalReview();
                break;

            case FlowCode.Closure_WOCheckList:
                wfEntity = new ClosureWOCheckList();
                break;

            case FlowCode.Closure_ExecutiveSummary:
                wfEntity = new ClosureExecutiveSummary();
                break;

            case FlowCode.TempClosure:
                wfEntity = new TempClosureInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.TempClosure_LegalReview:
                wfEntity = new TempClosureLegalReview();
                break;

            case FlowCode.TempClosure_ClosurePackage:
                wfEntity = new TempClosurePackage();
                break;

            case FlowCode.Rebuild:
                wfEntity = new RebuildInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Rebuild_LegalReview:
                wfEntity = new RebuildLegalReview();
                break;

            case FlowCode.Rebuild_FinanceAnalysis:
                wfEntity = new RebuildFinancAnalysis();
                break;

            case FlowCode.Rebuild_ConsInfo:
                wfEntity = new RebuildConsInfo();
                break;

            case FlowCode.Rebuild_Package:
                wfEntity = new RebuildPackage();
                break;

            case FlowCode.Rebuild_ConsInvtChecking:
                wfEntity = new RebuildConsInvtChecking();
                break;

            case FlowCode.Rebuild_GBMemo:
                wfEntity = new GBMemo();
                break;

            case FlowCode.Renewal:
                wfEntity = new RenewalInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Renewal_Letter:
                wfEntity = new RenewalLetter();
                break;

            case FlowCode.Renewal_LLNegotiation:
                wfEntity = new RenewalLLNegotiation();
                break;

            case FlowCode.Renewal_ConsInfo:
                wfEntity = new RenewalConsInfo();
                break;

            case FlowCode.Renewal_Tool:
                wfEntity = new RenewalTool();
                break;

            case FlowCode.Renewal_Analysis:
                wfEntity = new RenewalAnalysis();
                break;

            case FlowCode.Renewal_ClearanceReport:
                wfEntity = new RenewalClearanceReport();
                break;

            case FlowCode.Renewal_ConfirmLetter:
                wfEntity = new RenewalConfirmLetter();
                break;

            case FlowCode.Renewal_LegalApproval:
                wfEntity = new RenewalLegalApproval();
                break;

            case FlowCode.Renewal_Package:
                wfEntity = new RenewalPackage();
                break;

            case FlowCode.Renewal_GBMemo:
                wfEntity = new RenewalGBMemo();
                break;

            case FlowCode.Reimage:
                wfEntity = new ReimageInfo();
                wfEntity.IsMainProject = true;
                break;

            case FlowCode.Reimage_ConsInfo:
                wfEntity = new ReimageConsInfo();
                break;

            case FlowCode.Reimage_Summary:
                wfEntity = new ReimageSummary();
                break;

            case FlowCode.Reimage_Package:
                wfEntity = new ReimagePackage();
                break;

            case FlowCode.Reimage_ConsInvtChecking:
                wfEntity = new ReimageConsInvtChecking();
                break;

            case FlowCode.Reimage_GBMemo:
                wfEntity = new ReimageGBMemo();
                break;
            }
            return(wfEntity);
        }
Exemplo n.º 3
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
            }));
        }