public IHttpActionResult Edit(ClosureWOCheckList entity) { return(Ok(new { TaskUrl = entity.Edit() })); }
public IHttpActionResult GetById(string Id) { Guid _Id; if (!Guid.TryParse(Id, out _Id)) { return(Ok()); } var entity = ClosureWOCheckList.Get(_Id); if (entity != null) { ProjectCommentCondition condition = new ProjectCommentCondition(); condition.RefTableId = entity.Id; condition.RefTableName = ClosureWOCheckList.TableName; condition.UserAccount = ClientCookie.UserCode; condition.Status = ProjectCommentStatus.Save; var commentList = ProjectComment.SearchList(condition); if (commentList != null && commentList.Count > 0) { entity.Comments = commentList[0].Content; } var closureEntity = ClosureInfo.GetByProjectId(entity.ProjectId); entity.USCode = closureEntity.USCode; entity.UserAccount = ClientCookie.UserCode; } return(Ok(entity)); }
private void SetStatus(ClosureWOCheckList entity, WOCheckListStatus status) { int statusVal = (int)status; if (entity.Status < statusVal) { entity.Status = statusVal; } }
public IHttpActionResult ProcessClosureWOCheckList(ClosureWOCheckList entity) { int procInstID = entity.ProcInstID.Value; string actionLower = entity.Action.ToLower(); string account = ClientCookie.UserCode; //评论信息 string comments = entity.Comments; // To-Do K2 action ProcessActionResult _action = BPMHelper.ConvertToProcAction(actionLower); if (actionLower.Equals(ProjectAction.Return, StringComparison.CurrentCultureIgnoreCase)) { TaskWork.Finish(e => e.RefID == entity.ProjectId && e.TypeCode == FlowCode.Closure_WOCheckList && e.Status == TaskWorkStatus.UnFinish && e.K2SN != entity.SN); } if (actionLower == "resubmit") { List <ProcessDataField> _listDataFields = new List <ProcessDataField>(); _listDataFields.Add(new ProcessDataField("dest_PMSupervisor", entity.PMSupervisorAccount)); // 工程PM直属上级 _listDataFields.Add(new ProcessDataField("dest_MCCLApprovers", string.Join(";", entity.MCCLApproverAccount, entity.MCCLITApproverAccount, entity.MCCLMCCLEqApproverAccount))); // MCCL Approvers K2FxContext.Current.ApprovalProcess(entity.SN, account, _action.ToString(), comments, _listDataFields); entity.Save(); _db.Entry(entity).State = EntityState.Modified; _db.SaveChanges(); } else { K2FxContext.Current.ApprovalProcess(entity.SN, account, _action.ToString(), comments); } if (actionLower == "submit") { } else if (actionLower == "resubmit") { ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_ClosingCost); } //ProjectInfo.UpdateProjectStatus(entity.ProjectId, FlowCode.Closure_WOCheckList, entity.GetProjectStatus(entity.Action)); SaveCommers(entity, _action.ToString(), ProjectCommentStatus.Submit); return(Ok(entity.Status)); }
public IHttpActionResult GetOnline(string projectID) { var closure = ClosureInfo.GetByProjectId(projectID); var store = StoreBasicInfo.GetStore(closure.USCode); var toolEntity = ClosureTool.Get(closure.ProjectId); var woEntity = ClosureWOCheckList.Get(closure.ProjectId); List <StoreBEInfo> remoteBeList = new List <StoreBEInfo>(); List <StoreBEInfo> attachedBeList = new List <StoreBEInfo>(); StoreBEInfo mds = null; StoreBEInfo mcCafe = null; StoreBEInfo hour24 = null; if (store.StoreBEInfoList.Count > 0) { foreach (var beInfo in store.StoreBEInfoList) { switch (beInfo.BETypeName) { case "Remote Kiosk": remoteBeList.Add(beInfo); break; case "Attach Kiosk": attachedBeList.Add(beInfo); break; case "MDS": mds = beInfo; break; case "McCafe": mcCafe = beInfo; break; case "24 Hour": hour24 = beInfo; break; } } } return(Ok(new { Store = store, ClosureTool = toolEntity, WOCheckList = woEntity, RemoteBeList = remoteBeList, AttachedBeList = attachedBeList, MDS = mds, McCafe = mcCafe, Hour24 = hour24 })); }
public IHttpActionResult UploadClosingCost(string projectid) { HttpRequest request = System.Web.HttpContext.Current.Request; HttpFileCollection FileCollect = request.Files; int result = 0; string resultStr = string.Empty; string internalName = string.Empty; if (FileCollect.Count > 0) //如果集合的数量大于0 { var woEntity = ClosureWOCheckList.Get(projectid); //用key获取单个文件对象HttpPostedFile HttpPostedFile fileSave = FileCollect[0]; string fileExtension = Path.GetExtension(fileSave.FileName); string fileName = "ClosingCost" + fileExtension; var current = System.Web.HttpContext.Current; internalName = Guid.NewGuid() + fileExtension; string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName; fileSave.SaveAs(absolutePath); Attachment att = new Attachment(); att.InternalName = internalName; att.RefTableName = ClosureWOCheckList.TableName; att.RefTableID = woEntity.Id.ToString(); att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; att.CreateTime = DateTime.Now; att.TypeCode = "ClosingCost"; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorID = ClientCookie.UserCode; Attachment.SaveSigleFile(att); var currentNode = NodeInfo.GetCurrentNode(projectid, FlowCode.Closure_WOCheckList); var newNode = NodeInfo.GetNodeInfo(NodeCode.Closure_WOCheckList_ClosingCost); if (newNode.Sequence > currentNode.Sequence) { ProjectInfo.FinishNode(projectid, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_ClosingCost); } } return(Ok(NodeCode.Closure_WOCheckList_Approve)); }
public ClosureWOCheckListExcelData(FileInfo fileInfo) : base(fileInfo) { SheetName = "PMT"; StartRow = 2; EndRow = 43; StartColumn = "D"; EndColumn = "E"; _outputCol = "E"; _closureWOCheckList = new ClosureWOCheckList(); Entity = _closureWOCheckList; }
public IHttpActionResult UploadAttachement(string id) { HttpRequest request = System.Web.HttpContext.Current.Request; HttpFileCollection FileCollect = request.Files; int result = 0; string resultStr = string.Empty; string internalName = string.Empty; if (FileCollect.Count > 0) //如果集合的数量大于0 { var woEntity = ClosureWOCheckList.Get(id); for (int i = 0; i < FileCollect.Count; i++) { var fileSave = FileCollect[i]; //用key获取单个文件对象HttpPostedFile string fileName = Path.GetFileName(fileSave.FileName); string fileExtension = Path.GetExtension(fileSave.FileName); var current = System.Web.HttpContext.Current; internalName = Guid.NewGuid() + fileExtension; string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName; fileSave.SaveAs(absolutePath); Attachment att = new Attachment(); att.InternalName = internalName; att.RefTableName = ClosureWOCheckList.TableName; att.RefTableID = woEntity.Id.ToString(); att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; att.CreateTime = DateTime.Now; att.ID = Guid.NewGuid(); att.TypeCode = "Attachment"; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorID = ClientCookie.UserCode; _db.Attachment.Add(att); result = _db.SaveChanges(); } resultStr = SiteInfo.WebUrl + "UploadFiles/" + internalName; } return(Ok(resultStr)); }
private string GetCommers(ClosureWOCheckList entity) { string commers = string.Empty; if (entity.Id != new Guid() && !string.IsNullOrEmpty(ClientCookie.UserCode)) { var list = _db.ProjectComment.Where( c => c.CreateUserAccount == ClientCookie.UserCode && c.RefTableId == entity.Id && c.Action == "Submit" && c.RefTableName == ClosureWOCheckList.TableName && c.TitleCode == ClientCookie.TitleENUS && c.SourceCode == "Closure").ToList(); if (list.Count > 0) { commers = list[0].Content; } } return(commers); }
public IHttpActionResult SaveClosureWOCheckList(ClosureWOCheckList entity) { if (entity.Id == Guid.Empty) { entity.Id = Guid.NewGuid(); entity.CreateTime = DateTime.Now; entity.CreateUserAccount = ClientCookie.UserCode; } entity.Save(); string action = string.IsNullOrEmpty(entity.Action) ? ProjectCommentAction.Submit : entity.Action; SaveCommers(entity, action, ProjectCommentStatus.Save); int result = _db.SaveChanges(); return(Ok(result)); }
private void SaveCommers(ClosureWOCheckList entity, string action, ProjectCommentStatus status) { if (status == ProjectCommentStatus.Save) { var list = _db.ProjectComment.Where(c => c.CreateUserAccount == ClientCookie.UserCode && c.RefTableId == entity.Id && c.Status == ProjectCommentStatus.Save && c.RefTableName == ClosureWOCheckList.TableName && c.SourceCode == FlowCode.Closure).ToList(); if (list.Count > 0) { ProjectComment closureCommens = list[0]; if (!string.IsNullOrEmpty(entity.Comments)) { closureCommens.Content = entity.Comments.Trim(); } _db.ProjectComment.Attach(closureCommens); _db.Entry(closureCommens).State = EntityState.Modified; } else { AddProjectComment(entity, action, status); } } else { var list = _db.ProjectComment.Where(c => c.CreateUserAccount == ClientCookie.UserCode && c.RefTableId == entity.Id && c.Status == ProjectCommentStatus.Save && c.RefTableName == ClosureWOCheckList.TableName && c.SourceCode == FlowCode.Closure).ToList(); if (list.Count > 0) { ProjectComment closureCommens = list[0]; if (!string.IsNullOrEmpty(entity.Comments)) { closureCommens.Content = entity.Comments.Trim(); } closureCommens.Status = ProjectCommentStatus.Submit; _db.ProjectComment.Attach(closureCommens); _db.Entry(closureCommens).State = EntityState.Modified; } else { AddProjectComment(entity, action, status); } } _db.SaveChanges(); }
public IHttpActionResult GetHistoryTemplates(Guid entityId) { Attachment att = new Attachment(); var entity = ClosureWOCheckList.Get(entityId); List <Attachment> list = null; if (entity != null) { list = Attachment.GetList(ClosureWOCheckList.TableName, entity.Id.ToString(), "Template"); foreach (var item in list) { //item.FileURL = SiteFilePath.UploadFiles_URL + item.InternalName; item.FileURL = SiteInfo.ServiceUrl + "api/attachment/download?id=" + item.ID; } } return(Ok(list)); }
public IHttpActionResult Finnish(ClosureWOCheckList entity) { entity.ProgressRate = 100; entity.Status = (int)WOCheckListStatus.Finish; var task = _db.TaskWork.First( e => e.ReceiverAccount == ClientCookie.UserCode && e.Status == 0 && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_WOCheckList && e.RefID == entity.ProjectId ); task.Status = TaskWorkStatus.Finished; task.FinishTime = DateTime.Now; task.Url = SiteInfo.GetProjectViewPageUrl(FlowCode.Closure_WOCheckList, task.RefID); _db.TaskWork.Attach(task); _db.ClosureWOCheckList.Attach(entity); var result = _db.SaveChanges(); return(Ok(result)); }
private int ModifyProject(ClosureWOCheckList entity, string action) { // 2014-08-05 victor.huang: Recall 或Edit 后不需要重新再生成Task,不然会多生成一条冗余记录 //TaskWorkCondition condition = new TaskWorkCondition(); //condition.ProjectId = entity.ProjectId; //condition.Url = "/closure/Main#/closure/WOCheckList/" + entity.ProjectId; //condition.UserAccount = ClientCookie.UserCode; //condition.UserNameENUS = entity.UserNameENUS; //condition.UserNameZHCN = entity.UserNameZHCN; //taskWorkBll.ReSendTaskWork(condition); ProjectInfo.Reset(entity.ProjectId, FlowCode.Closure_WOCheckList); var result = 0; result = _db.SaveChanges(); return(result); }
public IHttpActionResult GetByProjectId(string projectId) { var entity = ClosureWOCheckList.Get(projectId); if (entity != null) { ProjectCommentCondition condition = new ProjectCommentCondition(); condition.RefTableId = entity.Id; condition.RefTableName = ClosureWOCheckList.TableName; condition.UserAccount = ClientCookie.UserCode; condition.Status = ProjectCommentStatus.Save; var commentList = ProjectComment.SearchList(condition); if (commentList != null && commentList.Count > 0) { entity.Comments = commentList[0].Content; } var closureEntity = ClosureInfo.GetByProjectId(entity.ProjectId); entity.USCode = closureEntity.USCode; entity.UserAccount = ClientCookie.UserCode; if (string.IsNullOrEmpty(entity.PMSupervisorAccount)) { var puser = ProjectUsers.FirstOrDefault(i => i.ProjectId == entity.ProjectId && i.RoleCode == ProjectUserRoleCode.CM); if (puser != null) { entity.PMSupervisorAccount = puser.UserAccount; } } // entity.Comments = GetCommers(entity); //string pmAccount = closureEntity.PMAccount; //entity.PMSupervisorAccount = userPositionHandler.GetReportToAccounts(pmAccount); //string[] accounts = {UserPositionHandler.IT,UserPositionHandler.MCCL_Construction_Mgr}; //var positionlist = userPositionHandler.SearchUserPosition(closureEntity.USCode,accounts); //string mcclApprover = userPositionHandler.GetAccounts(positionlist); //entity.MCCLApproverAccount = mcclApprover; } return(Ok(entity)); }
public override void Import() { var woCheckList = ClosureWOCheckList.FirstOrDefault(e => e.Id.ToString().Equals(_closureWOCheckList.Id.ToString())); if (woCheckList != null) { woCheckList.RE_Original = _closureWOCheckList.RE_Original; woCheckList.LHI_Original = _closureWOCheckList.LHI_Original; woCheckList.ESSD_Original = _closureWOCheckList.ESSD_Original; woCheckList.Equipment_Original = _closureWOCheckList.Equipment_Original; woCheckList.Signage_Original = _closureWOCheckList.Signage_Original; woCheckList.Seating_Original = _closureWOCheckList.Seating_Original; woCheckList.Decoration_Original = _closureWOCheckList.Decoration_Original; woCheckList.RE_NBV = _closureWOCheckList.RE_NBV; woCheckList.LHI_NBV = _closureWOCheckList.LHI_NBV; woCheckList.ESSD_NBV = _closureWOCheckList.ESSD_NBV; woCheckList.Equipment_NBV = _closureWOCheckList.Equipment_NBV; woCheckList.Signage_NBV = _closureWOCheckList.Signage_NBV; woCheckList.Seating_NBV = _closureWOCheckList.Seating_NBV; woCheckList.Decoration_NBV = _closureWOCheckList.Decoration_NBV; woCheckList.EquipmentTransfer = _closureWOCheckList.EquipmentTransfer; woCheckList.TotalCost_Original = _closureWOCheckList.TotalCost_Original; woCheckList.TotalCost_NBV = _closureWOCheckList.TotalCost_NBV; woCheckList.TotalCost_WriteOFF = _closureWOCheckList.TotalCost_WriteOFF; woCheckList.RECost_WriteOFF = _closureWOCheckList.RECost_WriteOFF; woCheckList.LHI_WriteOFF = _closureWOCheckList.LHI_WriteOFF; woCheckList.ESSD_WriteOFF = _closureWOCheckList.ESSD_WriteOFF; woCheckList.Equipment_WriteOFF = _closureWOCheckList.Equipment_WriteOFF; woCheckList.Signage_WriteOFF = _closureWOCheckList.Signage_WriteOFF; woCheckList.Seating_WriteOFF = _closureWOCheckList.Seating_WriteOFF; woCheckList.Decoration_WriteOFF = _closureWOCheckList.Decoration_WriteOFF; woCheckList.ClosingCost = _closureWOCheckList.ClosingCost; ClosureWOCheckList.Update(woCheckList); } else { ClosureWOCheckList.Add(_closureWOCheckList); } }
public IHttpActionResult Recall(ClosureWOCheckList entity) { // bool _recallSuccess = false; if (entity.ProcInstID != null) { _recallSuccess = K2FxContext.Current.GoToActivityAndRecord(entity.ProcInstID.Value, WFClosureWOCheckList.Act_Originator, ClientCookie.UserCode, ProjectAction.Recall, entity.Comments); if (_recallSuccess) { SaveCommers(entity, ProjectCommentAction.Recall, ProjectCommentStatus.Submit); } } if (!_recallSuccess) { throw new Exception("Recall失败"); } //ProjectInfo.Reset(entity.ProjectId, FlowCode.Closure_WOCheckList, ProjectStatus.Recalled); ProjectInfo.UpdateProjectStatus(entity.ProjectId, FlowCode.Closure_WOCheckList, ProjectStatus.Recalled); return(Ok()); }
private void AddProjectComment(ClosureWOCheckList entity, string action, ProjectCommentStatus status) { ProjectComment closureCommens = new ProjectComment(); closureCommens.RefTableId = entity.Id; closureCommens.RefTableName = ClosureWOCheckList.TableName; closureCommens.TitleNameENUS = ClientCookie.TitleENUS; closureCommens.TitleNameZHCN = ClientCookie.TitleENUS; closureCommens.TitleCode = ClientCookie.TitleENUS; closureCommens.CreateTime = DateTime.Now; closureCommens.CreateUserAccount = ClientCookie.UserCode; closureCommens.UserAccount = ClientCookie.UserCode; closureCommens.UserNameENUS = ClientCookie.UserNameENUS; closureCommens.UserNameZHCN = ClientCookie.UserNameZHCN; closureCommens.CreateUserNameZHCN = entity.UserNameZHCN; closureCommens.Id = Guid.NewGuid(); if (!string.IsNullOrEmpty(entity.Comments)) { closureCommens.Content = entity.Comments.Trim(); } closureCommens.Action = action; closureCommens.Status = status; if (entity.ProcInstID > 0) { closureCommens.ProcInstID = entity.ProcInstID; } closureCommens.SourceCode = FlowCode.Closure; closureCommens.SourceNameENUS = FlowCode.Closure; closureCommens.SourceNameZHCN = "关店流程"; closureCommens.Add(); }
public IHttpActionResult DownLoadTemplate(string projectId) { var current = System.Web.HttpContext.Current; //string path = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.FAWrite_offTool_Template; //Excel excel = new Excel(); //string templatePath = path; //string tempFilePath = current.Server.MapPath("~/") + "Temp\\" + Guid.NewGuid() + ".xls"; //var closure = ClosureInfo.GetByProjectId(projectId); //excel.Open(path); //excel.Save(tempFilePath); //var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == closure.USCode); //Excel tempExcel = new Excel(); //tempExcel.Open(tempFilePath); //var sheet = tempExcel.Sheets["PMT"]; //sheet.Cells[1, 1].StrValue = store.RegionENUS; //sheet.Cells[2, 1].StrValue = store.MarketENUS; //sheet.Cells[3, 1].StrValue = store.NameZHCN; //sheet.Cells[4, 1].StrValue = closure.USCode; //sheet.Cells[5, 1].StrValue = store.StoreTypeName; //if (closure.ActualCloseDate != null) //{ // sheet.Cells[6, 1].StrValue = closure.ActualCloseDate.Value.ToString("yyyy-MM-dd"); //} //sheet.Cells[7, 1].StrValue = "";//TODO::-Cary GetPM //sheet.Cells[0, 7].StrValue = ConsInvtCheckingVersion; //tempExcel.Save(tempFilePath); //直接下载writeoff文件 McdAMEntities _db = new McdAMEntities(); var closureInfo = ClosureInfo.GetByProjectId(projectId); var wo = ClosureWOCheckList.Get(projectId); if (wo != null) { var att = _db.Attachment.FirstOrDefault(a => a.RefTableID == wo.Id.ToString() && a.TypeCode == "Template"); string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + att.InternalName; string tempFilePath = current.Server.MapPath("~/") + "Temp\\" + Guid.NewGuid() + Path.GetExtension(absolutePath); File.Copy(absolutePath, tempFilePath); ExcelHelper.UpdateExcelVersionNumber(tempFilePath, ConsInvtCheckingVersion); var currentNode = NodeInfo.GetCurrentNode(projectId, FlowCode.Closure_ConsInvtChecking); var newNode = NodeInfo.GetNodeInfo(NodeCode.Closure_ConsInvtChecking_DownLoadTemplate); if (newNode.Sequence > currentNode.Sequence) { ProjectInfo.FinishNode(projectId, FlowCode.Closure_ConsInvtChecking, NodeCode.Closure_ConsInvtChecking_DownLoadTemplate); } current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + SiteFilePath.GetTemplateFileName(closureInfo.USCode, FlowCode.Closure_ConsInvtChecking, SiteFilePath.FAWrite_offTool_Template)); current.Response.ContentType = "application/octet-stream"; current.Response.WriteFile("" + tempFilePath + ""); current.Response.End(); } else { string path = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.FAWrite_offTool_Template; current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + SiteFilePath.GetTemplateFileName(closureInfo.USCode, FlowCode.Closure_ConsInvtChecking, SiteFilePath.FAWrite_offTool_Template)); current.Response.ContentType = "application/octet-stream"; current.Response.WriteFile("" + path + ""); current.Response.End(); } return(Ok()); }
public IHttpActionResult UploadTemplate(string projectid) { HttpRequest request = System.Web.HttpContext.Current.Request; HttpFileCollection FileCollect = request.Files; string internalName = string.Empty; if (FileCollect.Count > 0) //如果集合的数量大于0 { ClosureWOCheckList entity = new ClosureWOCheckList(); //用key获取单个文件对象HttpPostedFile HttpPostedFile fileSave = FileCollect[0]; string fileName = Path.GetFileName(fileSave.FileName); string fileExtension = Path.GetExtension(fileSave.FileName); internalName = Guid.NewGuid() + fileExtension; string absolutePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalName; //通过此对象获取文件名 fileSave.SaveAs(absolutePath); var woEntity = ClosureExecutiveSummary.FirstOrDefault(e => e.ProjectId == projectid && e.IsHistory == false); if (woEntity == null) { woEntity = new ClosureExecutiveSummary(); woEntity.ProjectId = projectid; woEntity.Id = Guid.NewGuid(); woEntity.CreateTime = DateTime.Now; woEntity.CreatorAccount = ClientCookie.UserCode; ClosureExecutiveSummary.Add(woEntity); } Attachment att = Attachment.GetAttachment("ClosureExecutiveSummary", woEntity.Id.ToString(), "Template"); if (att == null) { att = new Attachment(); att.RefTableName = "ClosureExecutiveSummary"; att.RefTableID = woEntity.Id.ToString(); att.CreateTime = DateTime.Now; att.ID = Guid.NewGuid(); att.TypeCode = "Template"; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = fileName; att.InternalName = internalName; att.Name = fileName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; Attachment.Add(att); } else { att.CreateTime = DateTime.Now; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = fileName; att.InternalName = internalName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; Attachment.Update(att); } //var closureInfo = closureHandler.GetByProjectId(projectid); //Store store = new Store(); //var storeInfo = store.GetStoreEntity(closureInfo.USCode); //string filePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalName; //Excel excel = new Excel(); //excel.Open(filePath); //var sheet = excel.Sheets["PMT"]; //sheet.Cells[1, 1].StrValue = closureInfo.StoreNameZHCN; //sheet.Cells[2, 1].StrValue = closureInfo.USCode; //if (storeInfo != null) //{ // sheet.Cells[3, 1].StrValue = storeInfo.CityName; // sheet.Cells[4, 1].StrValue = storeInfo.MarketName; // if (storeInfo.OpenDate != null) // { // sheet.Cells[5, 1].StrValue = storeInfo.OpenDate.Value.ToString("yyyy-MM-dd"); // } // sheet.Cells[7, 1].StrValue = storeInfo.TotalLeasedArea; // sheet.Cells[8, 1].StrValue = storeInfo.TotalSeatsNo; // sheet.Cells[10, 1].StrValue = storeInfo.LeasePurchaseTerm; // if (storeInfo.RentCommencementDate != null) // { // sheet.Cells[11, 1].StrValue = storeInfo.RentCommencementDate.Value.ToString("yyyy-MM-dd"); // } // if (storeInfo.EndDate != null) // { // sheet.Cells[12, 1].StrValue = storeInfo.EndDate.Value.ToString("yyyy-MM-dd"); // } // sheet.Cells[13, 1].StrValue = storeInfo.RentType; // sheet.Cells[13, 1].StrValue = storeInfo.RentStructure; //} //excel.Save(); } //return Ok(result); ProjectInfo.FinishNode(projectid, FlowCode.Closure_ExecutiveSummary, NodeCode.Finish); var resultStr = SiteInfo.WebUrl + "UploadFiles/" + internalName; return(Ok(resultStr)); }
public IHttpActionResult RecallProject(PostSimpleWorkflowData postData) { ApiProxy.SetCookies(Request.RequestUri.Host, HttpContext.Current.Request.Cookies); var rootPath = string.Concat(HttpContext.Current.Request.Url.Scheme, @"://", HttpContext.Current.Request.Url.Authority, HttpContext.Current.Request.ApplicationPath); switch (postData.FlowCode) { #region Closure case FlowCode.Closure_WOCheckList: { var entity = ClosureWOCheckList.Get(postData.ProjectId); entity.Comments = postData.ProjectComment; var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity)); ApiProxy.Call(rootPath + "api/ClosureWOCheckList/Recall", "POST", null, postDataBytes); } break; case FlowCode.Closure_LegalReview: { var entity = ClosureLegalReview.Get(postData.ProjectId); entity.Comments = postData.ProjectComment; var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity)); ApiProxy.Call(rootPath + "api/LegalReview/Recall", "POST", null, postDataBytes); } break; case FlowCode.Closure_ClosurePackage: { var entity = ClosurePackage.Get(postData.ProjectId); entity.Comments = postData.ProjectComment; var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity)); ApiProxy.Call(rootPath + "api/ClosurePackage/Recall", "POST", null, postDataBytes); } break; case FlowCode.Closure_ConsInvtChecking: { var entity = ClosureConsInvtChecking.Get(postData.ProjectId); entity.Comments = postData.ProjectComment; var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity)); ApiProxy.Call(rootPath + "api/ClosureConsInvtChecking/Recall", "POST", null, postDataBytes); } break; case FlowCode.Closure_ClosureTool: { var entity = ClosureTool.Get(postData.ProjectId); entity.Comments = postData.ProjectComment; var postDataBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(entity)); ApiProxy.Call(rootPath + "api/closureTool/Recall", "POST", null, postDataBytes); } break; #endregion Closure default: var wfEntity = BaseWFEntity.GetWorkflowEntity(postData.ProjectId, postData.FlowCode); wfEntity.Recall(postData.ProjectComment); break; } return(Ok()); }
public IHttpActionResult UploadTemplate(string projectid) { HttpRequest request = System.Web.HttpContext.Current.Request; HttpFileCollection FileCollect = request.Files; string resultStr = string.Empty; string internalName = string.Empty; ClosureConsInvtChecking woEntity = null; bool isNew = false; if (FileCollect.Count > 0) //如果集合的数量大于0 { //用key获取单个文件对象HttpPostedFile HttpPostedFile fileSave = FileCollect[0]; string fileName = Path.GetFileName(fileSave.FileName); string fileExtension = Path.GetExtension(fileSave.FileName); var current = System.Web.HttpContext.Current; internalName = Guid.NewGuid() + fileExtension; string filePath = current.Server.MapPath("~/") + "UploadFiles\\" + internalName; //通过此对象获取文件名 fileSave.SaveAs(filePath); string column = "E"; woEntity = ClosureConsInvtChecking.Get(projectid); var fileInfo = new FileInfo(filePath); //验证上传EXCEL版本 var vn = ExcelHelper.GetExcelVersionNumber(filePath); if (vn != ConsInvtCheckingVersion) { PluploadHandler.WriteErrorMsg("上传附件版本号不一致"); } var importDirector = new ExcelDataImportDirector(fileInfo, ExcelDataImportType.ClosureWOCheckList); if (woEntity == null) { isNew = true; woEntity = new ClosureConsInvtChecking(); woEntity.ProjectId = projectid; woEntity.Id = Guid.NewGuid(); woEntity.CreateTime = DateTime.Now; woEntity.CreateUserAccount = ClientCookie.UserCode; woEntity.IsHistory = false; } woEntity.TotalOriginalBudget = GetDecimalValue(importDirector, 16, column); woEntity.TotalNBVBudget = GetDecimalValue(importDirector, 17, column); woEntity.TotalWriteoffBudget = GetDecimalValue(importDirector, 18, column); var woCheckList = ClosureWOCheckList.Get(projectid); if (woCheckList != null) { if (!EqualValue(woCheckList.TotalCost_Original, woEntity.TotalOriginalBudget)) { PluploadHandler.WriteErrorMsg("Total Budget 数据验证不通过,请检查后重试!"); } if (!EqualValue(woCheckList.TotalCost_NBV, woEntity.TotalNBVBudget)) { PluploadHandler.WriteErrorMsg("Total NBV(Closure Data) 数据验证不通过,请检查后重试!"); } if (!EqualValue(woCheckList.TotalCost_WriteOFF, woEntity.TotalWriteoffBudget)) { PluploadHandler.WriteErrorMsg("Total Write off 数据验证不通过,请检查后重试!"); } } woEntity.RECostBudget = GetDecimalValue(importDirector, 19, column); woEntity.LHIBudget = GetDecimalValue(importDirector, 20, column); woEntity.ESSDBudget = GetDecimalValue(importDirector, 21, column); woEntity.EquipmentBudget = GetDecimalValue(importDirector, 22, column); woEntity.SignageBudget = GetDecimalValue(importDirector, 23, column); woEntity.SeatingBudget = GetDecimalValue(importDirector, 24, column); woEntity.DecorationBudget = GetDecimalValue(importDirector, 25, column); woEntity.ClosingCostBudegt = GetDecimalValue(importDirector, 26, column); woEntity.ClosingCostActual = GetDecimalValue(importDirector, 27, column); woEntity.TotalActual = GetDecimalValue(importDirector, 28, column); woEntity.RECostActual = GetDecimalValue(importDirector, 29, column); woEntity.LHIActual = GetDecimalValue(importDirector, 30, column); woEntity.EquipmentActual = GetDecimalValue(importDirector, 31, column); woEntity.SignageActual = GetDecimalValue(importDirector, 32, column); woEntity.SeatingActual = GetDecimalValue(importDirector, 33, column); woEntity.DecorationActual = GetDecimalValue(importDirector, 34, column); woEntity.RECostVsBudget = GetDecimalValue(importDirector, 35, column); woEntity.LHIWOVsBudget = GetDecimalValue(importDirector, 36, column); woEntity.ESSDWOVsBudget = GetDecimalValue(importDirector, 37, column); woEntity.TTLWOVsBudget = GetDecimalValue(importDirector, 38, column); woEntity.REExplanation = GetStringValue(importDirector, 39, column); woEntity.LHIExplanation = GetStringValue(importDirector, 40, column); woEntity.ESSDExplanation = GetStringValue(importDirector, 41, column); woEntity.TotalExplanation = GetStringValue(importDirector, 42, column); Attachment att = Attachment.GetAttachment("ClosureConsInvtChecking", woEntity.Id.ToString(), "Template"); if (att == null) { att = new Attachment(); att.ID = Guid.NewGuid(); att.TypeCode = "Template"; att.RefTableName = ClosureConsInvtChecking.TableName; att.RefTableID = woEntity.Id.ToString(); att.RelativePath = "//"; } att.InternalName = internalName; att.Name = fileName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; att.CreateTime = DateTime.Now; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; Attachment.SaveSigleFile(att); var currentNode = NodeInfo.GetCurrentNode(projectid, FlowCode.Closure_ConsInvtChecking); var newNode = NodeInfo.GetNodeInfo(NodeCode.Closure_ConsInvtChecking_ResultUpload); if (newNode.Sequence > currentNode.Sequence) { ProjectInfo.FinishNode(projectid, FlowCode.Closure_ConsInvtChecking, NodeCode.Closure_ConsInvtChecking_DownLoadTemplate); ProjectInfo.FinishNode(projectid, FlowCode.Closure_ConsInvtChecking, NodeCode.Closure_ConsInvtChecking_WriteOffData); ProjectInfo.FinishNode(projectid, FlowCode.Closure_ConsInvtChecking, NodeCode.Closure_ConsInvtChecking_ResultUpload); } if (isNew) { ClosureConsInvtChecking.Add(woEntity); } else { ClosureConsInvtChecking.Update(woEntity); } } return(Ok(woEntity)); }
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); }
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); }
public IHttpActionResult DownLoadTemplate(string projectID) { var current = System.Web.HttpContext.Current; string path = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Executive_Summary_Template; string tempFilePath = current.Server.MapPath("~/") + "Temp\\" + Guid.NewGuid() + ".xlsx"; File.Copy(path, tempFilePath); var fileInfo = new FileInfo(tempFilePath); var excelDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.ClosureExecutiveSummary); var closure = ClosureInfo.GetByProjectId(projectID); var store = StoreBasicInfo.GetStore(closure.USCode); var inputInfo = new ExcelInputDTO { StoreNameCN = store.StoreBasicInfo.NameZHCN, USCode = store.StoreBasicInfo.StoreCode, City = store.StoreBasicInfo.CityENUS, Market = store.StoreBasicInfo.MarketENUS, OpenDate = store.StoreBasicInfo.OpenDate, Floor = store.StoreSTLocation.Floor, TotalArea = store.StoreSTLocation.TotalArea, TotalSeatsNo = store.StoreSTLocation.TotalSeatsNo, BE = store.StoreBEInfoList.Count, RentType = store.StoreContractInfo.RentType, RentStructure = store.StoreContractInfo.RentStructure }; var leaseRecapID = StoreContractInfo.SearchByProject(projectID).FirstOrDefault().LeaseRecapID ?? 0; var storeAtt = StoreContractInfoAttached.Search(c => c.LeaseRecapID == leaseRecapID.ToString()).OrderByDescending(e => e.CreateDate).FirstOrDefault(); if (storeAtt != null) { inputInfo.LeasingTerm = store.StoreContractInfo.LeasePurchaseTerm; } if (store.StoreContractInfo.RentCommencementDate.HasValue) { inputInfo.RentCommencementDate = store.StoreContractInfo.RentCommencementDate.Value; } if (store.StoreContractInfo.EndDate.HasValue) { inputInfo.LeaseExpirationDate = store.StoreContractInfo.EndDate.Value; } var toolEntity = ClosureTool.Get(closure.ProjectId); if (toolEntity != null) { if (toolEntity.TotalSales_Adjustment_RMB != null) { inputInfo.TotalSales_TTM = string.Format("{0:f}", toolEntity.TotalSales_Adjustment_RMB); } if (toolEntity.CompSales_Adjustment != null) { inputInfo.SalesComp_TTM = string.Format("{0:f}", toolEntity.CompSales_Adjustment); } if (toolEntity.CompCG_Adjustment != null) { inputInfo.GCComp_TTM = string.Format("{0:f}", toolEntity.CompCG_Adjustment); } if (toolEntity.PAC_RMB_Adjustment != null) { inputInfo.PAC_TTM = string.Format("{0:f}", toolEntity.PAC_RMB_Adjustment); } if (toolEntity.SOI_Adjustment != null) { inputInfo.SOI_TTM = string.Format("{0:f}", toolEntity.SOI_Adjustment); } if (toolEntity.CashFlow_RMB_Adjustment != null) { inputInfo.CASHFLOW_TTM = string.Format("{0:f}", toolEntity.CashFlow_RMB_Adjustment); } if (toolEntity.TotalSales_TTMY1 != null) { inputInfo.TotalSales_TTMY1 = string.Format("{0:f}", toolEntity.TotalSales_TTMY1); } if (toolEntity.CompSales_TTMY1 != null) { inputInfo.CompSales_TTMY1 = string.Format("{0:f}", toolEntity.CompSales_TTMY1); } if (toolEntity.CompGC_TTMY1 != null) { inputInfo.CompGC_TTMY1 = string.Format("{0:f}", toolEntity.CompGC_TTMY1); } if (toolEntity.PAC_TTMY1 != null) { inputInfo.PAC_TTMY1 = string.Format("{0:f}", toolEntity.PAC_TTMY1); } if (toolEntity.SOI_TTMY1 != null) { inputInfo.SOI_TTMY1 = string.Format("{0:f}", toolEntity.SOI_TTMY1); } if (toolEntity.CashFlow_TTMY1 != null) { inputInfo.CashFlow_TTMY1 = string.Format("{0:f}", toolEntity.CashFlow_TTMY1); } if (toolEntity.TotalSales_TTMY2 != null) { inputInfo.TotalSales_TTMY2 = string.Format("{0:f}", toolEntity.TotalSales_TTMY2); } if (toolEntity.CompSales_TTMY2 != null) { inputInfo.CompSales_TTMY2 = string.Format("{0:f}", toolEntity.CompSales_TTMY2); } if (toolEntity.CompGC_TTMY2 != null) { inputInfo.CompGC_TTMY2 = string.Format("{0:f}", toolEntity.CompGC_TTMY2); } if (toolEntity.PAC_TTMY2 != null) { inputInfo.PAC_TTMY2 = string.Format("{0:f}", toolEntity.PAC_TTMY2); } if (toolEntity.SOI_TTMY2 != null) { inputInfo.SOI_TTMY2 = string.Format("{0:f}", toolEntity.SOI_TTMY2); } if (toolEntity.CashFlow_TTMY2 != null) { inputInfo.CashFlow_TTMY2 = string.Format("{0:f}", toolEntity.CashFlow_TTMY2); } List <StoreBEInfo> remoteBeList = new List <StoreBEInfo>(); List <StoreBEInfo> attachedBeList = new List <StoreBEInfo>(); StoreBEInfo mds = null; StoreBEInfo mcCafe = null; StoreBEInfo hour24 = null; if (store.StoreBEInfoList.Count > 0) { foreach (var beInfo in store.StoreBEInfoList) { switch (beInfo.BETypeName) { case "Remote Kiosk": remoteBeList.Add(beInfo); break; case "Attached Kiosk": attachedBeList.Add(beInfo); break; case "MDS": mds = beInfo; break; case "McCafe": mcCafe = beInfo; break; case "24 Hour": hour24 = beInfo; break; } } } if (remoteBeList.Count > 0) { inputInfo.RemoteKiosk1_Status = remoteBeList[0].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.RemoteKiosk1_OpenDate = remoteBeList[0].LaunchDate; if (remoteBeList.Count > 1) { inputInfo.RemoteKiosk2_Status = remoteBeList[1].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.RemoteKiosk2_OpenDate = remoteBeList[1].LaunchDate; if (remoteBeList.Count > 2) { inputInfo.RemoteKiosk3_Status = remoteBeList[2].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.RemoteKiosk3_OpenDate = remoteBeList[2].LaunchDate; } } } if (attachedBeList.Count > 0) { inputInfo.AttachedKiosk1_Status = attachedBeList[0].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.AttachedKiosk1_OpenDate = attachedBeList[0].LaunchDate; if (attachedBeList.Count > 1) { inputInfo.AttachedKiosk2_Status = attachedBeList[1].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.AttachedKiosk2_OpenDate = attachedBeList[1].LaunchDate; if (attachedBeList.Count > 2) { inputInfo.AttachedKiosk3_Status = attachedBeList[2].IsSingleContract == 1 ? "Yes" : "No"; inputInfo.AttachedKiosk3_OpenDate = attachedBeList[2].LaunchDate; } } } if (mds != null) { inputInfo.MDS_Status = mds.IsSingleContract == 1 ? "Yes" : "No"; inputInfo.MDS_OpenDate = mds.LaunchDate; } if (mcCafe != null) { inputInfo.McCafe_Status = mcCafe.IsSingleContract == 1 ? "Yes" : "No"; inputInfo.McCafe_OpenDate = mcCafe.LaunchDate; } if (hour24 != null) { inputInfo.TwentyFourHour_Status = hour24.IsSingleContract == 1 ? "Yes" : "No"; inputInfo.TwentyFourHour_OpenDate = hour24.LaunchDate; } var woEntity = ClosureWOCheckList.Get(closure.ProjectId); if (woEntity != null) { if (woEntity.LHI_NBV != null) { inputInfo.LHI_NBV = string.Format("{0:f}", woEntity.LHI_NBV); } if (woEntity.ESSD_NBV != null) { inputInfo.ESSD_NBV = string.Format("{0:f}", woEntity.ESSD_NBV); } if (woEntity.TotalCost_NBV != null) { inputInfo.TotalCost_NBV = string.Format("{0:f}", woEntity.TotalCost_NBV); } } } excelDirector.Input(inputInfo); current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + DataConverter.ToHexString(SiteFilePath.Executive_Summary_Template)); current.Response.ContentType = "application/octet-stream"; current.Response.WriteFile("" + tempFilePath + ""); current.Response.End(); return(Ok()); }
public IHttpActionResult GenExecutiveSummaty(ClosureExecutiveSummary entity) { if (!ClosureExecutiveSummary.Any(i => i.ProjectId == entity.ProjectId && i.IsHistory == false)) { if (entity.Id == Guid.Empty || entity.Id == null) { entity.Id = Guid.NewGuid(); } entity.CreateTime = DateTime.Now; entity.CreatorAccount = ClientCookie.UserCode; ClosureExecutiveSummary.Add(entity); } else { ClosureExecutiveSummary.Update(entity); } var current = System.Web.HttpContext.Current; string path = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Executive_Summary_Template; string internalFileName = Guid.NewGuid() + ".xlsx"; string filePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalFileName; File.Copy(path, filePath); var fileInfo = new FileInfo(filePath); var excelPMTDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.ClosureExecutiveSummary); var closure = ClosureInfo.GetByProjectId(entity.ProjectId); var store = StoreBasicInfo.GetStore(closure.USCode); var inputInfo = new ExcelInputDTO { StoreNameCN = store.StoreBasicInfo.NameZHCN, USCode = store.StoreBasicInfo.StoreCode, City = store.StoreBasicInfo.CityENUS, Market = store.StoreBasicInfo.MarketENUS, OpenDate = store.StoreBasicInfo.OpenDate, Floor = store.StoreSTLocation.Floor, TotalArea = store.StoreSTLocation.TotalArea, TotalSeatsNo = store.StoreSTLocation.TotalSeatsNo, BE = store.StoreBEInfoList.Count, RentType = store.StoreContractInfo.RentType, RentStructure = store.StoreContractInfo.RentStructure, MiniMarket = entity.MiniMarket, StoreLocation = entity.StoreLocation, CurrentSituation = entity.CurrentSituation, NegotiationHistory = entity.NegotiationHistory, ProposedSolution = entity.ProposedSolution, SalesTransfer = entity.SalesTransfer }; var leaseRecapID = StoreContractInfo.SearchByProject(entity.ProjectId).FirstOrDefault().LeaseRecapID ?? 0; var storeAtt = StoreContractInfoAttached.Search(c => c.LeaseRecapID == leaseRecapID.ToString()).OrderByDescending(e => e.CreateDate).FirstOrDefault(); if (storeAtt != null) { inputInfo.LeasingTerm = store.StoreContractInfo.LeasePurchaseTerm; } if (store.StoreContractInfo.RentCommencementDate.HasValue) { inputInfo.RentCommencementDate = store.StoreContractInfo.RentCommencementDate.Value; } if (store.StoreContractInfo.EndDate.HasValue) { inputInfo.LeaseExpirationDate = store.StoreContractInfo.EndDate.Value; } var toolEntity = ClosureTool.Get(closure.ProjectId); if (toolEntity != null) { if (toolEntity.TotalSales_Adjustment_RMB != null) { inputInfo.TotalSales_TTM = string.Format("{0:f}", toolEntity.TotalSales_Adjustment_RMB); } if (toolEntity.CompSales_Adjustment != null) { inputInfo.SalesComp_TTM = string.Format("{0:f}", toolEntity.CompSales_Adjustment); } if (toolEntity.CompCG_Adjustment != null) { inputInfo.GCComp_TTM = string.Format("{0:f}", toolEntity.CompCG_Adjustment); } if (toolEntity.PAC_Adjustment != null) { inputInfo.PAC_TTM = string.Format("{0:f}", toolEntity.PAC_Adjustment); } if (toolEntity.SOI_Adjustment != null) { inputInfo.SOI_TTM = string.Format("{0:f}", toolEntity.SOI_Adjustment); } if (toolEntity.CashFlow_RMB_Adjustment != null) { inputInfo.CASHFLOW_TTM = string.Format("{0:f}", toolEntity.CashFlow_RMB_Adjustment); } if (toolEntity.TotalSales_TTMY1 != null) { inputInfo.TotalSales_TTMY1 = string.Format("{0:f}", toolEntity.TotalSales_TTMY1); } if (toolEntity.CompSales_TTMY1 != null) { inputInfo.CompSales_TTMY1 = string.Format("{0:f}", toolEntity.CompSales_TTMY1); } if (toolEntity.CompGC_TTMY1 != null) { inputInfo.CompGC_TTMY1 = string.Format("{0:f}", toolEntity.CompGC_TTMY1); } if (toolEntity.PAC_TTMY1 != null) { inputInfo.PAC_TTMY1 = string.Format("{0:f}", toolEntity.PAC_TTMY1); } if (toolEntity.SOI_TTMY1 != null) { inputInfo.SOI_TTMY1 = string.Format("{0:f}", toolEntity.SOI_TTMY1); } if (toolEntity.CashFlow_TTMY1 != null) { inputInfo.CashFlow_TTMY1 = string.Format("{0:f}", toolEntity.CashFlow_TTMY1); } if (toolEntity.TotalSales_TTMY2 != null) { inputInfo.TotalSales_TTMY2 = string.Format("{0:f}", toolEntity.TotalSales_TTMY2); } if (toolEntity.CompSales_TTMY2 != null) { inputInfo.CompSales_TTMY2 = string.Format("{0:f}", toolEntity.CompSales_TTMY2); } if (toolEntity.CompGC_TTMY2 != null) { inputInfo.CompGC_TTMY2 = string.Format("{0:f}", toolEntity.CompGC_TTMY2); } if (toolEntity.PAC_TTMY2 != null) { inputInfo.PAC_TTMY2 = string.Format("{0:f}", toolEntity.PAC_TTMY2); } if (toolEntity.SOI_TTMY2 != null) { inputInfo.SOI_TTMY2 = string.Format("{0:f}", toolEntity.SOI_TTMY2); } if (toolEntity.CashFlow_TTMY2 != null) { inputInfo.CashFlow_TTMY2 = string.Format("{0:f}", toolEntity.CashFlow_TTMY2); } List <StoreBEInfo> remoteBeList = new List <StoreBEInfo>(); List <StoreBEInfo> attachedBeList = new List <StoreBEInfo>(); StoreBEInfo mds = null; StoreBEInfo mcCafe = null; StoreBEInfo hour24 = null; if (store.StoreBEInfoList.Count > 0) { foreach (var beInfo in store.StoreBEInfoList) { switch (beInfo.BETypeName) { case "Remote Kiosk": remoteBeList.Add(beInfo); break; case "Attach Kiosk": attachedBeList.Add(beInfo); break; case "MDS": mds = beInfo; break; case "McCafe": mcCafe = beInfo; break; case "24 Hour": hour24 = beInfo; break; } } } inputInfo.RemoteKiosk1_Status = "No"; inputInfo.RemoteKiosk2_Status = "No"; inputInfo.RemoteKiosk3_Status = "No"; inputInfo.AttachedKiosk1_Status = "No"; inputInfo.AttachedKiosk2_Status = "No"; inputInfo.AttachedKiosk3_Status = "No"; inputInfo.MDS_Status = "No"; inputInfo.McCafe_Status = "No"; inputInfo.TwentyFourHour_Status = "No"; if (remoteBeList.Count > 0) { inputInfo.RemoteKiosk1_Status = "Yes"; inputInfo.RemoteKiosk1_OpenDate = remoteBeList[0].LaunchDate; if (remoteBeList.Count > 1) { inputInfo.RemoteKiosk2_Status = "Yes"; inputInfo.RemoteKiosk2_OpenDate = remoteBeList[1].LaunchDate; if (remoteBeList.Count > 2) { inputInfo.RemoteKiosk3_Status = "Yes"; inputInfo.RemoteKiosk3_OpenDate = remoteBeList[2].LaunchDate; } } } if (attachedBeList.Count > 0) { inputInfo.AttachedKiosk1_Status = "Yes"; inputInfo.AttachedKiosk1_OpenDate = attachedBeList[0].LaunchDate; if (attachedBeList.Count > 1) { inputInfo.AttachedKiosk2_Status = "Yes"; inputInfo.AttachedKiosk2_OpenDate = attachedBeList[1].LaunchDate; if (attachedBeList.Count > 2) { inputInfo.AttachedKiosk3_Status = "Yes"; inputInfo.AttachedKiosk3_OpenDate = attachedBeList[2].LaunchDate; } } } if (mds != null) { inputInfo.MDS_Status = "Yes"; inputInfo.MDS_OpenDate = mds.LaunchDate; } if (mcCafe != null) { inputInfo.McCafe_Status = "Yes"; inputInfo.McCafe_OpenDate = mcCafe.LaunchDate; } if (hour24 != null) { inputInfo.TwentyFourHour_Status = "Yes"; inputInfo.TwentyFourHour_OpenDate = hour24.LaunchDate; } var woEntity = ClosureWOCheckList.Get(closure.ProjectId); if (woEntity != null) { if (woEntity.LHI_NBV != null) { inputInfo.LHI_NBV = string.Format("{0:f}", woEntity.LHI_NBV); } if (woEntity.ESSD_NBV != null) { inputInfo.ESSD_NBV = string.Format("{0:f}", woEntity.ESSD_NBV); } if (woEntity.TotalCost_NBV != null) { inputInfo.TotalCost_NBV = string.Format("{0:f}", woEntity.TotalCost_NBV); } } } excelPMTDirector.Input(inputInfo); Attachment att = Attachment.GetAttachment("ClosureExecutiveSummary", entity.Id.ToString(), "Template"); if (att == null) { att = new Attachment(); att.RefTableName = "ClosureExecutiveSummary"; att.RefTableID = entity.Id.ToString(); att.CreateTime = DateTime.Now; att.ID = Guid.NewGuid(); att.TypeCode = "Template"; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = SiteFilePath.Executive_Summary_Template; att.InternalName = internalFileName; att.Extension = fileInfo.Extension; att.Length = Convert.ToInt32(fileInfo.Length); att.RequirementId = new Guid("79258ffb-c2ef-4eff-897d-ba8376c90071"); Attachment.Add(att); } else { att.CreateTime = DateTime.Now; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = SiteFilePath.Executive_Summary_Template; att.InternalName = internalFileName; att.Extension = fileInfo.Extension; att.Length = Convert.ToInt32(fileInfo.Length); att.RequirementId = new Guid("79258ffb-c2ef-4eff-897d-ba8376c90071"); Attachment.Update(att); } ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_ExecutiveSummary, NodeCode.Closure_ExecutiveSummary_Generate); return(Ok()); }
public IHttpActionResult PostClosureWOCheckList(ClosureWOCheckList entity) { string _debugInfo = string.Format("[Ln 571] Start Run PostClosureWOCheckList - Entity: {0}", JsonConvert.SerializeObject(entity)); Log4netHelper.WriteInfoLog(_debugInfo, this.GetType(), "PostClosureWOCheckList"); //ClosureInfo closure = new ClosureInfo(); //closure = closure.GetByProjectId(entity.ProjectId.Value); var task = _db.TaskWork.First( e => e.ReceiverAccount == ClientCookie.UserCode && e.Status == 0 && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_WOCheckList && e.RefID == entity.ProjectId ); task.Status = TaskWorkStatus.Finished; task.FinishTime = DateTime.Now; task.Url = SiteInfo.GetProjectViewPageUrl(FlowCode.Closure_WOCheckList, task.RefID); task.RefTableName = ClosureWOCheckList.TableName; task.RefTableId = entity.Id; _db.TaskWork.Attach(task); _db.Entry(task).State = EntityState.Modified; int result = _db.SaveChanges(); _debugInfo = string.Format("[Ln 611] Task:{0}", TaskWork.ConvertToJson(task)); //DateTime.Parse() Log4netHelper.WriteInfoLog(_debugInfo, this.GetType(), "PostClosureWOCheckList"); if (result > 0) { // Start K2 Process var _procCode = WFClosureWOCheckList.ProcessCode; var _listDataFields = new List <ProcessDataField>(); _listDataFields.Add(new ProcessDataField("dest_Creator", ClientCookie.UserCode)); _listDataFields.Add(new ProcessDataField("dest_PMSupervisor", entity.PMSupervisorAccount)); // 工程PM直属上级 _listDataFields.Add(new ProcessDataField("dest_MCCLApprovers", string.Join(";", entity.MCCLApproverAccount, entity.MCCLITApproverAccount, entity.MCCLMCCLEqApproverAccount))); // MCCL Approvers _listDataFields.Add(new ProcessDataField("ProcessCode", _procCode)); //_listDataFields.Add(new ProcessDataField("dest_Receiver", "")); 知会人 //将WOCheckList的任务传给K2 var taskJson = Newtonsoft.Json.JsonConvert.SerializeObject(task); _listDataFields.Add(new ProcessDataField("ProjectTaskInfo", taskJson)); _debugInfo = string.Format("[Ln 630] DataFields: {0}", JsonConvert.SerializeObject(_listDataFields)); Log4netHelper.WriteInfoLog(_debugInfo, this.GetType(), "PostClosureWOCheckList"); var _procInstID = K2FxContext.Current.StartProcess(_procCode, ClientCookie.UserCode, _listDataFields); _debugInfo = string.Format("[Ln 637] ProcInstID: {0}", _procInstID); Log4netHelper.WriteInfoLog(_debugInfo, this.GetType(), "PostClosureWOCheckList"); if (_procInstID > 0) { // 更新 WOCheckList表的ProcInstId entity.ProcInstID = _procInstID; if (entity.Id == Guid.Empty) { entity.Id = Guid.NewGuid(); entity.CreateTime = DateTime.Now; entity.CreateUserAccount = ClientCookie.UserCode; } entity.Save(); _db.Entry(entity).State = EntityState.Modified; SaveCommers(entity, ProjectCommentAction.Submit, ProjectCommentStatus.Submit); result = _db.SaveChanges(); } ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_ClosingCost); } return(Ok(result)); }
/// <summary> /// 提交Closure /// </summary> /// <param name="entity"></param> /// <returns></returns> public IHttpActionResult PostClosure(ClosureInfo entity) { using (TransactionScope tranScope = new TransactionScope()) { // bll.BeginTransAction(); // try // { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (entity.ClosureReasonCode != "Others") { entity.ClosureReasonRemark = string.Empty; } if (entity.Id == new Guid()) { entity.Id = Guid.NewGuid(); entity.CreateDate = DateTime.Now; entity.ProjectId = ProjectInfo.CreateMainProject(FlowCode.Closure, entity.USCode, NodeCode.Start, entity.CreateUserAccount); ClosureInfo.Add(entity); } else { ClosureInfo.Update(entity); } // bll.Commit(); //} //catch (Exception ex) //{ // bll.Rollback(); // return BadRequest(ex.Message); //} var usersList = new List <ProjectUsers>(); var assetActor = GetClosureUsers(ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, ProjectUserRoleCode.AssetActor, entity.AssetActorAccount, entity.AssetActorNameENUS, entity.AssetActorNameZHCN, entity.ProjectId); usersList.Add(assetActor); var assetRep = GetClosureUsers(ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, ProjectUserRoleCode.AssetRep, entity.AssetRepAccount, entity.AssetRepNameENUS, entity.AssetRepNameZHCN, entity.ProjectId); usersList.Add(assetRep); var finance = GetClosureUsers(ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, ProjectUserRoleCode.Finance, entity.FinanceAccount, entity.FinanceNameENUS, entity.FinanceNameZHCN, entity.ProjectId); usersList.Add(finance); var Legal = GetClosureUsers(ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, ProjectUserRoleCode.Legal, entity.LegalAccount, entity.LegalNameENUS, entity.LegalNameZHCN, entity.ProjectId); usersList.Add(Legal); var PM = GetClosureUsers(ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, ProjectUserRoleCode.PM, entity.PMAccount, entity.PMNameZHCN, entity.PMNameENUS, entity.ProjectId); usersList.Add(PM); var assertMgr = GetClosureUsers(ProjectUserRoleCode.AssetManager, ProjectUserRoleCode.AssetManager, ProjectUserRoleCode.AssetManager, entity.AssetManagerAccount, entity.AssetManagerNameENUS, entity.AssetManagerNameZHCN, entity.ProjectId); usersList.Add(assertMgr); var cm = GetClosureUsers(ProjectUserRoleCode.CM, ProjectUserRoleCode.CM, ProjectUserRoleCode.CM, entity.CMAccount, entity.CMNameENUS, entity.CMNameZHCN, entity.ProjectId); usersList.Add(cm); if (entity.NecessaryNoticeUserList != null && entity.NecessaryNoticeUserList.Count > 0) { usersList.AddRange(entity.NecessaryNoticeUserList.Select( user => GetClosureUsers(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.Code, user.NameENUS, user.NameZHCN, entity.ProjectId))); } if (entity.NoticeUserList != null && entity.NoticeUserList.Count > 0) { usersList.AddRange(entity.NoticeUserList.Select( user => GetClosureUsers(ProjectUserRoleCode.View, ProjectUserRoleCode.View, ProjectUserRoleCode.View, user.Code, user.NameENUS, user.NameZHCN, entity.ProjectId))); } ProjectUsers.Add(usersList.ToArray()); SendRemind(entity); SendWorkTaskAndEmail(entity); //初始化项目信息 ProjectInfo.CreateSubProject(FlowCode.Closure_WOCheckList, entity.ProjectId, entity.USCode, NodeCode.Start, PM.UserAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_LegalReview, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_ClosureTool, entity.ProjectId, entity.USCode, NodeCode.Start, finance.UserAccount); var store = StoreBasicInfo.GetStorInfo(entity.USCode); var closureTool = new ClosureTool(); closureTool.Id = Guid.NewGuid(); closureTool.ProjectId = entity.ProjectId; closureTool.IsHistory = false; closureTool.IsOptionOffered = entity.IsRelocation(); closureTool.PipelineName = store.PipelineNameENUS; closureTool.RelocationPipelineID = store.PipelineID; closureTool.Add(); var woCheckList = new ClosureWOCheckList { Id = Guid.NewGuid(), ProjectId = entity.ProjectId, CreateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode, CreateUserName = ClientCookie.UserNameENUS, IsHistory = false }; woCheckList.Add(); var legalReview = new ClosureLegalReview { Id = Guid.NewGuid(), ProjectId = entity.ProjectId, CreateTime = DateTime.Now, CreateUserAccount = ClientCookie.UserCode, CreateUserName = ClientCookie.UserNameENUS, IsHistory = false }; legalReview.Add(); var executiveSummary = new ClosureExecutiveSummary { Id = Guid.NewGuid(), ProjectId = entity.ProjectId, CreateTime = DateTime.Now, CreatorAccount = ClientCookie.UserCode, CreatorName = ClientCookie.UserNameENUS, IsHistory = false }; executiveSummary.Add(); //var package = new ClosurePackage //{ // Id = Guid.NewGuid(), // ProjectId = entity.ProjectId, // CreateTime = DateTime.Now, // CreateUserAccount = ClientCookie.UserCode, // IsHistory = false //}; //package.Add(); var projectContractInfo = ProjectContractInfo.GetContractWithHistory(entity.ProjectId).Current; projectContractInfo.Add(); ProjectInfo.CreateSubProject(FlowCode.Closure_ExecutiveSummary, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_ClosurePackage, entity.ProjectId, entity.USCode, NodeCode.Start, assetActor.UserAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_ConsInvtChecking, entity.ProjectId, entity.USCode, NodeCode.Start, entity.PMAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_ContractInfo, entity.ProjectId, entity.USCode, NodeCode.Start, entity.CreateUserAccount); ProjectInfo.CreateSubProject(FlowCode.Closure_Memo, entity.ProjectId, entity.USCode, NodeCode.Start, entity.CreateUserAccount); ProjectNode.GenerateOnCreate(FlowCode.Closure, entity.ProjectId); try { //bllActionLog.Add(new ActionLog //{ // Id = Guid.NewGuid(), // ProjectId = entity.ProjectId, // Action = ActionType.Submit, // CreateTime = DateTime.Now, // Operator = entity.CreateUserAccount, // OperatorENUS = entity.CreateUserNameENUS, // OperatorZHCN = entity.CreateUserNameZHCN, // Remark = "", // OperatorTitle = "创建流程" //}); tranScope.Complete(); //bll.GetDb().SaveChanges(); } catch (DbEntityValidationException dbEx) { tranScope.Dispose(); } return(Ok(entity)); } }
//private string GetCellValue(decimal? val) //{ // string result = string.Empty; // if (val.HasValue) // { // result = val.Value.ToString("f2"); // } // return result; //} public override void Input(OfficeOpenXml.ExcelWorksheet worksheet, ExcelInputDTO inputInfo) { var closureInfo = ClosureInfo.GetByProjectId(inputInfo.ProjectId); var storeInfo = StoreBasicInfo.FirstOrDefault(s => s.StoreCode == closureInfo.USCode); var storeContract = StoreContractInfo.Get(storeInfo.StoreCode); ClosureTool closureTool = ClosureTool.Get(inputInfo.ProjectId); //ClosureWOCheckList closureWoCheckList = ClosureWOCheckList.Get(inputInfo.ProjectId); worksheet.Cells["B2"].Value = storeInfo.Market; worksheet.Cells["B3"].Value = storeInfo.StoreCode; worksheet.Cells["B4"].Value = storeInfo.NameZHCN; worksheet.Cells["B5"].Value = storeInfo.OpenDate.ToString("yyyy-MM-dd"); if (storeContract != null) { worksheet.Cells["B6"].Value = storeContract.PartyAFullName; worksheet.Cells["B7"].Value = storeContract.EndDate.HasValue ? storeContract.EndDate.Value.ToString("yyyy-MM-dd") : ""; } worksheet.Cells["B8"].Value = closureInfo.ClosureTypeNameZHCN; if (closureInfo.ActualCloseDate != null) { worksheet.Cells["B9"].Value = closureInfo.ActualCloseDate.Value.ToString("yyyy-MM-dd"); } worksheet.Cells["B10"].Value = closureTool.Product_Sales_RMB_Adjustment; worksheet.Cells["B11"].Value = closureTool.PAC_RMB_Adjustment; worksheet.Cells["B12"].Value = closureTool.Rent_RMB_Adjustment; worksheet.Cells["B13"].Value = closureTool.DepreciationLHI_RMB_Adjustment; worksheet.Cells["B14"].Value = closureTool.InterestLHI_RMB_Adjustment; //INTEREST LHI // worksheet.Cells[15, 2].Value = closureTool..ToString(); worksheet.Cells["B15"].Value = closureTool.ServiceFee_RMB_Adjustment; worksheet.Cells["B16"].Value = closureTool.Accounting_RMB_Adjustment; worksheet.Cells["B17"].Value = closureTool.Accounting_RMB_Adjustment; worksheet.Cells["B18"].Value = closureTool.TaxesLicenses_RMB_Adjustment; worksheet.Cells["B19"].Value = closureTool.Depreciation_ESSD_RMB_Adjustment; worksheet.Cells["B20"].Value = closureTool.Interest_ESSD_RMB_Adjustment; worksheet.Cells["B21"].Value = closureTool.OtherIncExp_RMB_Adjustment; worksheet.Cells["B22"].Value = closureTool.NonProduct_Sales_RMB_Adjustment; worksheet.Cells["B23"].Value = closureTool.NonProduct_Costs_RMB_Adjustment; worksheet.Cells["B24"].Value = closureTool.CompSalesMacket_Adjustment; worksheet.Cells["B25"].Value = closureTool.CompCG_Adjustment; worksheet.Cells["B26"].Value = closureTool.CompCGMacket_Adjustment; worksheet.Cells["B27"].Value = closureTool.PACMarket_Adjustment; worksheet.Cells["B28"].Value = closureTool.SOIMarket_Adjustment; worksheet.Cells["B29"].Value = closureTool.TotalSales_TTMY1; worksheet.Cells["B30"].Value = closureTool.CompSales_TTMY1; worksheet.Cells["B31"].Value = closureTool.CompSales_Market_TTMY1; worksheet.Cells["B32"].Value = closureTool.CompGC_TTMY1; worksheet.Cells["B33"].Value = closureTool.CompGCMarket_TTMY1; worksheet.Cells["B34"].Value = closureTool.PAC_TTMY1; worksheet.Cells["B35"].Value = closureTool.PACMarket_TTMY1; worksheet.Cells["B36"].Value = closureTool.SOI_TTMY1; worksheet.Cells["B37"].Value = closureTool.SOIMarket_TTMY1; worksheet.Cells["B38"].Value = closureTool.CashFlow_TTMY1; worksheet.Cells["B39"].Value = closureTool.TotalSales_TTMY2; //sheet.Cells[36, 2].Value = closureTool.cashflow.ToString(); worksheet.Cells["B40"].Value = closureTool.CompSales_TTMY2; worksheet.Cells["B41"].Value = closureTool.CompSales_Market_TTMY2; worksheet.Cells["B42"].Value = closureTool.CompGC_TTMY2; worksheet.Cells["B43"].Value = closureTool.CompGCMarket_TTMY2; worksheet.Cells["B44"].Value = closureTool.PAC_TTMY2; worksheet.Cells["B45"].Value = closureTool.PACMarket_TTMY2; worksheet.Cells["B46"].Value = closureTool.SOI_TTMY2; worksheet.Cells["B47"].Value = closureTool.SOIMarket_TTMY2; worksheet.Cells["B48"].Value = closureTool.CashFlow_TTMY2; worksheet.Cells["B49"].Value = DateTime.Now.Year + " July"; var woEntity = ClosureWOCheckList.Get(closureTool.ProjectId); if (woEntity != null) { worksheet.Cells["B50"].Value = woEntity.RE_Original; worksheet.Cells["B51"].Value = woEntity.LHI_Original; worksheet.Cells["B52"].Value = woEntity.ESSD_Original; worksheet.Cells["B53"].Value = woEntity.RE_NBV; worksheet.Cells["B54"].Value = woEntity.LHI_NBV; worksheet.Cells["B55"].Value = woEntity.ESSD_NBV; worksheet.Cells["B56"].Value = woEntity.EquipmentTransfer; worksheet.Cells["B57"].Value = woEntity.ClosingCost; } var list = ClosureToolImpactOtherStore.Search(e => e.ClosureId == closureTool.Id).AsNoTracking().ToList(); if (list.Count > 0) { worksheet.Cells["B58"].Value = list[0].StoreCode; worksheet.Cells["B59"].Value = list[0].NameZHCN; worksheet.Cells["B60"].Value = list[0].ImpactSaltes; } if (list.Count > 1) { worksheet.Cells["B61"].Value = list[1].StoreCode; worksheet.Cells["B62"].Value = list[1].NameZHCN; worksheet.Cells["B63"].Value = list[1].ImpactSaltes; } worksheet.Cells["B64"].Value = closureTool.McppcoMargin; worksheet.Cells["B65"].Value = closureTool.MccpcoCashFlow; worksheet.Cells["B66"].Value = closureTool.Compensation; worksheet.Cells["B67"].Value = closureTool.CompAssumption; worksheet.Cells["B68"].Value = closureTool.CashflowGrowth; if (closureTool.IsOptionOffered.HasValue) { worksheet.Cells["B69"].Value = closureTool.IsOptionOffered.Value ? "Yes" : "No"; } worksheet.Cells["B70"].Value = closureTool.LeaseTerm; worksheet.Cells["B71"].Value = closureTool.Investment; worksheet.Cells["B72"].Value = closureTool.NPVRestaurantCashflows; if (closureTool.Yr1SOI != null) { worksheet.Cells["B73"].Value = closureTool.Yr1SOI; } if (closureTool.Yr1SOI != null) { worksheet.Cells["B74"].Value = closureTool.IRR; } if (closureTool.ConclusionComment != null) { worksheet.Cells["B76"].Value = closureTool.ConclusionComment; } }
public IHttpActionResult UploadClosureWOCheckListTemplate(string projectid) { var request = HttpContext.Current.Request; var fileCollection = request.Files; if (fileCollection.Count > 0) { _refId = GetRefId(projectid, ClosureWOCheckList.TableName); if (_refId.HasValue) { var file = fileCollection[0]; var fileExtension = Path.GetExtension(file.FileName); var name = _refId.Value.ToString() + "WriteOff"; var fileName = string.Format(@"{0}UploadFiles/{1}{2}", HttpContext.Current.Server.MapPath("~/"), name, fileExtension); file.SaveAs(fileName); if (!IsMeetVersion(ExcelDataInputType.ClosureWOCheckList.ToString(), fileName)) { PluploadHandler.WriteErrorMsg("上传的是非标准模板,请下载标准模板再上传"); } var fileInfo = new FileInfo(fileName); var importDirector = new ExcelDataImportDirector(fileInfo, ExcelDataImportType.ClosureWOCheckList); decimal RE_NBV = 0; decimal.TryParse(importDirector.GetCellValue(9, "E"), out RE_NBV); decimal LHI_NBV = 0; decimal.TryParse(importDirector.GetCellValue(10, "E"), out LHI_NBV); decimal ESSD_NBV = 0; decimal.TryParse(importDirector.GetCellValue(11, "E"), out ESSD_NBV); decimal Equipment_Transfer = 0; decimal.TryParse(importDirector.GetCellValue(16, "E"), out Equipment_Transfer); importDirector.FillEntityEvent += FillClosureWOCheckList; using (TransactionScope scope = new TransactionScope()) { importDirector.ParseAndImport(); AddUpdateAttachment(name + fileExtension, ClosureWOCheckList.TableName, "Template", fileCollection); var currentNode = NodeInfo.GetCurrentNode(projectid, FlowCode.Closure_WOCheckList); var newNode = NodeInfo.GetNodeInfo(NodeCode.Closure_WOCheckList_ResultUpload); if (newNode.Sequence > currentNode.Sequence) { ProjectInfo.FinishNode(projectid, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_DownLoadTemplate); ProjectInfo.FinishNode(projectid, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_WriteOffData); ProjectInfo.FinishNode(projectid, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_ResultUpload); } scope.Complete(); } if (_woCheckList != null) { var closureToolHandler = new ClosureTool(); var oldRE_NBV = _woCheckList.RE_NBV ?? 0; var oldLHI_NBV = _woCheckList.LHI_NBV ?? 0; var oldESSD_NBV = _woCheckList.ESSD_NBV ?? 0; var oldEquipmentTransfer = _woCheckList.EquipmentTransfer ?? 0; if ((RE_NBV != oldRE_NBV) || (LHI_NBV != oldLHI_NBV) || (ESSD_NBV != oldESSD_NBV) || (Equipment_Transfer != oldEquipmentTransfer)) { var __woCheckList = ClosureWOCheckList.FirstOrDefault(e => e.Id.ToString().Equals(_woCheckList.Id.ToString())); if (__woCheckList != null) { __woCheckList.RefreshClosureTool = true; __woCheckList.Update(); } //var closureToolController = new ClosureToolController(); //var toolEntity = ClosureTool.Get(projectid); //if (toolEntity != null) //{ // //判断是否满足生成closureTools的条件 // if (toolEntity.EnableReGenClosureTool()) // { // closureToolController.GenClosureTool(toolEntity.Id, toolEntity.UserAccount, toolEntity.UserNameZHCN, toolEntity.UserNameENUS); // closureToolController.CallClosureTool(toolEntity.Id); // //通知Finance Specialist和Asset Actor // var closureInfo = ClosureInfo.FirstOrDefault(i => i.ProjectId == projectid); // List<string> receiverList = new List<string>(); // receiverList.Add(closureInfo.AssetActorAccount); // receiverList.Add(closureInfo.FinanceAccount); // var notificationMsg = new NotificationMsg() // { // FlowCode = FlowCode.Closure_WOCheckList, // ProjectId = projectid, // SenderCode = ClientCookie.UserCode, // Title = "由于WO Tool数据发生变化,Closure Tool文件已自动更新", // RefId = _woCheckList.Id, // UsCode = _woCheckList.USCode, // IsSendEmail = false, // ReceiverCodeList = receiverList // }; // Notification.Send(notificationMsg); // } //} } } } } return(Ok()); }