private void ClearWork() { lock (padlock) { currentWorkFunction = null; currentContext = null; } }
/// <summary> /// Ons the get async. /// </summary> /// <returns>The get async.</returns> public async Task <IActionResult> OnPostAsync() { _logger.LogDebug("Functions/Create/OnPostAsync"); if (!ModelState.IsValid) { return(Page()); } var emptyFunction = new WorkFunction(); if (await TryUpdateModelAsync <WorkFunction>( emptyFunction, "function", // Prefix for form value f => f.Name, f => f.Priority, f => f.LastUpdate ).ConfigureAwait(false)) { _context.WorkFunction.Add(emptyFunction); await _context.SaveChangesAsync().ConfigureAwait(false); return(RedirectToPage("./Index")); } return(null); }
private void SetWork(WorkFunction workFunction, object contextObject) { lock (padlock) { currentWorkFunction = workFunction; currentContext = contextObject; } }
public BatchProcessor(CPUMediator cpuMediator) { padlock = new object(); shutdown = false; this.cpuMediator = cpuMediator; currentWorkFunction = null; currentContext = null; thread = new Thread(new ThreadStart(DoProcessing)); thread.Start(); }
private void CheckForMoreWork() { CPUMediator.QueuedBatch batch; lock (padlock) { batch = cpuMediator.TryToGetBatch(); } if (batch.workFunction != null) { currentWorkFunction = batch.workFunction; currentContext = batch.contextObject; } }
/// <summary> /// Ons the get async. /// </summary> /// <returns>The get async.</returns> /// <param name="id">Identifier.</param> public async Task <IActionResult> OnGetAsync(int?id) { _logger.LogDebug($"Functions/Edit/OnGetAsync({id})"); if (id == null) { return(NotFound()); } WorkFunction = await _context.WorkFunction.FindAsync(id).ConfigureAwait(false); if (WorkFunction == null) { return(NotFound()); } return(Page()); }
/// <summary> /// Ons the get async. /// </summary> /// <returns>The get async.</returns> /// <param name="id">Identifier.</param> public async Task <IActionResult> OnGetAsync(int?id) { _logger.LogDebug($"Functions/Details/OnGetAsync({id})"); if (id == null) { return(NotFound()); } WorkFunction = await _context.WorkFunction.SingleOrDefaultAsync(m => m.ID == id).ConfigureAwait(false); if (WorkFunction == null) { return(NotFound()); } return(Page()); }
public bool TryToStartWork(WorkFunction workFunction, object contextObject) { bool returnValue; lock (padlock) { if (currentWorkFunction == null) { currentWorkFunction = workFunction; currentContext = contextObject; returnValue = true; } else { returnValue = false; } } return(returnValue); }
/// <summary> /// Open a pop-up prompt window for button functions. /// </summary> public static void WorkPrompt(WorkFunction function, Action buttonAction, string title, PawnSurface surface) { string text = ""; switch (function) { case WorkFunction.AllPawns_EnableWork: text = "DD_WorkTab_PromptText_AllPawns_EnableWork".CachedTranslation(); break; case WorkFunction.AllPawns_DisableWork: text = "DD_WorkTab_PromptText_AllPawns_DisableWork".CachedTranslation(); break; case WorkFunction.AllPawns_ResetWork: text = "DD_WorkTab_PromptText_AllPawns_ResetWork".CachedTranslation(); break; case WorkFunction.EnableWork: text = "DD_WorkTab_PromptText_EnableWork".CachedTranslation().AdjustedFor(surface.pawn); break; case WorkFunction.DisableWork: text = "DD_WorkTab_PromptText_DisableWork".CachedTranslation().AdjustedFor(surface.pawn); break; case WorkFunction.ResetWork: text = "DD_WorkTab_PromptText_ResetWork".CachedTranslation().AdjustedFor(surface.pawn); break; } DiaOption accept = new DiaOption("DD_WorkTab_PromptOption_Accept".CachedTranslation()) { action = buttonAction, resolveTree = true }; DiaOption cancel = new DiaOption("DD_WorkTab_PromptOption_Cancel".CachedTranslation()) { resolveTree = true }; DiaOption acceptDisablePrompt = new DiaOption("DD_WorkTab_PromptOption_AcceptDisablePrompt".CachedTranslation()) { action = delegate { Controller.ShowPrompts.Value = false; buttonAction(); }, resolveTree = true }; DiaNode prompt = new DiaNode(text + "DD_WorkTab_PromptText_DisablePrompt".CachedTranslation()) { options = new List <DiaOption> { accept, cancel, acceptDisablePrompt } }; Find.WindowStack.Add(new Dialog_NodeTree(prompt, false, false, title)); }
/// <summary> /// Builds a Float Menu entry to perform various work functions. /// </summary> public static FloatMenuOption WorkOption(WorkFunction function, PawnSurface surface) { string title = ""; Action buttonAction = default(Action); switch (function) { case WorkFunction.AllPawns_EnableWork: title = "DD_WorkTab_Title_AllPawns_EnableWork".CachedTranslation(); buttonAction = delegate { foreach (Pawn p in Find.VisibleMap.mapPawns.FreeColonists) { Controller.GetManager.GetPawnSurface(p).EnableAllPawnWork(); } }; break; case WorkFunction.AllPawns_DisableWork: title = "DD_WorkTab_Title_AllPawns_DisableWork".CachedTranslation(); buttonAction = delegate { foreach (Pawn p in Find.VisibleMap.mapPawns.FreeColonists) { Controller.GetManager.GetPawnSurface(p).DisableAllPawnWork(); } }; break; case WorkFunction.AllPawns_ResetWork: title = "DD_WorkTab_Title_AllPawns_ResetWork".CachedTranslation(); buttonAction = delegate { foreach (Pawn p in Find.VisibleMap.mapPawns.FreeColonists) { Controller.GetManager.GetPawnSurface(p).ResetAllPawnWork(); } }; break; case WorkFunction.EnableWork: title = "DD_WorkTab_Title_EnableWork".CachedTranslation(); buttonAction = delegate { surface.EnableAllPawnWork(); }; break; case WorkFunction.DisableWork: title = "DD_WorkTab_Title_DisableWork".CachedTranslation(); buttonAction = delegate { surface.DisableAllPawnWork(); }; break; case WorkFunction.ResetWork: title = "DD_WorkTab_Title_ResetWork".CachedTranslation(); buttonAction = delegate { surface.ResetAllPawnWork(); }; break; case WorkFunction.CopySettings: title = "DD_WorkTab_Title_CopyWorkPriorities".CachedTranslation(); buttonAction = delegate { surface.CopyPriorities(); }; break; case WorkFunction.PasteSettings: title = "DD_WorkTab_Title_PasteWorkPriorities".CachedTranslation(); buttonAction = delegate { surface.PastePriorities(Controller.CopyPrioritiesReference); }; break; } if (Controller.ShowPrompts && function != WorkFunction.CopySettings && function != WorkFunction.PasteSettings) { return(new FloatMenuOption(title, delegate { WorkPrompt(function, buttonAction, title, surface); })); } return(new FloatMenuOption(title, delegate { buttonAction(); UserFeedbackChain(WorkSound.TaskCompleted); })); }