//public static void AddTaskToList(TaskContainer task) //{ // TaskContainer.Items.Add(task); //} //public static void SaveToDataBase(List<TaskContainer> list ) //{ // Serv.SaveToDataBase(list); //} public static void AddTag(TaskContainer task, TaskTag tag) { Task_To_Tag tasktag = new Task_To_Tag(task, tag); Task_To_Tag.Items.Add(tasktag.Id, tasktag); TaskTag.Items.Add(tag.Id, tag); Console.WriteLine(tasktag); }
public Guid PushTask(object taskModel, out bool isStarted, out Guid executorId) { if (taskModel == null) { throw new ArgumentNullException(nameof(taskModel)); } var taskMetadata = MetadataManager.FindTaskMetadata(taskModel); if (taskMetadata == null) { throw new ArgumentException($"Тип модели задачи {taskModel.GetType().AssemblyQualifiedName} не зарегистрирован.", nameof(taskModel)); } var taskId = Guid.NewGuid(); var taskContainer = new TaskContainer(taskId, taskModel, DateTime.UtcNow); taskRepository.PushTaskAsync(taskId, taskMetadata.TaskName, taskModel, DateTime.UtcNow); isStarted = TryCommandExecute(taskContainer, out TaskExecutor executor); if (isStarted) { executorId = executor.ExecutorId; Interlocked.Increment(ref countExecutingTasks); } else { executorId = Guid.Empty; commandQueue.Enqueue(taskContainer); } return(taskId); }
public void StartTask(string taskId) { if (currentTask != "") { return; } TaskContainer task = GetById(taskId); if (task == null || task.status != TaskKind.Active) { return; } if (money < task.task.price) { Gui.ErrorMessage("Not enough money", 1); return; } money -= task.task.price; currentTask = taskId; task.working = true; currentTime = task.task.time; }
private static void OnFinish(FlowToken flowToken, Dictionary <string, object> bindings, FlowControllerServicesContainer serviceContainer) { WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken; using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Finish" })) { TaskManagerFlowControllerService taskManagerFlowControllerService = new TaskManagerFlowControllerService(taskContainer); serviceContainer.AddService(taskManagerFlowControllerService); WorkflowFacade.FireFinishEvent(workflowFlowToken.WorkflowInstanceId, bindings); WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer); WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId); taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId)); } IFormFlowRenderingService formServices = serviceContainer.GetService <IFormFlowRenderingService>(); if (!formServices.HasFieldMessages) { serviceContainer.GetService <IFormFlowRenderingService>().RerenderView(); } }
private void Add_Button_Click(object sender, RoutedEventArgs e) { TaskContainer Task = new TaskContainer(); var addWindow = new AddTaskWindow(Task); bool? res = addWindow.ShowDialog(); RefreshTaskList(); }
private async Task RestoreTasksAsync(CancellationToken cancellationToken = default) { foreach (var taskState in await taskRepository.GetActualTasksAsync(cancellationToken)) { var taskMetadata = MetadataManager.FindTaskMetadata(taskState.TaskModel); if (taskMetadata == null) { throw new ArgumentException(); } var taskContainer = new TaskContainer(taskState.TaskId, taskState.TaskModel, taskState.CreatedDate); if (taskState.ExecutorId.HasValue) { if (!executors.TryGetValue(taskState.ExecutorId.Value, out TaskExecutor executor)) { executors.TryAdd(taskState.ExecutorId.Value, executor = new TaskExecutor(taskState.ExecutorId.Value)); } executor.AddTask(taskContainer); Interlocked.Increment(ref countExecutingTasks); } else { commandQueue.Enqueue(taskContainer); } } }
private void Start() { task = Science.GetById(scienceID); if (task == null) { Debug.Log("science not defined " + scienceID, gameObject); return; } priceText.text = task.task.price.ToString(); iconColor = iconImage.color; UpdateTask(scienceID); if (!requestedPanel) { return; } for (int i = 0; i < task.task.requested.Count; i++) { TaskContainer science = Science.GetById(task.task.requested[i]); Image child = requestedPanel.transform.GetChild(i).GetComponent <Image>(); Color c = child.color; c.a = science.completed ? 1 : 0.2f; child.color = c; } }
static void Main(string[] args) { var parser = new ArgumentParser(); var container = new TaskContainer(); var executor = new TaskExecutor(container, parser); container.Add(new HelpTaskRunner(container)); container.Add(new TaskListTaskRunner(container)); container.Add(new ArgumentDisplayTaskRunner()); container.Add(new AssemblyModuleBuilderTaskRunner()); container.Add(new PackTaskRunner()); container.Add(new InstallTaskRunner()); container.Add(new InstallAllTaskRunner()); Stopwatch timer = new Stopwatch(); timer.Start(); if (args.Length == 0) { executor.ExecuteTask("list", args); Environment.Exit(0); } var result = executor.ExecuteTask(args[0], args.Skip(1).ToArray()); foreach (var exception in result.RaisedExceptions) { Console.WriteLine(exception.Message); } timer.Stop(); Console.WriteLine($"Completed in {timer.Elapsed.ToString("c")}."); Environment.Exit(result.ExitCode); }
protected virtual void Start() { turretData = Science.GetTurretById(turretId); damage = turretData.values.damage; energyUse = turretData.values.energy; fireRate = turretData.values.fireRate; range = turretData.values.range; weaponSpeed = turretData.values.weaponSpeed; foreach (var upgrade in turretData.level) { TaskContainer task = Science.GetById(upgrade.scienceId); if (task == null || task.status != TaskKind.Ready) { continue; } damage += upgrade.values.damage; energyUse -= upgrade.values.energy; fireRate += upgrade.values.fireRate; range += upgrade.values.range; weaponSpeed += upgrade.values.weaponSpeed; } }
public void TaskContainer_Append_Validate_ExceedsMaxLength_ShouldThrowException() { TaskContainer model = new TaskContainer { SourceApp = "BC001", SourceType = "SOURCE TYPE LONGER THAN 10 CHARACTERS", JobNo = "JOB0001", TaskNo = "TASK0001", Name = "Container 1" }; Assert.Throws <Exception>(() => ((IImportRequestable)model).ToImportRequest(TransactionType.Append)); }
public void TaskContainer_Append_Validate_HasIncompleteRequiredAttributes_ShouldThrowException() { TaskContainer model = new TaskContainer { SourceApp = "BC001" }; Assert.Throws <Exception>(() => (model as IImportRequestable).ToImportRequest(TransactionType.Append)); }
public void fasdfasg() { using (var con = new TaskContainer()) { con.AddJobFromAssembly(this.GetType().Assembly); con.Start(); } }
private static async Task RunAsync() { var runner = TaskContainer.Create() .Add("Migration", new MigrationTaskRunner()) .Build(); await runner.RunAsync(); }
public TaskInfo(ParameterizedThreadSStart Funk, object o) { _out = null; is_start = false; is_complete = false; to_lock = new object(); taskContainer = new TaskContainer(Funk, o, this); }
private static TaskContainer CreateContainer(TestContext context) { var container = new TaskContainer(); context.Finishing += delegate { ReapTasks(context, container); }; container.TaskTerminated += delegate(object sender, TaskEventArgs e) { RecordTaskResult(context, e.Task); }; return(container); }
public void TaskContainer_Append_Validate_HasRequiredAttributes_ShouldSucceed() { TaskContainer model = new TaskContainer { SourceApp = "BC001", SourceType = "BC001", JobNo = "JOB0001", TaskNo = "TASK0001", Name = "Container 1" }; ImportRequest importRequest = ((IImportRequestable)model).ToImportRequest(TransactionType.Append); Assert.True(importRequest.ParameterNames[0] == "SourceApp"); Assert.True(importRequest.ParameterValues[0] == "BC001"); }
// List<string> strintaglist = new List<string>(); public AddTagWindow(TaskContainer Taska) { InitializeComponent(); chosenTask = Taska; if (chosenTask.Tags.Count != 0) Taglist.ItemsSource = chosenTask.Tags; //else // Taglist.ItemsSource = chosenTask.Tags; }
public void QueueUserWorkItem(WaitCallback callBack, Object state) { DoDisposeCheck(); if (callBack == null) { ThrowHelper.ThrowArgumentNullException("callBack"); } lock (mLockObject) { DoDisposeCheck(); if (LOGGER.IsDebugEnabled) { LOGGER.Debug(String.Format("THREADPOOL({0}): enqueue new task for execution. Currently waiting task(s) in the queue: {1}", string.IsNullOrEmpty(mName) ? GetHashCode().ToString() : mName, mTaskContainerQueue.Count)); } TaskContainer tc = new TaskContainer() { WaitCallback = callBack, State = state }; WorkerThread wt = null; if (mInactiveThreads.Count > 0) { foreach (WorkerThread _wt in mInactiveThreads) { if (_wt.Task == null && _wt.Thread.ThreadState != System.Threading.ThreadState.Aborted && _wt.Thread.ThreadState != System.Threading.ThreadState.Stopped) { wt = _wt; } } } else if (mThreadNumber < mMaxThreadNumber) { wt = StartNewThread(); } if (wt == null) { // nincs szabad végrehajtó mTaskContainerQueue.Enqueue(tc); if (mMaxThreadNumber > mThreadNumber) { // teli vagyunk, tartalék thread indítása StartNewThread(); } } else { // egyből hozzárendelem valakihez mInactiveThreads.Remove(wt); wt.Task = tc; wt.WakeUpEvent.Set(); } } }
static void Main(string[] args) { var container = new TaskContainer(); ITaskExample example = null; while ((example = container.GetTaskExample()) != null) { example.Execute(); Console.WriteLine("Example is processed"); } }
private void Update() { if (isDead) { return; } if (shipHull <= 0) { isDead = true; CameraControll.ChangeView(ViewKind.Space); return; } dangerObject.SetActive(shipHull < 0.3f); //30% hullText.text = string.Format("{0:0}%", shipHull * 100f); foreach (TMP_Text t in moneyText) { t.text = money.ToString(); } energyText.text = string.Format("{0:0}/{1:0}", energy, maxEnergy); if (currentTask == "") { return; } TaskContainer task = GetById(currentTask); if (!task.working) { return; } if (currentTime > 0) { currentTime -= Time.deltaTime; task.progress = 1 - currentTime / task.task.time; return; } task.completed = true; task.working = false; task.progress = 1; OnScienceComplete?.Invoke(currentTask); currentTime = 0; currentTask = ""; }
public void OnTasksRetrieved(TaskContainer tasks) { try { items.Clear(); items.AddRange(tasks.Habits); items.AddRange(tasks.Routines); items.AddRange(tasks.Todos); UpdateTasks(items); } catch (Exception) { } }
// public AddTask(TaskClass Task, TaskList Tasks, DB TaskDataBase) public AddTaskWindow(TaskContainer Task) { InitializeComponent(); _task = Task; DateTime localTime = DateTime.Now; Year.Text = localTime.Date.Year.ToString(); Month.Text = localTime.Date.Month.ToString(); Day.Text = localTime.Date.Day.ToString(); Hour.Text = localTime.Date.Hour.ToString(); Minute.Text = localTime.Date.Minute.ToString(); }
private bool CanResearch() { foreach (string s in task.requested) { TaskContainer c = Science.GetById(s); if (c == null || !c.completed) { return(false); } } return(true); }
public bool Start(HostControl hostControl) { try { //_wordProcessor = new Timer(ProcessPDFs, null, 0, TimeSpan.FromMinutes(10).Milliseconds); _taskContainer = new TaskContainer(10); ProcessPDFs(null); return(true); } catch { return(false); } }
public void TestEstimation() { var taskContainer = new TaskContainer(CancellationToken.None, null); var task1 = new TestTask(); task1.UpdateEstimation(); var task2 = new TestTask(); taskContainer.AddTask(task1); taskContainer.AddTask(task2); Assert.AreEqual(4, taskContainer.Estimation); task2.UpdateEstimation(); Assert.AreEqual(6, taskContainer.Estimation); }
public int AddTask(ulong sessionId, Action <T> fn, T context, TimeSpan atTime, bool repeated = false) { if (scheduledTasks.TryGetValue(sessionId, out TaskContainer <T> container)) { return(container.CreateNewReminder(fn, context, atTime, repeated)); } else { TaskContainer <T> rc = new TaskContainer <T>(); rc.Id = sessionId; scheduledTasks.Add(sessionId, rc); return(rc.CreateNewReminder(fn, context, atTime, repeated)); } }
public ChangeTaskWindow(TaskContainer Task) { InitializeComponent(); _task = Task; TaskTitle.Text = _task.Name; TaskDescription.Text = _task.Description; Year.Text = _task.Date.Year.ToString(); Month.Text = _task.Date.Month.ToString(); Day.Text = _task.Date.Day.ToString(); Hour.Text = _task.Date.Hour.ToString(); Minute.Text = _task.Date.Minute.ToString(); }
private static void OnPreview(FlowToken flowToken, Dictionary <string, object> bindings, FlowControllerServicesContainer serviceContainer) { WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken; using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Preview" })) { WorkflowFacade.FirePreviewEvent(workflowFlowToken.WorkflowInstanceId, bindings); WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer); WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId); taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId)); } }
private static void ReapTasks(TestContext context, TaskContainer container) { if (!container.JoinAll(JoinBeforeAbortTimeout)) { LogMessageAboutActiveTasks(context, container, String.Format("Some tasks failed to complete within {0} seconds of test termination: ", JoinBeforeAbortTimeout.TotalSeconds)); container.AbortAll(); if (!container.JoinAll(JoinAfterAbortTimeout)) { LogMessageAboutActiveTasks(context, container, String.Format("Some tasks failed to abort within {0} seconds of test termination: ", (JoinBeforeAbortTimeout + JoinAfterAbortTimeout).TotalSeconds)); } } }
public void Serialize() { TaskContainer cont = new TaskContainer(); cont.Groups.Add(new Group { Name = "test" }); var serializer = new XmlSerializer(typeof(TaskContainer)); StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); serializer.Serialize(sw, cont); string xmlResult = sw.GetStringBuilder().ToString(); var test = File.ReadLines(path); }
public void TestProgress() { var taskContainer = new TaskContainer(CancellationToken.None, null); var task1 = new TestTask(); var task2 = new TestTask(); taskContainer.AddTask(task1); taskContainer.AddTask(task2); Assert.AreEqual(0, taskContainer.Progress); task1.DoWork(); Assert.AreEqual(1, taskContainer.Progress); task2.DoWork(); Assert.AreEqual(2, taskContainer.Progress); task1.DoWork(); Assert.AreEqual(3, taskContainer.Progress); task2.DoWork(); Assert.AreEqual(4, taskContainer.Progress); }
public void TestEstimationEvents() { var currentEstimation = 0; var taskContainer = new TaskContainer(CancellationToken.None, null); taskContainer.EstimationChanged += (sender, args) => currentEstimation = args.Estimation; var task1 = new TestTask(); task1.UpdateEstimation(); var task2 = new TestTask(); taskContainer.AddTask(task1); Assert.AreEqual(3, currentEstimation); taskContainer.AddTask(task2); Assert.AreEqual(4, currentEstimation); task2.UpdateEstimation(); Assert.AreEqual(6, currentEstimation); }
private static void OnCustomEvent(int customEventNumber, FlowToken flowToken, Dictionary <string, object> bindings, FlowControllerServicesContainer serviceContainer) { if (customEventNumber < 1 || customEventNumber > 5) { throw new ArgumentException("Number must be between 1 and 5", nameof(customEventNumber)); } WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken; using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "CustomEvent0" + customEventNumber })) { WorkflowFacade.FireCustomEvent(customEventNumber, workflowFlowToken.WorkflowInstanceId, bindings); WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer); WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId); taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId)); } }
public void OnTasksRetrieved(TaskContainer tasks) { try { items.Clear(); var taskList = new List <BaseTask>(); taskList.AddRange(tasks.Habits); taskList.AddRange(tasks.Routines); taskList.AddRange(tasks.Todos); items.AddTasks(taskList); habitLogs = tasks.HabitLogs; routineLogs = tasks.RoutineLogs; adapter.UpdateLogs(habitLogs, routineLogs); UpdateTasks(items); } catch (Exception) { } }
private static void OnSaveAndPublish(FlowToken flowToken, Dictionary <string, object> bindings, FlowControllerServicesContainer serviceContainer) { WorkflowFlowToken workflowFlowToken = (WorkflowFlowToken)flowToken; using (TaskContainer taskContainer = TaskManagerFacade.RuntTasks(flowToken, new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId) { EventName = "Save" })) { TaskManagerFlowControllerService taskManagerFlowControllerService = new TaskManagerFlowControllerService(taskContainer); serviceContainer.AddService(taskManagerFlowControllerService); WorkflowFacade.FireSaveAndPublishEvent(workflowFlowToken.WorkflowInstanceId, bindings); WorkflowFacade.SetFlowControllerServicesContainer(workflowFlowToken.WorkflowInstanceId, serviceContainer); WorkflowFacade.RunWorkflow(workflowFlowToken.WorkflowInstanceId); taskContainer.SetOnIdleTaskManagerEvent(new WorkflowTaskManagerEvent(flowToken, workflowFlowToken.WorkflowInstanceId)); serviceContainer.RemoveService(taskManagerFlowControllerService); } }
public static void AddTaskToList(TaskContainer task) { TaskContainer.Items.Add(task.Id, task); }
private void RunTask(Task task) { var taskContainer = new TaskContainer(task, (o, s) => { // Record that one more task is complete Interlocked.Increment(ref tasksCompleted); // Record the total run time of all tasks. lock (taskTimeTotalLock) { taskTimeTotal = taskTimeTotal.Add(s.TaskExecutionTime); } // Remove my own task from the running tasks. var completedTask = runningTasks.FirstOrDefault(m => m.Id == s.TaskId); if (completedTask != null) runningTasks.Remove(completedTask); OnTaskCompleted(); MakeSureToRunEnoughTasks(); }); lock (runningTasks) { runningTasks.Add(taskContainer); } }
public void QueueUserWorkItem(WaitCallback callBack, Object state) { DoDisposeCheck(); if (callBack == null) { ThrowHelper.ThrowArgumentNullException("callBack"); } lock (mLockObject) { DoDisposeCheck(); if (LOGGER.IsDebugEnabled) LOGGER.Debug(String.Format("THREADPOOL({0}): enqueue new task for execution. Currently waiting task(s) in the queue: {1}", string.IsNullOrEmpty(mName) ? GetHashCode().ToString() : mName, mTaskContainerQueue.Count)); TaskContainer tc = new TaskContainer() { WaitCallback = callBack, State = state }; WorkerThread wt = null; if (mInactiveThreads.Count > 0) { foreach (WorkerThread _wt in mInactiveThreads) { if (_wt.Task == null && _wt.Thread.ThreadState != System.Threading.ThreadState.Aborted && _wt.Thread.ThreadState != System.Threading.ThreadState.Stopped) { wt = _wt; } } } else if (mThreadNumber < mMaxThreadNumber) { wt = StartNewThread(); } if (wt == null) { // nincs szabad végrehajtó mTaskContainerQueue.Enqueue(tc); if (mMaxThreadNumber > mThreadNumber) { // teli vagyunk, tartalék thread indítása StartNewThread(); } } else { // egyből hozzárendelem valakihez mInactiveThreads.Remove(wt); wt.Task = tc; wt.WakeUpEvent.Set(); } } }
/// <exclude /> public TaskManagerFlowControllerService(TaskContainer taskContainer) { Verify.IsNotNull(taskContainer, "taskContainer"); this.TaskContainer = taskContainer; }