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 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)); }
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)); }