Esempio n. 1
0
 public void ExecuteBackgroundAction(Shows.Action action)
 {
     if (State == StateType.Running)
     {
         action.ActionComplete += OnBackgroundActionComplete;
         ExecuteAction(action);
     }
 }
Esempio n. 2
0
 public void OnShutdownActionComplete(object sender, EventArgs e)
 {
     Shows.Action action = (sender as Shows.Action);
     action.ActionComplete -= OnShutdownActionComplete;
     lock (_actionLock)
     {
         RunningActions.Remove(action);
     }
     ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Shutdown action complete: " + action.ShowItem.Name);
     ExecuteNextShutdownItem();
 }
Esempio n. 3
0
 private void StopSequential()
 {
     foreach (ShowItem item in Show.GetItems(ShowItemType.Sequential))
     {
         Shows.Action action = item.GetAction();
         if (action.IsRunning)
         {
             action.Stop();
         }
         action.Dispose();
     }
 }
Esempio n. 4
0
 public void BeginBackground()
 {
     if (Show != null)
     {
         foreach (ShowItem item in Show.GetItems(ShowItemType.Background))
         {
             Shows.Action action = item.GetAction();
             BackgroundActions.Add(action);
             ExecuteBackgroundAction(action);
         }
     }
 }
Esempio n. 5
0
 public void OnSequentialActionComplete(object sender, EventArgs e)
 {
     Shows.Action action = (sender as Shows.Action);
     action.ActionComplete -= OnSequentialActionComplete;
     lock (_actionLock)
     {
         RunningActions.Remove(action);
     }
     ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Sequential action complete: " + action.ShowItem.Name);
     if (!StartShutdownIfRequested())
     {
         LogScheduleInfoEntry("OnSequentialActionComplete: Shutdown was NOT requested");
         ExecuteNextSequentialItem();
     }
 }
Esempio n. 6
0
        public void OnBackgroundActionComplete(object sender, EventArgs e)
        {
            Shows.Action action = (sender as Shows.Action);
            action.ActionComplete -= OnBackgroundActionComplete;
            lock (_actionLock)
            {
                RunningActions.Remove(action);
            }
            ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Background action complete: " + action.ShowItem.Name);

            // Run it again and again and again and again and again and again and again and...
            if (!CheckForShutdown())
            {
                ExecuteBackgroundAction(action);
            }
        }
Esempio n. 7
0
 public void ExecuteNextShutdownItem()
 {
     if (ItemQueue.Any())
     {
         _currentItem = ItemQueue.Dequeue();
         Shows.Action action = _currentItem.GetAction();
         action.ActionComplete += OnShutdownActionComplete;
         ExecuteAction(action);
         // Otherwise, the show is done :(
     }
     else
     {
         State = StateType.Waiting;
         ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Show complete");
         Show.ReleaseAllActions();
     }
 }
Esempio n. 8
0
 public void ExecuteNextStartupItem()
 {
     if (State == StateType.Running)
     {
         // Do we have startup items to run?
         if (ItemQueue.Any())
         {
             _currentItem = ItemQueue.Dequeue();
             Shows.Action action = _currentItem.GetAction();
             action.ActionComplete += OnStartupActionComplete;
             ExecuteAction(action);
         }
         // Otherwise, move on to the sequential and background items
         else
         {
             BeginSequential();
             BeginBackground();
         }
     }
 }
Esempio n. 9
0
 public void ExecuteNextSequentialItem()
 {
     LogScheduleInfoEntry("ExecuteNextSequentialItem");
     if (State == StateType.Running)
     {
         if (ItemQueue.Any())
         {
             LogScheduleInfoEntry("ExecuteNextSequentialItem: Dequeue next item");
             _currentItem = ItemQueue.Dequeue();
             Shows.Action action = _currentItem.GetAction();
             action.ActionComplete += OnSequentialActionComplete;
             ExecuteAction(action);
         }
         else
         {
             LogScheduleInfoEntry("ExecuteNextSequentialItem: Nothing left in the queue. Restarting the queue.");
             // Restart the queue
             BeginSequential();
         }
     }
 }
Esempio n. 10
0
        private void ExecuteAction(Shows.Action action)
        {
            LogScheduleInfoEntry(string.Format("ExecuteAction: {0} with state of {1}", action.ShowItem.Name, State));

            if (State != StateType.Waiting)
            {
                if (!action.PreProcessingCompleted)
                {
                    ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Pre-processing action: " + action.ShowItem.Name);

                    // Do this in a task so we don't stop Vixen while pre-processing!
                    tokenSourcePreProcess = new CancellationTokenSource();
                    Task preProcessTask = new Task(() => action.PreProcess(), tokenSourcePreProcess.Token);
                    preProcessTask.ContinueWith(task =>
                    {
                        ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Starting action: " + action.ShowItem.Name);
                        action.Execute();
                        lock (_actionLock)
                        {
                            RunningActions.Add(action);
                        }
                    }
                                                );

                    preProcessTask.Start();
                }
                else
                {
                    ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Starting action: " + action.ShowItem.Name);
                    action.Execute();
                    lock (_actionLock)
                    {
                        RunningActions.Add(action);
                    }
                }
            }
        }