public override string Edit() { var taskWork = TaskWork.FirstOrDefault(e => e.ReceiverAccount == ClientCookie.UserCode && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_ExecutiveSummary && e.RefID == this.ProjectId); taskWork.Status = TaskWorkStatus.UnFinish; taskWork.StatusNameZHCN = "任务"; taskWork.StatusNameENUS = "任务"; var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId); taskWork.ReceiverAccount = closureEntity.AssetActorAccount; taskWork.ReceiverNameENUS = closureEntity.AssetActorNameENUS; taskWork.ReceiverNameZHCN = closureEntity.AssetActorNameZHCN; taskWork.Id = Guid.NewGuid(); taskWork.CreateTime = DateTime.Now; taskWork.Url = TaskWork.BuildUrl(FlowCode.Closure_ExecutiveSummary, this.ProjectId, ""); taskWork.ActivityName = NodeCode.Start; taskWork.ProcInstID = null; taskWork.FinishTime = null; taskWork.ActionName = SetTaskActionName(ProjectId); TaskWork.Add(taskWork); this.IsHistory = true; this.Save(); var objectCopy = new ObjectCopy(); var newEntity = objectCopy.AutoCopy(this); newEntity.Id = Guid.NewGuid(); newEntity.ProcInstID = 0; newEntity.IsHistory = false; newEntity.Add(); var projectEntity = ProjectInfo.Get(this.ProjectId, FlowCode.Closure_ExecutiveSummary); projectEntity.Status = ProjectStatus.UnFinish; ProjectInfo.Update(projectEntity); ProjectInfo.Reset(ProjectId, FlowCode.Closure_ExecutiveSummary); ProjectInfo.Reset(ProjectId, FlowCode.Closure); var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() && e.RefTableName == ClosureExecutiveSummary.TableName).AsNoTracking().ToList(); var newList = new List <Attachment>(); foreach (var att in attList) { var newAtt = objectCopy.AutoCopy(att); newAtt.RefTableID = newEntity.Id.ToString(); newAtt.ID = Guid.NewGuid(); newList.Add(newAtt); } Attachment.Add(newList.ToArray()); return(taskWork.Url); }
public static void PostRemaindList(Remind remind, List <ProjectUsers> remindUsers) { var objectCopy = new ObjectCopy(); List <Remind> listRemind = new List <Remind>(); try { foreach (var users in remindUsers) { var entity = new Remind(); entity = objectCopy.AutoCopy(remind); entity.Id = Guid.NewGuid(); entity.ReceiverNameENUS = users.UserNameENUS; entity.ReceiverNameZHCN = users.UserNameZHCN; entity.ReceiverAccount = users.UserAccount; entity.CreateTime = DateTime.Now; listRemind.Add(entity); } Add(listRemind.ToArray()); } catch (Exception ex) { throw ex; } }
private void ModifyProject(ClosureConsInvtChecking 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); if (action == ProjectAction.Edit) { entity.IsHistory = true; entity.LastUpdateTime = DateTime.Now; entity.Update(); var objectCopy = new ObjectCopy(); var newWo = objectCopy.AutoCopy(entity); newWo.Id = Guid.NewGuid(); ClosureConsInvtChecking.Add(newWo); var projectEntity = ProjectInfo.Get(entity.ProjectId, FlowCode.Closure_ConsInvtChecking); projectEntity.Status = ProjectStatus.UnFinish; ProjectInfo.Update(projectEntity); } ProjectInfo.Reset(entity.ProjectId, FlowCode.Closure_ConsInvtChecking); }
public IHttpActionResult CreateList(TaskWork entity, List <RemindUserInfo> users) { var taskWorkEntity = new TaskWork(); ObjectCopy objectCopy = new ObjectCopy(); foreach (var remindUserInfo in users) { taskWorkEntity = objectCopy.AutoCopy(entity); taskWorkEntity.ReceiverAccount = remindUserInfo.UserAccount; taskWorkEntity.ReceiverNameENUS = remindUserInfo.UserNameENUS; taskWorkEntity.ReceiverNameZHCN = remindUserInfo.UserNameZHCN; taskWorkEntity.CreateTime = DateTime.Now; Create(taskWorkEntity); } return(Ok()); }
public IHttpActionResult PostRemaindList(Remind remind, List <RemindUserInfo> remindUsers) { var newGuid = new Guid(); ObjectCopy objectCopy = new ObjectCopy(); var entity = new Remind(); foreach (var users in remindUsers) { entity = objectCopy.AutoCopy(remind); entity.Id = newGuid; entity.ReceiverNameENUS = users.UserNameENUS; entity.ReceiverNameZHCN = users.UserNameZHCN; entity.ReceiverAccount = users.UserAccount; entity.CreateTime = DateTime.Now; PostRemind(entity); } return(Ok()); }
public static void Send(Remind remindInfo, List <SimpleEmployee> receiverUserList, string projectId, string flowCode) { var objectCopy = new ObjectCopy(); using (var scope = new TransactionScope()) { foreach (var receiver in receiverUserList) { var remind = objectCopy.AutoCopy(remindInfo); remind.Id = Guid.NewGuid(); remind.IsReaded = false; remind.ReceiverAccount = receiver.Code; remind.ReceiverNameENUS = receiver.NameENUS; remind.ReceiverNameZHCN = receiver.NameZHCN; remind.CreateTime = DateTime.Now; remind.Url = string.Format("/Home/Main#/project/detail/{0}?flowCode={1}", projectId, flowCode); remind.Add(); } scope.Complete(); } }
public override string Edit() { if (!PreEdit(this.ProjectId)) { return(""); } var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId); var store = StoreBasicInfo.GetStorInfo(closureEntity.USCode); var taskWork = new TaskWork(); var source = FlowInfo.Get(FlowCode.Closure); var taskType = FlowInfo.Get(FlowCode.Closure_WOCheckList); taskWork.SourceCode = source.Code; taskWork.SourceNameZHCN = source.NameZHCN; taskWork.SourceNameENUS = source.NameENUS; taskWork.Status = TaskWorkStatus.UnFinish; taskWork.StatusNameZHCN = "任务"; taskWork.StatusNameENUS = "任务"; taskWork.Title = TaskWork.BuildTitle(this.ProjectId, store.NameZHCN, store.NameENUS); taskWork.RefID = this.ProjectId; taskWork.StoreCode = closureEntity.USCode; taskWork.TypeCode = taskType.Code; taskWork.TypeNameENUS = taskType.NameENUS; taskWork.TypeNameZHCN = taskType.NameZHCN; taskWork.ReceiverAccount = closureEntity.PMAccount; taskWork.ReceiverNameENUS = closureEntity.PMNameENUS; taskWork.ReceiverNameZHCN = closureEntity.PMNameZHCN; taskWork.Id = Guid.NewGuid(); taskWork.CreateTime = DateTime.Now; taskWork.Url = TaskWork.BuildUrl(FlowCode.Closure_WOCheckList, this.ProjectId, ""); taskWork.ActivityName = NodeCode.Start; TaskWork.Add(taskWork); this.IsHistory = true; this.RefreshClosureTool = false; //TaskWork.SetTaskHistory(this.Id, this.ProcInstID); this.Save(); var objectCopy = new ObjectCopy(); var newWo = objectCopy.AutoCopy(this); newWo.Id = Guid.NewGuid(); newWo.ProcInstID = 0; newWo.Save(); var projectEntity = ProjectInfo.Get(this.ProjectId, FlowCode.Closure_WOCheckList); ProjectInfo.UnFinishNode(this.ProjectId, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_Approve, ProjectStatus.UnFinish); var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() && e.RefTableName == ClosureWOCheckList.TableName); var objCopy = new ObjectCopy(); var newList = new List <Attachment>(); foreach (var att in attList) { var newAtt = objCopy.AutoCopy(att); newAtt.RefTableID = newWo.Id.ToString(); newAtt.ID = Guid.NewGuid(); newList.Add(newAtt); } Attachment.AddList(newList); return(taskWork.Url); }
public override string Edit() { var taskWork = TaskWork.Search(e => e.ReceiverAccount == ClientCookie.UserCode && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_ConsInvtChecking && e.RefID == this.ProjectId ).AsNoTracking().FirstOrDefault(); taskWork.Status = TaskWorkStatus.UnFinish; taskWork.StatusNameZHCN = "任务"; taskWork.StatusNameENUS = "任务"; var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId); taskWork.ReceiverAccount = closureEntity.PMAccount; taskWork.ReceiverNameENUS = closureEntity.PMNameENUS; taskWork.ReceiverNameZHCN = closureEntity.PMNameZHCN; taskWork.Id = Guid.NewGuid(); taskWork.ProcInstID = null; taskWork.CreateTime = DateTime.Now; taskWork.Url = "/Closure/Main#/ConsInvtChecking?projectId=" + this.ProjectId; taskWork.ActivityName = NodeCode.Start; taskWork.ActionName = SetTaskActionName(ProjectId); taskWork.ProcInstID = null; taskWork.FinishTime = null; TaskWork.Add(taskWork); this.IsHistory = true; this.Save(); var objectCopy = new ObjectCopy(); var newEntity = objectCopy.AutoCopy(this); newEntity.Id = Guid.NewGuid(); newEntity.ProcInstID = 0; newEntity.Save(); //var projectEntity = ProjectInfo.Get(this.ProjectId, FlowCode.Closure_ConsInvtChecking); //projectEntity.Status = ProjectStatus.UnFinish; //ProjectInfo.Update(projectEntity); //ProjectInfo.UpdateProjectNode(this.ProjectId, FlowCode.Closure_ConsInvtChecking, // NodeCode.Closure_ConsInvtChecking_Approve); //ProjectInfo.Reset(ProjectId, FlowCode.Closure); ProjectInfo.Reset(ProjectId, FlowCode.Closure_ConsInvtChecking); ProjectInfo.UnFinishNode(this.ProjectId, FlowCode.Closure_ConsInvtChecking, NodeCode.Closure_ConsInvtChecking_Approve, ProjectStatus.UnFinish); var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() && e.RefTableName == ClosureConsInvtChecking.TableName).AsNoTracking(); var newList = new List <Attachment>(); foreach (var att in attList) { var newAtt = objectCopy.AutoCopy(att); newAtt.RefTableID = newEntity.Id.ToString(); newAtt.ID = Guid.NewGuid(); newList.Add(newAtt); } Attachment.Add(newList.ToArray()); return(taskWork.Url); }
public override string Edit() { if (!PreEdit(this.ProjectId)) { return(""); } var taskWork = TaskWork.Search(e => e.ReceiverAccount == ClientCookie.UserCode && e.SourceCode == FlowCode.Closure && e.TypeCode == FlowCode.Closure_LegalReview && e.RefID == this.ProjectId ).FirstOrDefault(); TaskWork.Cancel(t => t.RefID == ProjectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == this.WorkflowCode);//取消老的流程实例的所有未完成任务 taskWork.Status = TaskWorkStatus.UnFinish; taskWork.StatusNameZHCN = "任务"; taskWork.StatusNameENUS = "任务"; var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId); taskWork.ReceiverAccount = closureEntity.AssetActorAccount; taskWork.ReceiverNameENUS = closureEntity.AssetActorNameENUS; taskWork.ReceiverNameZHCN = closureEntity.AssetActorNameENUS; taskWork.Id = Guid.NewGuid(); taskWork.ProcInstID = null; taskWork.CreateTime = DateTime.Now; taskWork.Url = "/closure/Main#/LegalReview?projectId=" + this.ProjectId; taskWork.ActivityName = NodeCode.Start; taskWork.ActionName = SetTaskActionName(ProjectId); TaskWork.Add(taskWork); this.IsHistory = true; //TaskWork.SetTaskHistory(this.Id, this.ProcInstID); this.Save(); var _db = GetDb(); _db.Entry(this).State = EntityState.Modified; var objectCopy = new ObjectCopy(); var newEntity = objectCopy.AutoCopy(this); newEntity.Id = Guid.NewGuid(); newEntity.ProcInstID = 0; newEntity.LegalCommers = ""; newEntity.Save(); ProjectInfo.Reset(this.ProjectId, FlowCode.Closure_LegalReview); var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() && e.RefTableName == ClosureLegalReview.TableName).AsNoTracking().ToList(); var newList = new List <Attachment>(); foreach (var att in attList) { var newAtt = objCopy.AutoCopy(att); newAtt.RefTableID = newEntity.Id.ToString(); newAtt.ID = Guid.NewGuid(); newList.Add(newAtt); } Attachment.AddList(newList); _db.SaveChanges(); return(taskWork.Url); }
public override string Edit() { if (!PreEdit(this.ProjectId)) { return(""); } var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId); var store = StoreBasicInfo.GetStorInfo(closureEntity.USCode); var taskWork = new TaskWork(); var source = FlowInfo.Get(FlowCode.Closure); var taskType = FlowInfo.Get(FlowCode.Closure_ClosureTool); taskWork.SourceCode = source.Code; taskWork.SourceNameZHCN = source.NameZHCN; taskWork.SourceNameENUS = source.NameENUS; taskWork.Status = TaskWorkStatus.UnFinish; taskWork.StatusNameZHCN = "任务"; taskWork.StatusNameENUS = "任务"; taskWork.Title = TaskWork.BuildTitle(this.ProjectId, store.NameZHCN, store.NameENUS); taskWork.RefID = this.ProjectId; taskWork.StoreCode = closureEntity.USCode; taskWork.TypeCode = taskType.Code; taskWork.TypeNameENUS = taskType.NameENUS; taskWork.TypeNameZHCN = taskType.NameZHCN; taskWork.ReceiverAccount = closureEntity.FinanceAccount; taskWork.ReceiverNameENUS = closureEntity.FinanceNameENUS; taskWork.ReceiverNameZHCN = closureEntity.FinanceNameZHCN; taskWork.Id = Guid.NewGuid(); taskWork.CreateTime = DateTime.Now; taskWork.ActivityName = NodeCode.Start; taskWork.ActionName = SetTaskActionName(ProjectId); taskWork.Url = TaskWork.BuildUrl(FlowCode.Closure_ClosureTool, this.ProjectId, ""); TaskWork.Add(taskWork); this.IsHistory = true; TaskWork.SetTaskHistory(this.Id, this.ProcInstID); this.Save(); var objectCopy = new ObjectCopy(); var newEntity = objectCopy.AutoCopy(this); newEntity.Id = Guid.NewGuid(); newEntity.ProcInstID = 0; newEntity.IsHistory = false; newEntity.Save(); //复制ImpactOtherStore信息 var impactOtherStores = ClosureToolImpactOtherStore.Search(i => i.ClosureId == this.Id).AsNoTracking().ToArray(); if (impactOtherStores.Length > 0) { foreach (var impactItem in impactOtherStores) { impactItem.Id = Guid.NewGuid(); impactItem.ClosureId = newEntity.Id; } ClosureToolImpactOtherStore.Add(impactOtherStores); } ProjectInfo.Reset(this.ProjectId, FlowCode.Closure_ClosureTool); var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() && e.RefTableName == ClosureTool.TableName).AsNoTracking().ToList(); var newList = new List <Attachment>(); foreach (var att in attList) { var newAtt = objCopy.AutoCopy(att); newAtt.RefTableID = newEntity.Id.ToString(); newAtt.ID = Guid.NewGuid(); newList.Add(newAtt); } Attachment.AddList(newList); return(taskWork.Url); }
public override string Edit() { //取消未处理完成的任务(主要是Package最后一个环节办理完后,不走K2流程生成的1条回到Actor的任务) var oldTask = TaskWork.Search(i => i.SourceCode == FlowCode.Closure && i.TypeCode == FlowCode.Closure_ClosurePackage && i.RefID == this.ProjectId && i.Status == TaskWorkStatus.UnFinish).ToArray(); foreach (var taskItem in oldTask) { taskItem.Status = TaskWorkStatus.Cancel; } TaskWork.Update(oldTask); //var taskWork = TaskWork.FirstOrDefault(e => e.ReceiverAccount == ClientCookie.UserCode // && e.SourceCode == FlowCode.Closure // && e.TypeCode == FlowCode.Closure_ClosurePackage && e.RefID == this.ProjectId); //taskWork.Status = TaskWorkStatus.UnFinish; //taskWork.StatusNameZHCN = "任务"; //taskWork.StatusNameENUS = "任务"; //var closureEntity = ClosureInfo.GetByProjectId(this.ProjectId); //taskWork.ReceiverAccount = closureEntity.AssetActorAccount; //taskWork.ReceiverNameENUS = closureEntity.AssetActorNameENUS; //taskWork.ReceiverNameZHCN = closureEntity.AssetActorNameZHCN; //taskWork.Id = Guid.NewGuid(); //taskWork.CreateTime = DateTime.Now; //taskWork.Url = TaskWork.BuildUrl(FlowCode.Closure_ClosurePackage, this.ProjectId, ""); //taskWork.ActivityName = NodeCode.Start; //taskWork.ActionName = SetTaskActionName(ProjectId); //taskWork.ProcInstID = null; //taskWork.FinishTime = null; //TaskWork.Add(taskWork); var url = GeneratePackageTask(ProjectId); this.IsHistory = true; this.Save(); var objectCopy = new ObjectCopy(); var newEntity = objectCopy.AutoCopy(this); newEntity.Id = Guid.NewGuid(); newEntity.ProcInstID = 0; newEntity.IsHistory = false; newEntity.Add(); var projectEntity = ProjectInfo.Get(this.ProjectId, FlowCode.Closure_ClosurePackage); projectEntity.Status = ProjectStatus.UnFinish; ProjectInfo.Update(projectEntity); ProjectInfo.Reset(ProjectId, FlowCode.Closure_ClosurePackage); ProjectInfo.Reset(ProjectId, FlowCode.Closure); var attList = Attachment.Search(e => e.RefTableID == this.Id.ToString() && e.RefTableName == ClosurePackage.TableName).AsNoTracking().ToList(); var newList = new List <Attachment>(); foreach (var att in attList) { var newAtt = objectCopy.AutoCopy(att); newAtt.RefTableID = newEntity.Id.ToString(); newAtt.ID = Guid.NewGuid(); newList.Add(newAtt); } Attachment.Add(newList.ToArray()); return(url); }
private void SendWorkTaskAndEmail(ClosureInfo entity) { var newGuid = new Guid(); var taskWorkController = new TaskWorkController(); //任务通用部分 var taskWork = new TaskWork(); taskWork.SourceCode = FlowCode.Closure; taskWork.SourceNameZHCN = "关店流程"; taskWork.SourceNameENUS = taskWork.SourceCode; taskWork.Status = 0; taskWork.StatusNameZHCN = "任务"; taskWork.StatusNameENUS = "任务"; var title = TaskWork.BuildTitle(entity.ProjectId, entity.StoreNameZHCN, entity.StoreNameENUS); taskWork.Title = title; //string.Format("{0} {1}", entity.StoreNameCN, entity.StoreNameEN); taskWork.RefID = entity.ProjectId.ToString(); taskWork.StoreCode = entity.USCode; taskWork.ActionName = NodeCode.Start; var objectCopy = new ObjectCopy(); var taskWorkEntity = objectCopy.AutoCopy(taskWork); //创建WOChecklist任务 taskWorkEntity.TypeCode = FlowCode.Closure_WOCheckList; taskWorkEntity.TypeNameENUS = "WOChecklist"; taskWorkEntity.TypeNameZHCN = "WOChecklist"; taskWorkEntity.ReceiverAccount = entity.PMAccount; taskWorkEntity.ReceiverNameENUS = entity.PMNameENUS; taskWorkEntity.ReceiverNameZHCN = entity.PMNameZHCN; taskWorkEntity.Id = newGuid; //taskWorkEntity.Url = SiteInfo.WebUrl + "/closure/Main#/closure/WOCheckList/" + entity.ProjectId; taskWorkEntity.Url = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_WOCheckList, entity.ProjectId); taskWorkEntity.ActivityName = "Start"; taskWorkController.Create(taskWorkEntity); var closureHandler = new ClosureHandler(); var noticerList = new List <string>(); if (entity.NoticeUserList != null && entity.NoticeUserList.Count > 0) { noticerList = entity.NoticeUserList.Select(e => e.Account).ToList(); } //noticerList.Add(entity.PMAccount); //closureHandler.SendEmail(newGuid, noticerList.ToArray(), "WOChecklist", entity.ProjectId, ClosureWOCheckList.TableName, entity.PMNameENUS); //noticerList.Remove(entity.PMAccount); taskWorkEntity = objectCopy.AutoCopy(taskWork); //创建Closure Tool任务 taskWorkEntity.TypeCode = FlowCode.Closure_ClosureTool; taskWorkEntity.TypeNameENUS = "Closure Tool(Fin)"; taskWorkEntity.TypeNameZHCN = "Closure Tool(Fin)"; taskWorkEntity.ReceiverAccount = entity.FinanceAccount; taskWorkEntity.ReceiverNameZHCN = entity.FinanceNameZHCN; taskWorkEntity.ReceiverNameENUS = entity.FinanceNameENUS; taskWorkEntity.Id = newGuid; taskWorkEntity.Url = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_ClosureTool, entity.ProjectId); taskWorkEntity.ActivityName = "Start"; taskWorkController.Create(taskWorkEntity); //noticerList.Add(entity.FinanceAccount); //closureHandler.SendEmail(newGuid, noticerList.ToArray(), "Closure Tool", entity.ProjectId, ClosureTool.TableName, entity.PMNameENUS); //noticerList.Remove(entity.FinanceAccount); taskWorkEntity = objectCopy.AutoCopy(taskWork); //创建LegalReview(Rep)任务 taskWorkEntity.TypeCode = FlowCode.Closure_LegalReview; taskWorkEntity.TypeNameENUS = "LegalReview(Rep)"; taskWorkEntity.TypeNameZHCN = "LegalReview(Rep)"; taskWorkEntity.ReceiverAccount = entity.AssetActorAccount; taskWorkEntity.ReceiverNameZHCN = entity.AssetActorNameZHCN; taskWorkEntity.ReceiverNameENUS = entity.AssetActorNameENUS; taskWorkEntity.Id = newGuid; taskWorkEntity.Url = SiteInfo.GetProjectHandlerPageUrl(FlowCode.Closure_LegalReview, entity.ProjectId); taskWorkEntity.ActivityName = "Start"; taskWorkController.Create(taskWorkEntity); //noticerList.Add(entity.AssetActorAccount); //closureHandler.SendEmail(newGuid, noticerList.ToArray(), "LegalReview", entity.ProjectId, ClosureLegalReview.TableName,entity.PMNameENUS); //noticerList.Remove(entity.AssetActorAccount); }