Example #1
0
        /// <summary>
        /// XMR Subscriber Action
        /// </summary>
        void _xmrSubscriber_OnAction(Action.PlayerActionInterface action)
        {
            switch (action.GetActionName())
            {
            case RevertToSchedulePlayerAction.Name:
                _scheduleManager.ClearLayoutChangeActions();
                _scheduleManager.RunNow();
                break;

            case "collectNow":
                // Run all of the various agents
                wakeUpXmds();
                break;

            case LayoutChangePlayerAction.Name:
                // Add to a collection of Layout Change events
                if (((LayoutChangePlayerAction)action).changeMode == "replace")
                {
                    _scheduleManager.ReplaceLayoutChangeActions(((LayoutChangePlayerAction)action));
                }
                else
                {
                    _scheduleManager.AddLayoutChangeAction(((LayoutChangePlayerAction)action));
                }

                // Assess the schedule now, or later?
                if (((LayoutChangePlayerAction)action).IsDownloadRequired())
                {
                    // Run XMDS to download the required layouts
                    // need to notify again once a complete download has occurred.
                    wakeUpXmds();
                }
                else
                {
                    // Reassess the schedule
                    _scheduleManager.RunNow();
                }

                break;

            case OverlayLayoutPlayerAction.Name:
                // Add to a collection of Layout Change events
                _scheduleManager.AddOverlayLayoutAction(((OverlayLayoutPlayerAction)action));

                // Assess the schedule now, or later?
                if (((OverlayLayoutPlayerAction)action).IsDownloadRequired())
                {
                    // Run XMDS to download the required layouts
                    // need to notify again once a complete download has occurred.
                    wakeUpXmds();
                }
                else
                {
                    // Reassess the schedule
                    _scheduleManager.RunNow();
                }

                break;
            }
        }
        /// <summary>
        /// A layout file has changed
        /// </summary>
        /// <param name="layoutPath"></param>
        private void LayoutFileModified(string layoutPath)
        {
            Trace.WriteLine(new LogMessage("Schedule - LayoutFileModified", "Layout file changed: " + layoutPath), LogType.Info.ToString());

            // Tell the schedule to refresh
            _scheduleManager.RefreshSchedule = true;

            // Are we set to expire modified layouts? If not then just return as if
            // nothing had happened.
            if (!ApplicationSettings.Default.ExpireModifiedLayouts)
            {
                return;
            }

            // If the layout that got changed is the current layout, move on
            try
            {
                if (_layoutSchedule[_currentLayout].layoutFile == ApplicationSettings.Default.LibraryPath + @"\" + layoutPath)
                {
                    // What happens if the action of downloading actually invalidates this layout?
                    if (!_cacheManager.IsValidPath(layoutPath))
                    {
                        Trace.WriteLine(new LogMessage("Schedule - LayoutFileModified", "The current layout is now invalid, refreshing the current schedule."), LogType.Audit.ToString());

                        // We should not force a change and we should tell the schedule manager to run now
                        _scheduleManager.RunNow();
                    }
                    else
                    {
                        Trace.WriteLine(new LogMessage("Schedule - LayoutFileModified", "Forcing the current layout to change: " + layoutPath), LogType.Audit.ToString());

                        // Force a change
                        _forceChange = true;

                        // Run the next layout
                        NextLayout();
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(new LogMessage("fileCollector_LayoutFileChanged", String.Format("Unable to determine current layout with exception {0}", ex.Message)), LogType.Error.ToString());
            }
        }