public void Run() { bool success; try { // Get a fresh command from settings Command = Command.GetByCode(Code); // Run the command. success = Command.Run(); } catch (Exception e) { Trace.WriteLine(new LogMessage("CommandSchedule - Run", "Cannot start 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 + "}"); } }
public void Run() { bool success; try { // Get a fresh command from settings Command = Command.GetByCode(Code); // Run the command. success = Command.Run(); } catch (Exception e) { Trace.WriteLine(new LogMessage("CommandSchedule - Run", "Cannot start 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 + "}"); } }
public static void Notify(string _layoutId) { 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\":" + _layoutId + "}"); } } }
/// <summary> /// Report the timezone to XMDS /// </summary> private void reportTimezone() { using (xmds.xmds xmds = new xmds.xmds()) { string status = "{\"timeZone\":\"" + WindowsToIana(TimeZone.CurrentTimeZone.StandardName) + "\"}"; xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=notifyStatus"; xmds.UseDefaultCredentials = false; xmds.NotifyStatusAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, status); } }
/// <summary> /// Notify Status to XMDS /// </summary> public void NotifyStatusToXmds() { try { StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Formatting.None; writer.WriteStartObject(); writer.WritePropertyName("lastActivity"); writer.WriteValue(DateTime.Now.ToString()); writer.WritePropertyName("applicationState"); writer.WriteValue(Thread.CurrentThread.ThreadState.ToString()); writer.WritePropertyName("xmdsLastActivity"); writer.WriteValue(ApplicationSettings.Default.XmdsLastConnection.ToString()); writer.WritePropertyName("scheduleStatus"); writer.WriteValue(ScheduleManagerStatus); writer.WritePropertyName("requiredFilesStatus"); writer.WriteValue(RequiredFilesStatus); writer.WritePropertyName("xmrStatus"); writer.WriteValue(XmrSubscriberStatus); writer.WriteEndObject(); } StringBuilder finalSb = new StringBuilder(); using (StringWriter sw = new StringWriter(finalSb)) using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Formatting.None; writer.WriteStartObject(); writer.WritePropertyName("statusDialog"); writer.WriteValue(sb.ToString()); writer.WriteEndObject(); } // 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, finalSb.ToString()); } sb.Clear(); finalSb.Clear(); } catch (Exception e) { Trace.WriteLine(new LogMessage("ClientInfo - notifyStatusToXmds", "Failed to notify status to XMDS. e = " + e.Message), LogType.Error.ToString()); } }
private void reportStorage() { // Use Drive Info foreach (DriveInfo drive in DriveInfo.GetDrives()) { if (drive.IsReady && ApplicationSettings.Default.LibraryPath.Contains(drive.RootDirectory.FullName)) { using (xmds.xmds xmds = new xmds.xmds()) { string status = "{\"availableSpace\":\"" + drive.TotalFreeSpace + "\", \"totalSpace\":\"" + drive.TotalSize + "\"}"; xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds; xmds.UseDefaultCredentials = false; xmds.NotifyStatusAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, status); } break; } } }
public void notifyStatusToXmds() { try { StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Formatting.None; writer.WriteStartObject(); writer.WritePropertyName("lastActivity"); writer.WriteValue(DateTime.Now.ToString()); writer.WritePropertyName("applicationState"); writer.WriteValue(Thread.State.ToString()); writer.WritePropertyName("xmdsLastActivity"); writer.WriteValue(ApplicationSettings.Default.XmdsLastConnection.ToString()); writer.WritePropertyName("scheduleStatus"); writer.WriteValue(scheduleStatusLabel.Text); writer.WritePropertyName("requiredFilesStatus"); writer.WriteValue(requiredFilesStatus.Text); writer.WritePropertyName("xmrStatus"); writer.WriteValue(xmrStatus.Text); writer.WriteEndObject(); } // Notify the state of the command (success or failure) using (xmds.xmds statusXmds = new xmds.xmds()) { statusXmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds; statusXmds.NotifyStatusAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, sb.ToString()); } } catch (Exception e) { Trace.WriteLine(new LogMessage("ClientInfo - notifyStatusToXmds", "Failed to notify status to XMDS. e = " + e.Message), LogType.Error.ToString()); } }
private void reportStorage() { StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Newtonsoft.Json.Formatting.None; writer.WriteStartObject(); writer.WritePropertyName("deviceName"); writer.WriteValue(Environment.MachineName); // Use Drive Info foreach (DriveInfo drive in DriveInfo.GetDrives()) { if (drive.IsReady && ApplicationSettings.Default.LibraryPath.Contains(drive.RootDirectory.FullName)) { writer.WritePropertyName("availableSpace"); writer.WriteValue(drive.TotalFreeSpace); writer.WritePropertyName("totalSpace"); writer.WriteValue(drive.TotalSize); break; } } writer.WriteEndObject(); // Report using (xmds.xmds xmds = new xmds.xmds()) { xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=notifyStatus"; xmds.UseDefaultCredentials = false; xmds.NotifyStatusAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, sb.ToString()); } } }
/// <summary> /// Report the timezone to XMDS /// </summary> private void NotifyStatus() { StringBuilder sb = new StringBuilder(); using (StringWriter sw = new StringWriter(sb)) using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Newtonsoft.Json.Formatting.None; writer.WriteStartObject(); writer.WritePropertyName("deviceName"); writer.WriteValue(Environment.MachineName); writer.WritePropertyName("width"); writer.WriteValue(ClientInfo.Instance.PlayerWidth); writer.WritePropertyName("height"); writer.WriteValue(ClientInfo.Instance.PlayerHeight); // GeoLocation if (ClientInfo.Instance.CurrentGeoLocation != null && !ClientInfo.Instance.CurrentGeoLocation.IsUnknown) { writer.WritePropertyName("latitude"); writer.WriteValue(ClientInfo.Instance.CurrentGeoLocation.Latitude); writer.WritePropertyName("longitude"); writer.WriteValue(ClientInfo.Instance.CurrentGeoLocation.Longitude); } try { // Use Drive Info foreach (DriveInfo drive in DriveInfo.GetDrives()) { if (drive.IsReady && ApplicationSettings.Default.LibraryPath.Contains(drive.RootDirectory.FullName)) { writer.WritePropertyName("availableSpace"); writer.WriteValue(drive.TotalFreeSpace); writer.WritePropertyName("totalSpace"); writer.WriteValue(drive.TotalSize); break; } } } catch { Trace.WriteLine(new LogMessage("NotifyStatus", "Unable to get drive info"), LogType.Info.ToString()); } // Timezone // we only do the timezone if it is currently empty, otherwise we stick with whatever has been set. if (string.IsNullOrEmpty(ApplicationSettings.Default.DisplayTimeZone)) { writer.WritePropertyName("timeZone"); writer.WriteValue(WindowsToIana(TimeZone.CurrentTimeZone.StandardName)); } // Finish writer.WriteEndObject(); // Report using (xmds.xmds xmds = new xmds.xmds()) { xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=notifyStatus"; xmds.UseDefaultCredentials = false; xmds.NotifyStatusAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, sb.ToString()); } } sb.Clear(); }
private void reportStorage() { // Use Drive Info foreach (DriveInfo drive in DriveInfo.GetDrives()) { if (drive.IsReady && ApplicationSettings.Default.LibraryPath.Contains(drive.RootDirectory.FullName)) { using (xmds.xmds xmds = new xmds.xmds()) { string status = "{\"availableSpace\":\"" + drive.TotalFreeSpace + "\", \"totalSpace\":\"" + drive.TotalSize + "\"}"; xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.R23SignageClient_xmds_xmds; xmds.UseDefaultCredentials = false; xmds.NotifyStatusAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, status); } break; } } }
public override void RenderMedia(double position) { 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(position); }