public bool Add(MaterTrack materTrack) { using (TransactionScope tranScope = new TransactionScope()) { materTrack.Id = Guid.NewGuid(); materTrack.CreateTime = DateTime.Now; MaterTrack.Add(materTrack); var project = ProjectInfo.Get(materTrack.WorkflowId, materTrack.WorkflowType); var store = StoreBasicInfo.FirstOrDefault(s => s.StoreCode == project.USCode); var Codes = materTrack.NodeType.Split('_'); var url = string.Format("/{0}/Main#/{1}/Process/View?projectId={2}", Codes[0], Codes[1], materTrack.WorkflowId); //if (Codes[0] == "Closure") //临时改动 只针对Closure,因为Closure 用的还是老的URL //{ // url = string.Format("/{0}/Main#/{0}/{1}/Process/View?projectId={2}", Codes[0], Codes[1], materTrack.WorkflowId); //} var title = TaskWork.BuildTitle(materTrack.WorkflowId, store.NameZHCN, store.NameENUS); switch (materTrack.TrackType) { case MaterTrackType.Rep: { var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == materTrack.WorkflowId && pu.RoleCode == ProjectUserRoleCode.AssetActor); TaskWork.SendTask(materTrack.WorkflowId, title, project.USCode, url, actor, materTrack.WorkflowType, materTrack.NodeType, "Start_MaterTrack_Rep"); } break; case MaterTrackType.Feedback: { var legal = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == materTrack.WorkflowId && pu.RoleCode == ProjectUserRoleCode.Legal); TaskWork.Finish(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Rep" && t.Status == TaskWorkStatus.UnFinish); if (TaskWork.Count(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Feedback" && t.Status == TaskWorkStatus.UnFinish) == 0) { TaskWork.SendTask(materTrack.WorkflowId, title, project.USCode, url, legal, materTrack.WorkflowType, materTrack.NodeType, "Start_MaterTrack_Feedback"); } } break; case MaterTrackType.Reply: { var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == materTrack.WorkflowId && pu.RoleCode == ProjectUserRoleCode.AssetActor); TaskWork.Finish(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Feedback" && t.Status == TaskWorkStatus.UnFinish); if (TaskWork.Count(t => t.RefID == materTrack.WorkflowId && t.SourceCode == materTrack.WorkflowType && t.TypeCode == materTrack.NodeType && t.ActivityName == "Start_MaterTrack_Rep" && t.Status == TaskWorkStatus.UnFinish) == 0) { TaskWork.SendTask(materTrack.WorkflowId, title, project.USCode, url, actor, materTrack.WorkflowType, materTrack.NodeType, "Start_MaterTrack_Rep"); } } break; } tranScope.Complete(); return(true); } }