예제 #1
0
        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;
        }
예제 #2
0
        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);
        }
예제 #3
0
        private void UpdateTaskInDb(UITimerTask task)
        {
            NodeData data = new NodeData
            {
                DateTime = DateTime.Now,
                Id       = task.Id,
                NodeId   = Id,
                Value    = JsonConvert.SerializeObject(task)
            };

            UpdateNodeData(data);
        }
예제 #4
0
        public bool ExecuteNowTask(int id)
        {
            UITimerTask oldTask = GetTask(id);

            if (oldTask == null)
            {
                return(false);
            }

            Execute(oldTask);
            return(true);
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        private void UpdateTaskInDb(UITimerTask task)
        {
            NodeData data = new NodeData
            {
                DateTime = DateTime.Now,
                Id = task.Id,
                NodeId = Id,
                Value = JsonConvert.SerializeObject(task)
            };

            UpdateNodeData(data);
        }
        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});
        }
예제 #8
0
        public bool AddTask(UITimerTask task)
        {
            if (task.IsRepeating)
            {
                task.ExecutionValue = task.RepeatingBValue;
            }

            AddTaskToDb(task);

            tasks.Add(task);
            AbortExecuting();

            return(true);
        }
예제 #9
0
        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);
        }
예제 #11
0
        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 });
        }
예제 #13
0
 private void AddTaskToDb(UITimerTask task)
 {
     int id = AddNodeDataImmediately(JsonConvert.SerializeObject(task));
     task.Id = id;
 }
예제 #14
0
        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;
        }
예제 #15
0
        public bool AddTask(UITimerTask task)
        {
            if (task.IsRepeating)
                task.ExecutionValue = task.RepeatingBValue;

            AddTaskToDb(task);

            tasks.Add(task);
            AbortExecuting();

            return true;
        }
예제 #16
0
        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;
        }