Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 /// <param name="forceRun">specifies whether a schedule should be triggered forcefully in case system was down when schedule was due (true).</param>
 /// <param name="wakeup">specifies whether the system should be woken up from standby for this task's schedule (false).</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence, DateTime expires, bool forceRun, bool wakeup)
 {
   _owner = owner;
   _schedule = schedule;
   _occurrence = occurrence;
   _expires = expires;
   _forceRun = forceRun;
   _wakeup = wakeup;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 /// <param name="forceRun">specifies whether a schedule should be triggered forcefully in case system was down when schedule was due (true).</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence, DateTime expires, bool forceRun) :
     this(owner, schedule, occurrence, expires, forceRun, false) { }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 /// <param name="expires">specifies when the task's schedule should expire.</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence, DateTime expires) :
     this(owner, schedule, occurrence, expires, true) { }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new task for the <see cref="TaskScheduler"/> with given <see cref="Schedule"/> as schedule.
 /// </summary>
 /// <param name="owner">specifies the owner of this task.</param>
 /// <param name="schedule">specifies the schedule of this task.</param>
 /// <param name="occurrence">specifies the occurrence of this task.</param>
 public Task(string owner, Schedule schedule, Occurrence occurrence) : this(owner, schedule, occurrence, DateTime.MaxValue) { }
Ejemplo n.º 5
0
    protected void ScheduleImports()
    {
      lock (_syncObj)
      {
        ITaskScheduler scheduler = ServiceRegistration.Get<ITaskScheduler>();
        ISettingsManager settingsManager = ServiceRegistration.Get<ISettingsManager>();
        _importerTaskId = _settings.Settings.ImporterScheduleId;

        // Allow removal of existing import tasks
        if (!_settings.Settings.EnableAutoRefresh) 
        {
          if (_importerTaskId != Guid.Empty)
          {
            scheduler.RemoveTask(_importerTaskId);
            _importerTaskId = _settings.Settings.ImporterScheduleId = Guid.Empty;
            _ignoreChange = true; // Do not react on next setting's change message!
            settingsManager.Save(_settings.Settings);
          }
          return;
        }

        Schedule schedule = new Schedule
          {
            Hour = (int) _settings.Settings.ImporterStartTime,
            Minute = (int) ((_settings.Settings.ImporterStartTime - (int) _settings.Settings.ImporterStartTime) * 60),
            Day = -1,
            Type = ScheduleType.TimeBased
          };
        
        Task importTask = new Task("ImporterWorker", schedule, Occurrence.Repeat, DateTime.MaxValue, true, true);
        if (_importerTaskId == Guid.Empty)
        {
          _importerTaskId = scheduler.AddTask(importTask);
          _settings.Settings.ImporterScheduleId = _importerTaskId;
          _ignoreChange = true; // Do not react on next setting's change message!
          settingsManager.Save(_settings.Settings);
        }
        else
          scheduler.UpdateTask(_importerTaskId, importTask);
      }
    }
Ejemplo n.º 6
0
    private void ScheduleRegularRefreshImports()
    {
      var scheduler = ServiceRegistration.Get<ITaskScheduler>();
      var settingsManager = ServiceRegistration.Get<ISettingsManager>();
      _importerTaskId = _settings.Settings.ImporterScheduleId;

      // Allow removal of existing import tasks
      if (!_settings.Settings.EnableAutoRefresh)
      {
        if (_importerTaskId != Guid.Empty)
        {
          scheduler.RemoveTask(_importerTaskId);
          _importerTaskId = _settings.Settings.ImporterScheduleId = Guid.Empty;
          settingsManager.Save(_settings.Settings);
        }
        return;
      }

      var schedule = new Schedule
      {
        Hour = (int)_settings.Settings.ImporterStartTime,
        Minute = (int)((_settings.Settings.ImporterStartTime - (int)_settings.Settings.ImporterStartTime) * 60),
        Day = -1,
        Type = ScheduleType.TimeBased
      };

      var importTask = new Common.TaskScheduler.Task("ImporterWorker", schedule, Occurrence.Repeat, DateTime.MaxValue, true, true);
      if (_importerTaskId == Guid.Empty)
      {
        _importerTaskId = scheduler.AddTask(importTask);
        _settings.Settings.ImporterScheduleId = _importerTaskId;
        settingsManager.Save(_settings.Settings);
      }
      else
        scheduler.UpdateTask(_importerTaskId, importTask);
    }