Skip to content

Commit

Permalink
Merge pull request #301 from xibosignage/develop
Browse files Browse the repository at this point in the history
Release v3 R309
  • Loading branch information
dasgarner authored Jun 20, 2023
2 parents 8462823 + 0028b80 commit 59e3991
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 117 deletions.
81 changes: 51 additions & 30 deletions Action/Command.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2022 Xibo Signage Ltd
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
Expand All @@ -21,7 +21,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Shapes;

namespace XiboClient.Action
{
Expand Down Expand Up @@ -52,6 +54,36 @@ public bool IsValidationRequired()
return !string.IsNullOrEmpty(Validation);
}

/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
private bool IsValid(string value)
{
LogMessage.Audit("Command", "IsValid", "Testing if " + Code + " is valid, output to test is [" + value + "]");

// Do we need to validate?
if (IsValidationRequired())
{
// Is the validation string a regex.
try
{
Match match = Regex.Match(value, Validation);
return match.Success;
}
catch
{
// Fallback to a string comparison
return value.Contains(Validation);
}
}
else
{
return true;
}
}

/// <summary>
/// Run the Command
/// </summary>
Expand All @@ -67,14 +99,7 @@ public bool Run()
Rs232Command rs232 = new Rs232Command(this);
string line = rs232.Run();

if (IsValidationRequired())
{
return line == Validation;
}
else
{
return true;
}
return IsValid(line);
}
else if (CommandString == "SoftRestart")
{
Expand All @@ -90,14 +115,7 @@ public bool Run()
HttpCommand command = new HttpCommand(this);
var httpStatus = command.RunAsync();

if (IsValidationRequired())
{
return httpStatus.Result + "" == Validation;
}
else
{
return true;
}
return IsValid(httpStatus.Result + "");
}
else
{
Expand All @@ -111,29 +129,32 @@ public bool Run()
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C " + CommandString;
startInfo.UseShellExecute = false;

if (IsValidationRequired())
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardOutput = true;

process.StartInfo = startInfo;
process.Start();
process.Exited += Process_Exited;

if (IsValidationRequired())
string line = "";
while (!process.StandardOutput.EndOfStream)
{
string line = "";
while (!process.StandardOutput.EndOfStream)
{
line += process.StandardOutput.ReadLine();
}

return line == Validation;
line += process.StandardOutput.ReadLine();
}
else
return true;

return IsValid(line);
}
}
}

private void Process_Exited(object sender, EventArgs e)
{
int exitCode = ((Process)sender).ExitCode;
if (exitCode != 0)
{
LogMessage.Audit("Command", "Run", "Non-zero exit code [" + exitCode + "] returned for command " + Code);
}
}

/// <summary>
/// Get a command from Application Settings based on its Command Code
/// </summary>
Expand Down
125 changes: 67 additions & 58 deletions Adspace/ExchangeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -672,87 +672,96 @@ private List<Ad> Request(Url url, Ad wrappedAd)
XmlNode inlineNode = adNode.SelectSingleNode("./InLine");
if (inlineNode != null)
{
// Title
XmlNode titleNode = inlineNode.SelectSingleNode("./AdTitle");
if (titleNode != null)
{
ad.Title = titleNode.InnerText.Trim();
}

// Get and impression/error URLs included with this wrap
XmlNode errorUrlNode = inlineNode.SelectSingleNode("./Error");
if (errorUrlNode != null)
try
{
string errorUrl = errorUrlNode.InnerText.Trim();
if (errorUrl != "about:blank")
// Title
XmlNode titleNode = inlineNode.SelectSingleNode("./AdTitle");
if (titleNode != null)
{
ad.ErrorUrls.Add(errorUrl + ad.WrapperExtendUrl);
ad.Title = titleNode.InnerText.Trim();
}
}

XmlNode impressionUrlNode = inlineNode.SelectSingleNode("./Impression");
if (impressionUrlNode != null)
{
string impressionUrl = impressionUrlNode.InnerText.Trim();
if (impressionUrl != "about:blank")
// Get and impression/error URLs included with this wrap
XmlNode errorUrlNode = inlineNode.SelectSingleNode("./Error");
if (errorUrlNode != null)
{
ad.ImpressionUrls.Add(impressionUrl + ad.WrapperExtendUrl);
string errorUrl = errorUrlNode.InnerText.Trim();
if (errorUrl != "about:blank")
{
ad.ErrorUrls.Add(errorUrl + ad.WrapperExtendUrl);
}
}
}

// Creatives
XmlNode creativeNode = inlineNode.SelectSingleNode("./Creatives/Creative");
if (creativeNode != null)
{
ad.CreativeId = creativeNode.Attributes["id"].Value;
XmlNode impressionUrlNode = inlineNode.SelectSingleNode("./Impression");
if (impressionUrlNode != null)
{
string impressionUrl = impressionUrlNode.InnerText.Trim();
if (impressionUrl != "about:blank")
{
ad.ImpressionUrls.Add(impressionUrl + ad.WrapperExtendUrl);
}
}

// Get the duration.
XmlNode creativeDurationNode = creativeNode.SelectSingleNode("./Linear/Duration");
if (creativeDurationNode != null)
// Creatives
XmlNode creativeNode = inlineNode.SelectSingleNode("./Creatives/Creative");
if (creativeNode != null)
{
ad.Duration = creativeDurationNode.InnerText.Trim();
ad.CreativeId = creativeNode.Attributes["id"].Value;

// Get the duration.
XmlNode creativeDurationNode = creativeNode.SelectSingleNode("./Linear/Duration");
if (creativeDurationNode != null)
{
ad.Duration = creativeDurationNode.InnerText.Trim();
}
else
{
ReportError(ad.ErrorUrls, 302);
continue;
}

// Get the media file
XmlNode creativeMediaNode = creativeNode.SelectSingleNode("./Linear/MediaFiles/MediaFile");
if (creativeMediaNode != null)
{
ad.Url = creativeMediaNode.InnerText.Trim();
ad.Width = int.Parse(creativeMediaNode.Attributes["width"].Value);
ad.Height = int.Parse(creativeMediaNode.Attributes["height"].Value);
ad.Type = creativeMediaNode.Attributes["type"].Value;
}
else
{
ReportError(ad.ErrorUrls, 302);
continue;
}
}
else
{
ReportError(ad.ErrorUrls, 302);
// Malformed Ad.
ReportError(ad.ErrorUrls, 300);
continue;
}

// Get the media file
XmlNode creativeMediaNode = creativeNode.SelectSingleNode("./Linear/MediaFiles/MediaFile");
if (creativeMediaNode != null)
// Extensions
XmlNodeList extensionNodes = inlineNode.SelectNodes("./Extension");
foreach (XmlNode extensionNode in extensionNodes)
{
ad.Url = creativeMediaNode.InnerText.Trim();
ad.Width = int.Parse(creativeMediaNode.Attributes["width"].Value);
ad.Height = int.Parse(creativeMediaNode.Attributes["height"].Value);
ad.Type = creativeMediaNode.Attributes["type"].Value;
}
else
{
ReportError(ad.ErrorUrls, 302);
continue;
switch (extensionNode.Attributes["type"].Value)
{
case "geoFence":
ad.IsGeoAware = true;
ad.GeoLocation = extensionNode.InnerText;
break;
}
}
}
else
catch (Exception ex)
{
// Malformed Ad.
LogMessage.Audit("ExchangeManager", "Request", "Error parsing response XML. e: " + ex.Message);
ReportError(ad.ErrorUrls, 300);
continue;
}

// Extensions
XmlNodeList extensionNodes = inlineNode.SelectNodes("./Extension");
foreach (XmlNode extensionNode in extensionNodes)
{
switch (extensionNode.Attributes["type"].Value)
{
case "geoFence":
ad.IsGeoAware = true;
ad.GeoLocation = extensionNode.InnerText;
break;
}
}

// Did this resolve from a wrapper? if so do some extra checks.
if (ad.IsWrapper)
{
Expand Down
6 changes: 4 additions & 2 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ protected override void OnStartup(StartupEventArgs e)
// Add the Xibo Tracelistener
Trace.Listeners.Add(new XiboTraceListener());

bool shouldQuit = false;
try
{
// Check for any passed arguments
if (e.Args.Length > 0)
{
if (e.Args[0].ToString() == "o")
{
shouldQuit = true;
RunSettings();
}
else
Expand Down Expand Up @@ -79,7 +81,7 @@ protected override void OnStartup(StartupEventArgs e)
}
catch (Exception ex)
{
HandleUnhandledException(ex, "Startup", false);
HandleUnhandledException(ex, "Startup", shouldQuit);
}

// Always flush at the end
Expand Down Expand Up @@ -174,7 +176,7 @@ static void HandleUnhandledException(Object o, string source, bool quit)
// Complete failure, show something to the user in these circumstances.
if (quit)
{
MessageBox.Show(ex.Message);
MessageBox.Show("Unhandled Exception: " + ex.Message + ". Stack Trace: " + e.StackTrace, "Fatal Error");
}
}

Expand Down
9 changes: 7 additions & 2 deletions Logic/ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ private static readonly Lazy<ApplicationSettings>
/// </summary>
private List<string> ExcludedProperties;

public string ClientVersion { get; } = "3 R308.0";
public string ClientVersion { get; } = "3 R309.1";
public string Version { get; } = "6";
public int ClientCodeVersion { get; } = 308;
public int ClientCodeVersion { get; } = 309;

private ApplicationSettings()
{
Expand Down Expand Up @@ -571,6 +571,11 @@ public bool InDownloadWindow
private int _maxLogFileUploads;
public int MaxLogFileUploads { get { return ((_maxLogFileUploads == 0) ? 10 : _maxLogFileUploads); } set { _maxLogFileUploads = value; } }

/// <summary>
/// The amount of time in seconds we wait before a video is considered timed out on load
/// </summary>
public int VideoStartTimeout { get; set; }

public bool PowerpointEnabled { get; set; }
public bool StatsEnabled { get; set; }
public bool ExpireModifiedLayouts { get; set; }
Expand Down
Loading

0 comments on commit 59e3991

Please sign in to comment.