示例#1
0
        /// <summary>
        /// Adds a media item to the Black list. Adds Locally and to the WebService
        /// </summary>
        /// <param name="id">The Media ID</param>
        /// <param name="type">The BlackListType, either All (to blacklist on all displays) or Single (to blacklist only on this display)</param>
        /// <param name="reason">The reason for the blacklist</param>
        public void Add(string id, BlackListType type, string reason)
        {
            // Do some validation
            if (reason == "") reason = "No reason provided";
            
            int mediaId;
            if (!int.TryParse(id, out mediaId))
            {
                System.Diagnostics.Trace.WriteLine(String.Format("Currently can only append Integer media types. Id {0}", id), "BlackList - Add");
            }

            // Send to the webservice
            xmds1 = new R23SignageClient.xmds.xmds();
            xmds1.BlackListCompleted += new R23SignageClient.xmds.BlackListCompletedEventHandler(xmds1_BlackListCompleted);

            xmds1.BlackListAsync(ApplicationSettings.Default.ServerKey, hardwareKey.Key, mediaId, type.ToString(), reason, ApplicationSettings.Default.Version);

            // Add to the local list
            AddLocal(id);
        }
示例#2
0
        public RequiredFiles()
        {
            RequiredFileList = new Collection<RequiredFile>();

            // Create a webservice call
            _report = new R23SignageClient.xmds.xmds();

            // Start up the Xmds Service Object
            _report.Credentials = null;
            _report.Url = ApplicationSettings.Default.R23SignageClient_xmds_xmds;
            _report.UseDefaultCredentials = false;
        }
示例#3
0
        /// <summary>
        /// Change to the next layout
        /// </summary>
        private void ChangeToNextLayout(string layoutPath)
        {
            try
            {
                SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS);
            }
            catch
            {
                Trace.WriteLine(new LogMessage("MainForm - ChangeToNextLayout", "Unable to set Thread Execution state"), LogType.Info.ToString());
            }

            try
            {
                // Destroy the Current Layout
                try
                {
                    DestroyLayout();
                }
                catch (Exception e)
                {
                    // Force collect all controls
                    foreach (System.Windows.Forms.Control control in Controls)
                    {
                        control.Dispose();
                        Controls.Remove(control);
                    }

                    Trace.WriteLine(new LogMessage("MainForm - ChangeToNextLayout", "Destroy Layout Failed. Exception raised was: " + e.Message), LogType.Error.ToString());
                    throw e;
                }

                // Prepare the next layout
                try
                {
                    PrepareLayout(layoutPath);
                    _clientInfoForm.CurrentLayoutId = layoutPath;

                }
                catch (Exception e)
                {
                    DestroyLayout();
                    Trace.WriteLine(new LogMessage("MainForm - ChangeToNextLayout", "Prepare Layout Failed. Exception raised was: " + e.Message), LogType.Error.ToString());
                    throw e;
                }

                // Do we need to notify?
                try
                {
                    if (ApplicationSettings.Default.SendCurrentLayoutAsStatusUpdate)
                    {
                        using (xmds.xmds statusXmds = new xmds.xmds())
                        {
                            statusXmds.Url = ApplicationSettings.Default.R23SignageClient_xmds_xmds;
                            statusXmds.NotifyStatusAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, "{\"currentLayoutId\":" + _layoutId + "}");
                        }
                    }
                }
                catch (Exception e)
                {
                    Trace.WriteLine(new LogMessage("MainForm - ChangeToNextLayout", "Notify Status Failed. Exception raised was: " + e.Message), LogType.Error.ToString());
                    throw e;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(new LogMessage("MainForm - ChangeToNextLayout", "Layout Change to " + layoutPath + " failed. Exception raised was: " + ex.Message), LogType.Error.ToString());
                
                ShowSplashScreen();

                // In 10 seconds fire the next layout?
                System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                timer.Interval = 10000;
                timer.Tick += new EventHandler(splashScreenTimer_Tick);

                // Start the timer
                timer.Start();
            }

            // We have finished changing the layout
            _changingLayout = false;
        }
示例#4
0
        public override void RenderMedia()
        {
            if (!string.IsNullOrEmpty(_code))
            {
                // Stored command
                bool success;

                try
                {
                    Command command = Command.GetByCode(_code);
                    success = command.Run();
                }
                catch (Exception e)
                {
                    Trace.WriteLine(new LogMessage("ScheduleManager - Run", "Cannot run Command: " + e.Message), LogType.Error.ToString());
                    success = false;
                }

                // Notify the state of the command (success or failure)
                using (xmds.xmds statusXmds = new xmds.xmds())
                {
                    statusXmds.Url = ApplicationSettings.Default.R23SignageClient_xmds_xmds;
                    statusXmds.NotifyStatusAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, "{\"lastCommandSuccess\":" + success + "}");
                }
            }
            else
            {
                // shell command

                // Is this module enabled?
                if (ApplicationSettings.Default.EnableShellCommands)
                {
                    // Check to see if we have an allow list
                    if (!string.IsNullOrEmpty(ApplicationSettings.Default.ShellCommandAllowList))
                    {
                        // Array of allowed commands
                        string[] allowedCommands = ApplicationSettings.Default.ShellCommandAllowList.Split(',');

                        // Check we are allowed to execute the command
                        bool found = false;

                        foreach (string allowedCommand in allowedCommands)
                        {
                            if (_command.StartsWith(allowedCommand))
                            {
                                found = true;
                                ExecuteShellCommand();
                                break;
                            }
                        }

                        if (!found)
                            Trace.WriteLine(new LogMessage("ShellCommand - RenderMedia", "Shell Commands not in allow list: " + ApplicationSettings.Default.ShellCommandAllowList), LogType.Error.ToString());
                    }
                    else
                    {
                        // All commands are allowed
                        ExecuteShellCommand();
                    }
                }
                else
                {
                    Trace.WriteLine(new LogMessage("ShellCommand - RenderMedia", "Shell Commands are disabled"), LogType.Error.ToString());
                }
            }

            // All shell commands have a duration of 1
            base.RenderMedia();
        }