Skip to content

Commit

Permalink
Merge pull request #323 from xibosignage/develop
Browse files Browse the repository at this point in the history
Release v4 R402
  • Loading branch information
dasgarner authored Dec 19, 2023
2 parents abef66d + 9881308 commit d528a2f
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Adspace/ExchangeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void FillForWidget(string partner)
{
if (CountAvailableAds <= 1)
{
Fill(true, true, null);
Fill(true, true, partner);
}
}

Expand Down
31 changes: 26 additions & 5 deletions Control/DurationController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright (C) 2021 Xibo Signage Ltd
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand Down Expand Up @@ -41,14 +41,21 @@ public DurationController(EmbeddedServer parent)
[Route(HttpVerbs.Post, "/expire")]
public async void Expire()
{
if (_parent == null)
{
LogMessage.Info("DurationController", "Expire", "Web server closing");
return;
}

try
{
var data = await HttpContext.GetRequestDataAsync<DurationRequest>();
_parent.Duration("expire", data.id, 0);
}
catch (Exception e)
{
Trace.WriteLine(new LogMessage("HookController", "Expire: unable to parse request: " + e.Message), LogType.Error.ToString());
Trace.WriteLine(new LogMessage("DurationController", "Expire: unable to parse request: " + e.Message), LogType.Error.ToString());
LogMessage.Trace("DurationController", "Expire", e.StackTrace.ToString());
}
}

Expand All @@ -58,14 +65,21 @@ public async void Expire()
[Route(HttpVerbs.Post, "/extend")]
public async void Extend()
{
if (_parent == null)
{
LogMessage.Info("DurationController", "Expire", "Web server closing");
return;
}

try
{
var data = await HttpContext.GetRequestDataAsync<DurationRequest>();
_parent.Duration("extend", data.id, data.duration);
}
catch (Exception e)
{
Trace.WriteLine(new LogMessage("HookController", "Extend: unable to parse request: " + e.Message), LogType.Error.ToString());
Trace.WriteLine(new LogMessage("DurationController", "Extend: unable to parse request: " + e.Message), LogType.Error.ToString());
LogMessage.Trace("DurationController", "Extend", e.StackTrace.ToString());
}
}

Expand All @@ -75,14 +89,21 @@ public async void Extend()
[Route(HttpVerbs.Post, "/set")]
public async void Set()
{
if (_parent == null)
{
LogMessage.Info("DurationController", "Expire", "Web server closing");
return;
}

try
{
var data = await HttpContext.GetRequestDataAsync<DurationRequest>();
_parent.Duration("set", data.id, data.duration);
}
catch (Exception e)
{
Trace.WriteLine(new LogMessage("HookController", "Set: unable to parse request: " + e.Message), LogType.Error.ToString());
Trace.WriteLine(new LogMessage("DurationController", "Set: unable to parse request: " + e.Message), LogType.Error.ToString());
LogMessage.Trace("DurationController", "Set", e.StackTrace.ToString());
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions Control/FaultController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand All @@ -22,12 +22,7 @@
using EmbedIO;
using EmbedIO.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.Remoting.Contexts;

namespace XiboClient.Control
{
Expand Down Expand Up @@ -67,6 +62,7 @@ public async Task<string> Fault()
catch (Exception e)
{
LogMessage.Error("FaultController", "Fault", "Trigger: unable to parse request: " + e.Message);
LogMessage.Trace("FaultController", "Fault", e.StackTrace.ToString());
throw HttpException.NotAcceptable();
}

Expand Down
4 changes: 2 additions & 2 deletions Control/HookController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright (C) 2021 Xibo Signage Ltd
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand Down
4 changes: 2 additions & 2 deletions InfoScreen.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright (C) 2021 Xibo Signage Ltd
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
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; } = "4 R401.0";
public string ClientVersion { get; } = "4 R402.1";
public string Version { get; } = "7";
public int ClientCodeVersion { get; } = 401;
public int ClientCodeVersion { get; } = 402;

private ApplicationSettings()
{
Expand Down
4 changes: 2 additions & 2 deletions Logic/CacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ public bool IsUnsafeWidget(string widgetId)
private string UnsafeListAsString()
{
string list = "";
foreach (UnsafeItem item in _unsafeItems)
foreach (UnsafeItem item in _unsafeItems.ToList())
{
list += item.Type.ToString() + ": " + item.Id + ", [" + (int)item.Code + "] " + item.Reason + ", ttl: " + item.Ttl + Environment.NewLine;
}
Expand All @@ -605,7 +605,7 @@ public string UnsafeListAsJsonString()
writer.Formatting = Newtonsoft.Json.Formatting.None;
writer.WriteStartArray();

foreach (UnsafeItem item in _unsafeItems)
foreach (UnsafeItem item in _unsafeItems.ToList())
{
writer.WriteStartObject();
writer.WritePropertyName("date");
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("4.401.0.0")]
[assembly: AssemblyFileVersion("4.401.0.0")]
[assembly: AssemblyVersion("4.402.1.0")]
[assembly: AssemblyFileVersion("4.402.1.0")]
[assembly: Guid("3bd467a4-4ef9-466a-b156-a79c13a863f7")]
26 changes: 24 additions & 2 deletions Rendering/Region.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand Down Expand Up @@ -151,6 +151,11 @@ public partial class Region : UserControl
/// </summary>
private int _widgetAvailableTtl;

/// <summary>
/// Count of widgets which are inside their from/to dates
/// </summary>
private int _countWidgetsInDate;

/// <summary>
/// The Schedule
/// </summary>
Expand All @@ -161,6 +166,7 @@ public Region(Schedule schedule)
this.schedule = schedule;
InitializeComponent();
ZIndex = 0;
_countWidgetsInDate = 0;
}

public void LoadFromOptions(string id, RegionOptions options, List<XmlNode> media, int actionTop, int actionLeft)
Expand Down Expand Up @@ -380,7 +386,19 @@ private void StartNext(double position)
// we don't do this for adspace exchange, because we expect to fail sometimes
if (!isLayoutAdspaceExchange && !(_media.Count == 1 && _media[0].Attributes["type"].Value == "ssp"))
{
CacheManager.Instance.AddUnsafeItem(UnsafeItemType.Region, UnsafeFaultCodes.XlfNoContent, options.layoutId, options.regionId, "Unable to set any region media nodes.", _widgetAvailableTtl);
// Is this because we have widgets with a from/to date, or is this because none of the widgets are valid?
// if there are no widgets in date, then use the calculated first date that the widget will be available from,
// otherwise use 60 seconds as a short timeout.
int faultTtl = _countWidgetsInDate <= 0 ? _widgetAvailableTtl : 60;

CacheManager.Instance.AddUnsafeItem(
UnsafeItemType.Region,
UnsafeFaultCodes.XlfNoContent,
options.layoutId,
options.regionId,
"There are no valid widgets inside one of the regions in this layout",
faultTtl
);
}

// Throw this out so we remove the Layout
Expand Down Expand Up @@ -522,6 +540,9 @@ private bool SetNextMediaNodeInOptions()
bool validNode = false;
int numAttempts = 0;

// Start with all widgets in-date
_countWidgetsInDate = _media.Count;

// Loop through all the nodes in order
while (numAttempts < this._media.Count)
{
Expand Down Expand Up @@ -575,6 +596,7 @@ private bool SetNextMediaNodeInOptions()

// Increment the number of attempts and try again
numAttempts++;
_countWidgetsInDate--;

// Watermark the next earliest time we can expect this Widget to be available.
if (_currentMediaOptions.FromDt > DateTime.Now)
Expand Down
Loading

0 comments on commit d528a2f

Please sign in to comment.