コード例 #1
0
ファイル: Task.cs プロジェクト: joconno4/MediaPortal-2
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> based on the given task.
 /// Used for the <see cref="ICloneable"/> implementation.
 /// </summary>
 /// <param name="task">The new task should be based upon.</param>
 public Task(Task task)
 {
   _taskID = task.ID;
   _owner = task.Owner;
   _schedule.Minute = task.Schedule.Minute;
   _schedule.Hour = task.Schedule.Hour;
   _schedule.Day = task.Schedule.Day;
   _schedule.Interval = task.Schedule.Interval;
   _schedule.Type = task.Schedule.Type;
   _expires = task.Expires;
   _forceRun = task.ForceRun;
   _wakeup = task.WakeupSystem;
 }
コード例 #2
0
 public Guid AddTask(Task newTask)
 {
   lock (_syncObj)
   {
     newTask.ID = Guid.NewGuid();
     _settings.TaskCollection.Add(newTask);
     SaveChanges(false);
   }
   return newTask.ID;
 }
コード例 #3
0
 public void UpdateTask(Guid taskId, Task updatedTask)
 {
   lock (_syncObj)
   {
     updatedTask.ID = taskId;
     _settings.TaskCollection.Replace(taskId, updatedTask);
     SaveChanges(false);
     TaskSchedulerMessaging.SendTaskSchedulerMessage(TaskSchedulerMessaging.MessageType.CHANGED, updatedTask);
   }
 }
コード例 #4
0
 /// <summary>
 /// Handles expired tasks: Sends out a message that a particular task is expired, removes the task from the
 /// registered task collection and sends out a message that the task is deleted. This method gets called
 /// from the DoWork() method.
 /// </summary>
 /// <param name="task">Task to expire</param>
 private void ExpireTask(Task task)
 {
   Task tc = (Task) task.Clone();
   TaskSchedulerMessaging.SendTaskSchedulerMessage(TaskSchedulerMessaging.MessageType.EXPIRED, tc);
   _settings.TaskCollection.Remove(task);
   TaskSchedulerMessaging.SendTaskSchedulerMessage(TaskSchedulerMessaging.MessageType.DELETED, tc);
   SaveChanges(false);
 }
コード例 #5
0
 /// <summary>
 /// Handles processing of due tasks. Sends out a message that a task is due, updates the tasks properties and
 /// removes the task if it was scheduled to run only once. This method gets called from the DoWork() method.
 /// </summary>
 /// <param name="task">Task to process.</param>
 private void ProcessTask(Task task)
 {
   Task tc = (Task) task.Clone();
   TaskSchedulerMessaging.SendTaskSchedulerMessage(TaskSchedulerMessaging.MessageType.DUE, tc);
   task.LastRun = task.NextRun;
   if (task.Occurrence == Occurrence.Once)
   {
     _settings.TaskCollection.Remove(task);
     TaskSchedulerMessaging.SendTaskSchedulerMessage(TaskSchedulerMessaging.MessageType.DELETED, tc);
   }
 }
コード例 #6
0
    public const string TASK = "Task"; // Stores the task of this message

    /// <summary>
    /// Sends a message in the <see cref="CHANNEL"/>.
    /// </summary>
    /// <param name="type">The type of the message to send.</param>
    /// <param name="task">The task of the message to send.</param>
    public static void SendTaskSchedulerMessage(MessageType type, Task task)
    {
      SystemMessage msg = new SystemMessage(type);
      msg.MessageData[TASK] = task;
      ServiceRegistration.Get<IMessageBroker>().Send(CHANNEL, msg);
    }
コード例 #7
0
ファイル: TaskScheduler.cs プロジェクト: davinx/MediaPortal-2
 public void UpdateTask(Guid taskId, Task updatedTask)
 {
   lock (_syncObj)
   {
     updatedTask.ID = taskId;
     ServiceRegistration.Get<ILogger>().Debug("TaskScheduler: UpdateTask: {0}", updatedTask);
     _settings.TaskCollection.Replace(taskId, updatedTask);
     SaveChanges(false);
     TaskSchedulerMessaging.SendTaskSchedulerMessage(TaskSchedulerMessaging.MessageType.CHANGED, updatedTask);
   }
 }
コード例 #8
0
ファイル: TaskScheduler.cs プロジェクト: davinx/MediaPortal-2
 public Guid AddTask(Task newTask)
 {
   lock (_syncObj)
   {
     newTask.ID = Guid.NewGuid();
     ServiceRegistration.Get<ILogger>().Debug("TaskScheduler: AddTask: {0}", newTask);
     _settings.TaskCollection.Add(newTask);
     SaveChanges(false);
   }
   return newTask.ID;
 }
コード例 #9
0
ファイル: TaskScheduler.cs プロジェクト: davinx/MediaPortal-2
 /// <summary>
 /// Handles processing of due tasks. Sends out a message that a task is due, updates the tasks properties and
 /// removes the task if it was scheduled to run only once. This method gets called from the DoWork() method.
 /// </summary>
 /// <param name="task">Task to process.</param>
 private void ProcessTask(Task task)
 {
   ServiceRegistration.Get<ILogger>().Debug("TaskScheduler: ProcessTask: {0}", task.ToString());
   Task tc = (Task) task.Clone();
   TaskSchedulerMessaging.SendTaskSchedulerMessage(TaskSchedulerMessaging.MessageType.DUE, tc);
   task.LastRun = task.NextRun;
   if (task.Occurrence == Occurrence.Once)
   {
     _settings.TaskCollection.Remove(task);
     TaskSchedulerMessaging.SendTaskSchedulerMessage(TaskSchedulerMessaging.MessageType.DELETED, tc);
   }
 }
コード例 #10
0
ファイル: TaskScheduler.cs プロジェクト: davinx/MediaPortal-2
 /// <summary>
 /// Handles expired tasks: Sends out a message that a particular task is expired, removes the task from the
 /// registered task collection and sends out a message that the task is deleted. This method gets called
 /// from the DoWork() method.
 /// </summary>
 /// <param name="task">Task to expire</param>
 private void ExpireTask(Task task)
 {
   ServiceRegistration.Get<ILogger>().Debug("TaskScheduler: ExpireTask: {0}", task.ToString());
   Task tc = (Task) task.Clone();
   TaskSchedulerMessaging.SendTaskSchedulerMessage(TaskSchedulerMessaging.MessageType.EXPIRED, tc);
   _settings.TaskCollection.Remove(task);
   TaskSchedulerMessaging.SendTaskSchedulerMessage(TaskSchedulerMessaging.MessageType.DELETED, tc);
   SaveChanges(false);
 }