Skip to content

Commit

Permalink
Merge pull request #282 from dasgarner/develop
Browse files Browse the repository at this point in the history
R307
  • Loading branch information
dasgarner authored Dec 20, 2022
2 parents 6393374 + da704bc commit 273d830
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Action/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public bool Run()
{
// Call close.
Application.Current.Dispatcher.Invoke(new System.Action(() => {
Application.Current.MainWindow.Close();
Application.Current.Shutdown();
}));

return true;
Expand Down
8 changes: 7 additions & 1 deletion Adspace/Ad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,14 @@ public string GetFileName()
{
return "axe_" + Url.Split('/').Last();
}
else
else if (Type.StartsWith("video"))
{
// Workaround for MediaElement not supporting videos without an extension.
string[] types = Type.Split('/');
return "axe_" + CreativeId + "." + types[1];
}
else
{
return "axe_" + CreativeId;
}
}
Expand Down
38 changes: 38 additions & 0 deletions Adspace/ExchangeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Eventing.Reader;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Xml;
Expand Down Expand Up @@ -281,13 +283,18 @@ public void Prefetch()
string resolvedUrl = url;
string urlProp = null;
string idProp = null;
string mimeTypeProp = null;
if (url.Contains("||"))
{
// Split the URL
string[] splits = url.Split(new string[] { "||" }, StringSplitOptions.None);
resolvedUrl = splits[0];
urlProp = splits[1];
idProp = splits[2];
if (splits.Length > 3)
{
mimeTypeProp = splits[3];
}
}

// We either expect a list of strings or a list of objects.
Expand All @@ -301,6 +308,19 @@ public void Prefetch()
{
string fetchUrl = creative.GetValue(urlProp).ToString();
string fileName = "axe_" + creative.GetValue(idProp).ToString();

// Handle videos.
// we do this because windows won't play videos without a file name (well it will, but not
// reliably)
if (mimeTypeProp != null && !fileName.Contains('.'))
{
string[] parts = creative.GetValue(mimeTypeProp).ToString().Split('/');
if (parts.Length > 1 && parts[0] == "video")
{
fileName += '.' + parts[1];
}
}

if (!CacheManager.Instance.IsValidPath(fileName))
{
DownloadAd(fetchUrl, fileName);
Expand Down Expand Up @@ -897,6 +917,24 @@ private void DownloadAd(string url, string fileName)
return;
}

// Check to see if we already have a matching file without the extension
if (fileName.Contains('.'))
{
try
{
string pathWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
if (File.Exists(ApplicationSettings.Default.LibraryPath + pathWithoutExtension))
{
File.Copy(ApplicationSettings.Default.LibraryPath + pathWithoutExtension, ApplicationSettings.Default.LibraryPath + fileName);
return;
}
}
catch
{
LogMessage.Audit("ExchangeManage", "DownloadAd", "Failed to get filename without extension");
}
}

// Not downloading yet, so do it now
creativesDownloading.Add(fileName);

Expand Down
2 changes: 1 addition & 1 deletion Log/ClientInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public int GetWidgetGroupSequence(string groupKey)
}
else
{
return -1;
return 0;
}
}

Expand Down
4 changes: 2 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 R306.3";
public string ClientVersion { get; } = "3 R307.0";
public string Version { get; } = "6";
public int ClientCodeVersion { get; } = 306;
public int ClientCodeVersion { get; } = 307;

private ApplicationSettings()
{
Expand Down
20 changes: 12 additions & 8 deletions Logic/Schedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,23 +514,27 @@ public void NextLayout()
{
// Next sequence
sequence++;
}

// Make sure we can get this sequence
if (sequence >= nextLayout.CycleScheduleItems.Count)
// Make sure we can get this sequence
if (sequence >= nextLayout.CycleScheduleItems.Count)
{
sequence = 0;
}

// Set the sequence and increment the playcount
ClientInfo.Instance.SetCampaignGroupSequence(nextLayout.CycleGroupKey, sequence);
}
else
{
sequence = 0;
// We are playing the same one again, so increment the playcount.
ClientInfo.Instance.IncrementCampaignGroupPlaycount(nextLayout.CycleGroupKey);
}

// Set the next layout
if (sequence > 0)
{
nextLayout = nextLayout.CycleScheduleItems[sequence];
}

// Set the sequence and increment the playcount
ClientInfo.Instance.SetCampaignGroupSequence(nextLayout.CycleGroupKey, sequence);
ClientInfo.Instance.IncrementCampaignGroupPlaycount(nextLayout.CycleGroupKey);
}

// Raise the event
Expand Down
43 changes: 27 additions & 16 deletions Logic/ScheduleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,11 @@ private List<ScheduleItem> ParseCyclePlayback(List<ScheduleItem> schedule)
// Add a new empty list
resolved.Add(item.CycleGroupKey, new List<ScheduleItem>());
}

resolved[item.CycleGroupKey].Add(item);
else
{
// We only add the 2nd item onward to our cycle group key.
resolved[item.CycleGroupKey].Add(item);
}
}
else
{
Expand Down Expand Up @@ -912,7 +915,15 @@ private List<ScheduleItem> ResolveNormalAndInterrupts(List<ScheduleItem> schedul
normalIndex = 0;
}
resolved.Add(resolvedNormal[normalIndex]);
totalSecondsAllocated += resolvedNormal[normalIndex].Duration;

// Protect against a schedule not having a duration (assume 60)
int duration = resolvedNormal[normalIndex].Duration;
if (duration <= 0)
{
duration = 60;
}

totalSecondsAllocated += duration;
normalIndex++;
}

Expand Down Expand Up @@ -1203,19 +1214,6 @@ private ScheduleItem ParseNodeIntoScheduleItem(XmlNode node)
}
}

// Duration
if (attributes["duration"] != null)
{
try
{
temp.Duration = int.Parse(attributes["duration"].Value);
}
catch
{
temp.Duration = 0;
}
}

// Cycle playback
try
{
Expand All @@ -1239,6 +1237,19 @@ private ScheduleItem ParseNodeIntoScheduleItem(XmlNode node)
}
}

// Duration (might exist on the default node too)
if (attributes["duration"] != null)
{
try
{
temp.Duration = int.Parse(attributes["duration"].Value);
}
catch
{
temp.Duration = 0;
}
}

// Look for dependents nodes
foreach (XmlNode childNode in node.ChildNodes)
{
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.306.0.3")]
[assembly: AssemblyFileVersion("3.306.0.3")]
[assembly: AssemblyVersion("3.307.0.0")]
[assembly: AssemblyFileVersion("3.307.0.0")]
[assembly: Guid("3bd467a4-4ef9-466a-b156-a79c13a863f7")]
24 changes: 12 additions & 12 deletions Rendering/Layout.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,10 @@ public void LoadFromFile(ScheduleItem scheduleItem, XmlDocument layoutXml, DateT
bool isRandom = XmlHelper.GetAttrib(media, "isRandom", "0") == "1";
int playCount = int.Parse(XmlHelper.GetAttrib(media, "playCount", "1"));

// This defaults to 0 if we're the first time here.
int sequence = ClientInfo.Instance.GetWidgetGroupSequence(groupKey);

// If the play count is greater than 1, we need to grab the count plays for the current widget
if (playCount > 1 && ClientInfo.Instance.GetWidgetGroupPlaycount(groupKey) < playCount)
{
// Stick with the current widget
mediaNodes.Add(parsedMedia[groupKey][sequence]);

// Bump plays
ClientInfo.Instance.IncrementWidgetGroupPlaycount(groupKey);
}
else
if (ClientInfo.Instance.GetWidgetGroupPlaycount(groupKey) >= playCount)
{
// Plays of the current widget have been met, so pick a new one.
if (isRandom)
Expand All @@ -455,11 +447,19 @@ public void LoadFromFile(ScheduleItem scheduleItem, XmlDocument layoutXml, DateT
sequence = 0;
}
}
// Pull out the appropriate widget
mediaNodes.Add(parsedMedia[groupKey][sequence]);

// Set the group sequence (also sets the play count to 1)
ClientInfo.Instance.SetWidgetGroupSequence(groupKey, sequence);
}
else
{
// Take the same one again (do not adjust sequence)
// Bump plays
ClientInfo.Instance.IncrementWidgetGroupPlaycount(groupKey);
}

// Pull out the appropriate widget
mediaNodes.Add(parsedMedia[groupKey][sequence]);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Rendering/Region.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ private void StopMedia(Media media)
// Macros
string uri = url
.Replace("[TIMESTAMP]", "" + DateTime.Now.ToString("o", System.Globalization.CultureInfo.InvariantCulture))
.Replace("[ERRORCODE]", "201");
.Replace("[ERRORCODE]", "405");

// Call the URL
new Flurl.Url(uri).WithTimeout(10).GetAsync().ContinueWith(t =>
Expand Down
16 changes: 8 additions & 8 deletions XiboClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
<Version>1.8.9</Version>
</PackageReference>
<PackageReference Include="CefSharp.Wpf">
<Version>102.0.100</Version>
<Version>107.1.120</Version>
</PackageReference>
<PackageReference Include="Crc32.NET">
<Version>1.2.0</Version>
Expand All @@ -307,7 +307,7 @@
<Version>1.16.0</Version>
</PackageReference>
<PackageReference Include="EmbedIO">
<Version>3.4.3</Version>
<Version>3.5.2</Version>
</PackageReference>
<PackageReference Include="Flurl">
<Version>3.0.6</Version>
Expand All @@ -322,22 +322,22 @@
<Version>0.3.6</Version>
</PackageReference>
<PackageReference Include="Microsoft.Data.Sqlite">
<Version>6.0.6</Version>
<Version>7.0.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.SqlServer.Types">
<Version>14.0.1016.290</Version>
</PackageReference>
<PackageReference Include="Microsoft.Web.WebView2">
<Version>1.0.1245.22</Version>
<Version>1.0.1462.37</Version>
</PackageReference>
<PackageReference Include="NetMQ">
<Version>4.0.1.8</Version>
<Version>4.0.1.10</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
<Version>13.0.2</Version>
</PackageReference>
<PackageReference Include="NodaTime">
<Version>3.1.0</Version>
<Version>3.1.6</Version>
</PackageReference>
<PackageReference Include="Ookii.Dialogs.Wpf">
<Version>5.0.1</Version>
Expand All @@ -349,7 +349,7 @@
<Version>3.0.0</Version>
</PackageReference>
<PackageReference Include="Unosquare.Swan.Lite">
<Version>3.0.0</Version>
<Version>3.1.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit 273d830

Please sign in to comment.