private void Execute(UITimerTask task) { task.RepeatingDoneCount++; if (!task.IsRepeating) { task.IsCompleted = true; } else { if (task.RepeatingNeededCount != 0 && task.RepeatingDoneCount >= task.RepeatingNeededCount) { task.IsCompleted = true; } task.ExecutionValue = task.ExecutionValue == task.RepeatingAValue ? task.RepeatingBValue : task.RepeatingAValue; if (!task.IsCompleted) { task.ExecutionDate = DateTime.Now.AddMilliseconds(task.RepeatingInterval); } } UpdateTaskInDb(task); Outputs[0].Value = task.ExecutionValue; }
public bool UpdateTask(UITimerTask task) { UITimerTask oldTask = GetTask(task.Id); if (oldTask == null) { return(false); } //oldTask.NodeId = task.NodeId; oldTask.Description = task.Description; oldTask.Enabled = task.Enabled; oldTask.ExecutionDate = task.ExecutionDate; oldTask.ExecutionValue = task.ExecutionValue; oldTask.IsCompleted = task.IsCompleted; oldTask.IsRepeating = task.IsRepeating; oldTask.RepeatingAValue = task.RepeatingAValue; oldTask.RepeatingBValue = task.RepeatingBValue; oldTask.RepeatingDoneCount = task.RepeatingDoneCount; oldTask.RepeatingInterval = task.RepeatingInterval; oldTask.RepeatingNeededCount = task.RepeatingNeededCount; oldTask.RepeatingInterval = task.RepeatingInterval; if (oldTask.IsRepeating && oldTask.ExecutionValue != oldTask.RepeatingBValue && oldTask.ExecutionValue != oldTask.RepeatingAValue) { oldTask.ExecutionValue = oldTask.RepeatingBValue; } UpdateTaskInDb(oldTask); return(true); }
private void UpdateTaskInDb(UITimerTask task) { NodeData data = new NodeData { DateTime = DateTime.Now, Id = task.Id, NodeId = Id, Value = JsonConvert.SerializeObject(task) }; UpdateNodeData(data); }
public bool ExecuteNowTask(int id) { UITimerTask oldTask = GetTask(id); if (oldTask == null) { return(false); } Execute(oldTask); return(true); }
private void GetTasksFromDB() { tasks = new List <UITimerTask>(); List <NodeData> data = GetAllNodeData(); foreach (var nodeData in data) { UITimerTask task = JsonConvert.DeserializeObject <UITimerTask>(nodeData.Value); task.Id = nodeData.Id; tasks.Add(task); } }
public ActionResult New(UITimerTask task) { if (engine == null) return View("Error", ERROR_MESSAGE); UiTimerNode node = engine.GetNode(task.NodeId) as UiTimerNode; if (node == null) return HttpNotFound(); node.AddTask(task); return RedirectToAction("Tasks", new { id = task.NodeId}); }
public bool AddTask(UITimerTask task) { if (task.IsRepeating) { task.ExecutionValue = task.RepeatingBValue; } AddTaskToDb(task); tasks.Add(task); AbortExecuting(); return(true); }
public bool RemoveTask(int id) { UITimerTask oldTask = GetTask(id); if (oldTask == null) { return(false); } tasks.Remove(oldTask); AbortExecuting(); RemoveTaskFromDb(oldTask.Id); return(true); }
public ActionResult New(string id) { if (engine == null) return View("Error", ERROR_MESSAGE); UiTimerNode node = engine.GetNode(id) as UiTimerNode; if (node == null) return HttpNotFound(); ViewBag.NodeId = node.Id; ViewBag.Name = node.Settings["Name"].Value; UITimerTask task = new UITimerTask { NodeId = id, ExecutionDate = DateTime.Now, RepeatingInterval = 1000, Enabled = true }; return View(task); }
private void AddTaskToDb(UITimerTask task) { int id = AddNodeDataImmediately(JsonConvert.SerializeObject(task)); task.Id = id; }
public ActionResult Edit(UITimerTask task,int TaskId) { if (engine == null) return View("Error", ERROR_MESSAGE); task.Id = TaskId; //pasing id dont work! UiTimerNode node = engine.GetNode(task.NodeId) as UiTimerNode; if (node == null) return HttpNotFound(); node.UpdateTask(task); return RedirectToAction("Tasks", new { id = task.NodeId }); }
public bool UpdateTask(UITimerTask task) { UITimerTask oldTask = GetTask(task.Id); if (oldTask == null) return false; //oldTask.NodeId = task.NodeId; oldTask.Description = task.Description; oldTask.Enabled = task.Enabled; oldTask.ExecutionDate = task.ExecutionDate; oldTask.ExecutionValue = task.ExecutionValue; oldTask.IsCompleted = task.IsCompleted; oldTask.IsRepeating = task.IsRepeating; oldTask.RepeatingAValue = task.RepeatingAValue; oldTask.RepeatingBValue = task.RepeatingBValue; oldTask.RepeatingDoneCount = task.RepeatingDoneCount; oldTask.RepeatingInterval = task.RepeatingInterval; oldTask.RepeatingNeededCount = task.RepeatingNeededCount; oldTask.RepeatingInterval = task.RepeatingInterval; if (oldTask.IsRepeating && oldTask.ExecutionValue != oldTask.RepeatingBValue && oldTask.ExecutionValue != oldTask.RepeatingAValue) oldTask.ExecutionValue = oldTask.RepeatingBValue; UpdateTaskInDb(oldTask); return true; }
public bool AddTask(UITimerTask task) { if (task.IsRepeating) task.ExecutionValue = task.RepeatingBValue; AddTaskToDb(task); tasks.Add(task); AbortExecuting(); return true; }
private void Execute(UITimerTask task) { task.RepeatingDoneCount++; if (!task.IsRepeating) task.IsCompleted = true; else { if (task.RepeatingNeededCount != 0 && task.RepeatingDoneCount >= task.RepeatingNeededCount) task.IsCompleted = true; task.ExecutionValue = task.ExecutionValue == task.RepeatingAValue ? task.RepeatingBValue : task.RepeatingAValue; if (!task.IsCompleted) task.ExecutionDate = DateTime.Now.AddMilliseconds(task.RepeatingInterval); } UpdateTaskInDb(task); Outputs[0].Value = task.ExecutionValue; }