/// <summary> /// Start a Layout /// </summary> /// <param name="layout"></param> private void StartLayout(Layout layout) { Debug.WriteLine("StartLayout: Starting...", "MainWindow"); // Match Background Colors this.Background = layout.BackgroundColor; // Add this Layout to our controls this.Scene.Children.Add(layout); // Start if (layout.IsPaused) { Debug.WriteLine("StartLayout: Resuming paused Layout", "MainWindow"); layout.Resume(); } else if (!layout.IsRunning) { Debug.WriteLine("StartLayout: Starting Layout", "MainWindow"); layout.Start(); } else { Trace.WriteLine(new LogMessage("MainForm", "StartLayout: Layout already running."), LogType.Error.ToString()); return; } Debug.WriteLine("StartLayout: Started Layout", "MainWindow"); // Update client info ClientInfo.Instance.CurrentLayoutId = layout.ScheduleItem.id; ClientInfo.Instance.CurrentlyPlaying = layout.ScheduleItem.layoutFile; ClientInfo.Instance.ControlCount = this.Scene.Children.Count; // Do we need to notify? try { if (ApplicationSettings.Default.SendCurrentLayoutAsStatusUpdate) { using (xmds.xmds statusXmds = new xmds.xmds()) { statusXmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=notifyStatus"; statusXmds.NotifyStatusAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, "{\"currentLayoutId\":" + this.currentLayout.ScheduleItem.id + "}"); } } } catch (Exception e) { Trace.WriteLine(new LogMessage("MainForm", "StartLayout: Notify Status Failed. Exception raised was: " + e.Message), LogType.Info.ToString()); throw; } }
/// <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); // TODO: Check we are never out of the UI thread at this point DestroyLayout(); _isExpired = false; PrepareLayout(layoutPath); _clientInfoForm.CurrentLayoutId = layoutPath; // Do we need to notify? if (ApplicationSettings.Default.SendCurrentLayoutAsStatusUpdate) { using (xmds.xmds statusXmds = new xmds.xmds()) { statusXmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds; statusXmds.NotifyStatusAsync(ApplicationSettings.Default.Version, ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, "{\"currentLayoutId\":" + _layoutId + "}"); } } } catch (Exception ex) { Trace.WriteLine(new LogMessage("MainForm - ChangeToNextLayout", "Layout Change to " + layoutPath + " failed. Exception raised was: " + ex.Message), LogType.Error.ToString()); _isExpired = true; 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(); } }
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.XiboClient_xmds_xmds + "&method=notifyStatus"; 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(); }
/// <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.XiboClient_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; }
/// <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.XiboClient_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; }