AddSchedulerLogEntry() public static method

public static AddSchedulerLogEntry ( string showName, string logEntry ) : void
showName string
logEntry string
return void
Ejemplo n.º 1
0
        public void OnBackgroundActionComplete(object sender, EventArgs e)
        {
            Shows.Action action = (sender as Shows.Action);
            action.ActionComplete -= OnBackgroundActionComplete;
            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);
            }
        }
Ejemplo n.º 2
0
        public void OnStartupActionComplete(object sender, EventArgs e)
        {
            var action = (sender as Shows.Action);

            if (action != null)
            {
                action.ActionComplete -= OnStartupActionComplete;
                RunningActions.Remove(action);

                ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Startup action complete: " + action.ShowItem.Name);
                action.Dispose();
            }
            ExecuteNextStartupItem();
        }
Ejemplo n.º 3
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();
     }
 }
Ejemplo n.º 4
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();
     }
 }
Ejemplo n.º 5
0
        public void Stop(bool graceful)
        {
            if (tokenSourcePreProcess != null && tokenSourcePreProcess.Token.CanBeCanceled)
            {
                tokenSourcePreProcess.Cancel(false);
            }
            if (tokenSourcePreProcessAll != null && tokenSourcePreProcessAll.Token.CanBeCanceled)
            {
                tokenSourcePreProcessAll.Cancel(false);
            }

            if (graceful)
            {
                State = StateType.Shutdown;
                ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Show stopping gracefully");
            }
            else
            {
                State = StateType.Waiting;

                ItemQueue.Clear();

                Action[] actions;
                lock (_actionLock)
                {
                    actions = RunningActions.ToArray();
                }

                foreach (var action in actions)
                {
                    ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Stopping action: " + action.ShowItem.Name);
                    action.Stop();
                }

                if (Show != null)
                {
                    Show.ReleaseAllActions();
                    ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Show stopped immediately");
                }
                else
                {
                    ScheduleExecutor.AddSchedulerLogEntry("No show selected", "Nothing to stop.");
                }
            }
        }
Ejemplo n.º 6
0
        public void BeginShutdown()
        {
            if (Show != null)
            {
                ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Starting shutdown");

                StopBackground();
                StopSequential();
                ItemQueue.Clear();

                State = StateType.Shutdown;
                foreach (ShowItem item in Show.GetItems(Shows.ShowItemType.Shutdown))
                {
                    LogScheduleInfoEntry(string.Format("BeginShutdown: Enqueue: {0}", item.Name));
                    ItemQueue.Enqueue(item);
                }

                ExecuteNextShutdownItem();
            }
        }
Ejemplo n.º 7
0
        private void PreProcessActionTask()
        {
            // Pre-Process all the actions to fill up our memory

            //Show.GetItems(Shows.ShowItemType.All).AsParallel().WithCancellation(tokenSourcePreProcessAll.Token).ForAll(
            //	item => {
            foreach (ShowItem item in Show.GetItems(ShowItemType.All))
            {
                ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Pre-processing: " + item.Name);
                var action = item.GetAction();

                if (!action.PreProcessingCompleted)
                {
                    action.PreProcess(tokenSourcePreProcessAll);
                }
                //if (tokenSourcePreProcessAll != null && tokenSourcePreProcessAll.IsCancellationRequested)
                //	return;
                //};
            }
        }
Ejemplo n.º 8
0
        public void Start(bool manuallyStarted)
        {
            State = StateType.Running;

            InProcessEndTime = EndTime;

            ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Show started");

            // Do this in a task so we don't stop Vixen while pre-processing!
            if (tokenSourcePreProcessAll == null || tokenSourcePreProcessAll.IsCancellationRequested)
            {
                tokenSourcePreProcessAll = new CancellationTokenSource();
            }

            var preProcessTask = new Task(a => PreProcessActionTask(), tokenSourcePreProcessAll.Token);

            preProcessTask.ContinueWith(task => BeginStartup(), tokenSourcePreProcessAll.Token);

            preProcessTask.Start();
        }
Ejemplo n.º 9
0
        public void BeginShutdown()
        {
            if (Show != null)
            {
                ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Starting shutdown");

                StopBackground();

                ItemQueue.Clear();

                State = StateType.Shutdown;
                foreach (Shows.ShowItem item in Show.GetItems(Shows.ShowItemType.Shutdown))
                {
                    ScheduleExecutor.Logging.Info("BeginShutdown: Enqueue: " + item.Name);
                    ItemQueue.Enqueue(item);
                }

                ExecuteNextShutdownItem();
            }
        }
Ejemplo n.º 10
0
        public void Stop(bool graceful)
        {
            if (tokenSourcePreProcess != null && tokenSourcePreProcess.Token.CanBeCanceled)
            {
                tokenSourcePreProcess.Cancel(false);
            }
            if (tokenSourcePreProcessAll != null && tokenSourcePreProcessAll.Token.CanBeCanceled)
            {
                tokenSourcePreProcessAll.Cancel(false);
            }

            if (graceful)
            {
                State = StateType.Shutdown;
                ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Show stopping gracefully");
            }
            else
            {
                State = StateType.Waiting;
                int runningCount = RunningActions.Count();

                ItemQueue.Clear();
                for (int i = 0; i < runningCount; i++)
                {
                    ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Stopping action: " + RunningActions[i].ShowItem.Name);
                    RunningActions[i].Stop();
                }
                if (Show != null)
                {
                    Show.ReleaseAllActions();
                    ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Show stopped immediately");
                }
                else
                {
                    ScheduleExecutor.AddSchedulerLogEntry("No show selected", "Nothing to stop.");
                }
            }
        }
Ejemplo n.º 11
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);
                    }
                }
            }
        }
Ejemplo n.º 12
0
 public void Shutdown()
 {
     ScheduleExecutor.AddSchedulerLogEntry(Show.Name, "Shutdown Requested");
     State = StateType.Shutdown;
 }