public IHttpActionResult InitPage(string projectId) { var info = RenewalInfo.Get(projectId); var siteInfoProject = ProjectInfo.Get(projectId, FlowCode.Renewal_SiteInfo); var estimatedVsActualConstruction = EstimatedVsActualConstruction.FirstOrDefault(e => e.RefId == siteInfoProject.Id); if (estimatedVsActualConstruction == null) { var consInfo = RenewalConsInfo.Get(projectId); var reinBasicInfo = ReinvestmentBasicInfo.GetByConsInfoId(consInfo.Id); var storeInfo = StoreSTLocation.FirstOrDefault(e => e.StoreCode == info.USCode); estimatedVsActualConstruction = new EstimatedVsActualConstruction { RefId = siteInfoProject.Id, GBDate = reinBasicInfo != null ? reinBasicInfo.GBDate : null, CompletionDate = reinBasicInfo != null ? reinBasicInfo.ConsCompletionDate : null, ARDC = reinBasicInfo != null ? reinBasicInfo.NewDesignType : null, OriginalOperationSize = storeInfo.TotalArea, OriginalSeatNumber = storeInfo.TotalSeatsNo, ClosureDays = reinBasicInfo != null ? (reinBasicInfo.ConsCompletionDate.Value - reinBasicInfo.GBDate.Value).TotalDays.ToString() : "" }; } var result = new { Info = info, Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_SiteInfo), EstimatedVsActualConstruction = estimatedVsActualConstruction }; return(Ok(result)); }
public IHttpActionResult GetCreateFlowInfo(string projectId, string flowCode) { Object entity = null; if (flowCode.ToLower() == "rebuild") { entity = new RebuildInfo().GetRebuildInfo(projectId); } else if (flowCode.ToLower() == "reimage") { entity = ReimageInfo.GetReimageInfo(projectId); } else if (flowCode.ToLower() == "renewal") { entity = RenewalInfo.Get(projectId); } else if (flowCode.ToLower() == "tempclosure") { entity = TempClosureInfo.Get(projectId); } else if (flowCode.ToLower() == "closure") { entity = ClosureInfo.GetByProjectId(projectId); } else if (flowCode.ToLower() == "majorlease") { entity = new MajorLeaseInfo().GetMajorLeaseInfo(projectId); } return(Ok(entity)); }
public void DownloadToolTemplate(string projectId) { var renewalTool = RenewalTool.Get(projectId); var renewalInfo = RenewalInfo.Get(projectId); var fileName = renewalTool.DownloadToolTemplate(); var current = HttpContext.Current; current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + SiteFilePath.GetTemplateFileName(renewalInfo.USCode, FlowCode.Renewal_Tool, "RenewalToolTemplate.xlsx")); current.Response.ContentType = "application/octet-stream"; current.Response.WriteFile(fileName); current.Response.End(); }
public IHttpActionResult InitPage(string projectId, string id = null) { var entity = RenewalConfirmLetter.Get(projectId, id); return(Ok(new { Entity = entity, Info = RenewalInfo.Get(projectId), Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_ConfirmLetter), Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_ConfirmLetter), Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_ConfirmLetter) })); }
public IHttpActionResult InitPage(string projectId) { var info = RenewalInfo.Get(projectId); var nego = RenewalLLNegotiation.Get(projectId); return(Ok(new { LLNegotiation = nego, USCode = info.USCode, Editable = ProjectInfo.IsFlowEditable(projectId, FlowCode.Renewal_LLNegotiation), Recallable = ProjectInfo.IsFlowRecallable(projectId, FlowCode.Renewal_LLNegotiation), Savable = ProjectInfo.IsFlowSavable(projectId, FlowCode.Renewal_LLNegotiation) })); }
public IHttpActionResult Get(string projectId) { return(Ok(RenewalInfo.Get(projectId))); }
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)); }
public IHttpActionResult UploadAttachment(string flowCode, string typeCode, string usCode, Guid Id) { var refTableId = string.Empty; var refTableName = string.Empty; var projectInfo = ProjectInfo.Get(Id); var projectId = string.Empty; if (projectInfo == null) { projectId = ProjectInfo.CreateDLProject(Id, flowCode, usCode, NodeCode.Start, ClientCookie.UserCode, false); } else { projectId = projectInfo.ProjectId; } using (TransactionScope tranScope = new TransactionScope()) { switch (flowCode) { case FlowCode.Closure: refTableName = "ClosureInfo"; var closureInfo = ClosureInfo.FirstOrDefault(i => i.ProjectId == projectId); if (closureInfo != null) { refTableId = closureInfo.Id.ToString(); } else { closureInfo = new ClosureInfo(); closureInfo.Id = Guid.NewGuid(); closureInfo.ProjectId = projectId; closureInfo.USCode = usCode; closureInfo.CreateDate = DateTime.Now; closureInfo.CreateUserAccount = ClientCookie.UserCode; closureInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; closureInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; closureInfo.Add(); refTableId = closureInfo.Id.ToString(); } break; case FlowCode.Rebuild: refTableName = "RebuildInfo"; var rebuildInfo = RebuildInfo.FirstOrDefault(i => i.ProjectId == projectId); if (rebuildInfo != null) { refTableId = rebuildInfo.Id.ToString(); } else { rebuildInfo = new RebuildInfo(); rebuildInfo.Id = Guid.NewGuid(); rebuildInfo.ProjectId = projectId; rebuildInfo.USCode = usCode; rebuildInfo.CreateTime = DateTime.Now; rebuildInfo.CreateUserAccount = ClientCookie.UserCode; rebuildInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; rebuildInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; rebuildInfo.Add(); refTableId = rebuildInfo.Id.ToString(); } break; case FlowCode.MajorLease: refTableName = "MajorLeaseInfo"; var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(i => i.ProjectId == projectId); if (majorLeaseInfo != null) { refTableId = majorLeaseInfo.Id.ToString(); } else { majorLeaseInfo = new MajorLeaseInfo(); majorLeaseInfo.Id = Guid.NewGuid(); majorLeaseInfo.ProjectId = projectId; majorLeaseInfo.USCode = usCode; majorLeaseInfo.CreateTime = DateTime.Now; majorLeaseInfo.CreateUserAccount = ClientCookie.UserCode; majorLeaseInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; majorLeaseInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; majorLeaseInfo.Add(); refTableId = majorLeaseInfo.Id.ToString(); } break; case FlowCode.Renewal: refTableName = "RenewalInfo"; var renewalInfo = RenewalInfo.Get(projectId); if (renewalInfo != null) { refTableId = renewalInfo.Id.ToString(); } else { renewalInfo = new RenewalInfo(); renewalInfo.Id = Guid.NewGuid(); renewalInfo.ProjectId = projectId; renewalInfo.USCode = usCode; renewalInfo.CreateTime = DateTime.Now; renewalInfo.CreateUserAccount = ClientCookie.UserCode; renewalInfo.Add(); refTableId = renewalInfo.Id.ToString(); } break; case FlowCode.Reimage: refTableName = "ReimageInfo"; var reimageInfo = ReimageInfo.GetReimageInfo(projectId); if (reimageInfo != null) { refTableId = reimageInfo.Id.ToString(); } else { reimageInfo = new ReimageInfo(); reimageInfo.Id = Guid.NewGuid(); reimageInfo.ProjectId = projectId; reimageInfo.USCode = usCode; reimageInfo.CreateDate = DateTime.Now; reimageInfo.CreateUserAccount = ClientCookie.UserCode; reimageInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; reimageInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; reimageInfo.Add(); refTableId = reimageInfo.Id.ToString(); } break; } if (!string.IsNullOrEmpty(refTableId)) { var files = HttpContext.Current.Request.Files; 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.FirstOrDefault(i => i.RefTableID == refTableId && i.RefTableName == refTableName && i.TypeCode == typeCode); if (att != null) { 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); } else { 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.TypeCode = typeCode; Attachment.Add(att); } } tranScope.Complete(); return(Ok()); } }
public IHttpActionResult GetAttachments(Guid Id, string flowCode) { var refTableId = string.Empty; var refTableName = string.Empty; var projectInfo = ProjectInfo.Get(Id); if (projectInfo != null) { switch (flowCode) { case FlowCode.Closure: refTableName = "ClosureInfo"; var closureInfo = ClosureInfo.GetByProjectId(projectInfo.ProjectId); if (closureInfo != null) { refTableId = closureInfo.Id.ToString(); } break; case FlowCode.Rebuild: refTableName = "RebuildInfo"; var rebuildInfo = RebuildInfo.FirstOrDefault(i => i.ProjectId == projectInfo.ProjectId); if (rebuildInfo != null) { refTableId = rebuildInfo.Id.ToString(); } break; case FlowCode.MajorLease: refTableName = "MajorLeaseInfo"; var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(i => i.ProjectId == projectInfo.ProjectId); if (majorLeaseInfo != null) { refTableId = majorLeaseInfo.Id.ToString(); } break; case FlowCode.Renewal: refTableName = "RenewalInfo"; var renewalInfo = RenewalInfo.Get(projectInfo.ProjectId); if (renewalInfo != null) { refTableId = renewalInfo.Id.ToString(); } break; case FlowCode.Reimage: refTableName = "ReimageInfo"; var reimageInfo = ReimageInfo.GetReimageInfo(projectInfo.ProjectId); if (reimageInfo != null) { refTableId = reimageInfo.Id.ToString(); } break; } if (!string.IsNullOrEmpty(refTableId)) { var list = Attachment.Search(i => i.RefTableName == refTableName && i.RefTableID == refTableId).ToList(); foreach (var item in list) { item.FileURL = SiteInfo.ServiceUrl + "api/attachment/download?id=" + item.ID; } return(Ok(list)); } } return(Ok()); }