public void Run(BatchWork work) { if (work is MakeAll) { work = (work as CompositeWork).Tasks[0]; } wasException = false; var worksInQueue = this.Work .Where(x => x.Status == BatchWorkStatus.Pending || x.Status == BatchWorkStatus.Running) .ToList(); //for duplicates removing if (worksInQueue.Any(x => x.Model == work.Model && x.GetType() == work.GetType())) { return; //reject work as duplicate at top level } UnpackWork(work); //prepare tree in work lock (addLock) { Work.Add(work); } if (!queueWorking && Work.Count != 0) { currentIndex = 0; queueThread = new Thread(Execute); queueThread.Start(); queueWorking = true; } }
public IActionResult Work(Work model) { List <Work> Work; using (var sr = new StreamReader(@"./Data/work.json")) { string json = sr.ReadToEnd(); Work = JsonSerializer.Deserialize <List <Work> >(json); } if (ModelState.IsValid) { Work.Add(model); using (var sr = new StreamWriter(@"./Data/work.json")) { string serialized = JsonSerializer.Serialize(Work); sr.Write(serialized); } return(RedirectToAction("Work")); } ViewBag.work = Work; return(View()); }
private void GetAllModel() { foreach (Part pt in Session.GetSession().Parts) { string name = pt.Name; if (ParentAssmblieInfo.IsParent(pt)) { ParentAssmblieInfo parent = ParentAssmblieInfo.GetAttribute(pt); switch (parent.Type) { case PartType.ASM: Asm.Add(new ASMModel(pt)); break; case PartType.EDM: Edm.Add(new EDMModel(pt)); break; case PartType.Electrode: ElectrodeModel eleModel = new ElectrodeModel(pt); Electrode.Add(eleModel); break; case PartType.Work: Work.Add(new WorkModel(pt)); break; default: Other.Add(pt); break; } } else { Other.Add(pt); } } }
private void OnAddStory() { Work.Add(new Work()); ModelText = "Task Board"; }