diff --git a/Adspace/ExchangeManager.cs b/Adspace/ExchangeManager.cs index 419deebd..36204c99 100644 --- a/Adspace/ExchangeManager.cs +++ b/Adspace/ExchangeManager.cs @@ -174,6 +174,10 @@ public Ad GetAd(double width, double height) if (!CacheManager.Instance.IsValidPath(ad.File)) { Task.Factory.StartNew(() => ad.Download()); + + // Don't show it this time + adBuffet.Remove(ad); + throw new AdspaceNoAdException("Creative pending download"); } // We've converted it into a play diff --git a/App.xaml.cs b/App.xaml.cs index 8c8f829e..0af5758e 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -79,7 +79,7 @@ protected override void OnStartup(StartupEventArgs e) } catch (Exception ex) { - HandleUnhandledException(ex, false); + HandleUnhandledException(ex, "Startup", false); } // Always flush at the end @@ -118,30 +118,30 @@ private static void RunClient(bool screenSaver) #region Exception Handlers static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { - HandleUnhandledException(e.Exception, true); + HandleUnhandledException(e.Exception, "ThreadException", true); } static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { - HandleUnhandledException(e.ExceptionObject, true); + HandleUnhandledException(e.ExceptionObject, "UnhandledException", true); } static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { - HandleUnhandledException(e.Exception, false); + HandleUnhandledException(e.Exception, "UnobservedTaskException", false); } /// /// Event for unhandled exceptions /// /// - static void HandleUnhandledException(Object o, bool quit) + static void HandleUnhandledException(Object o, string source, bool quit) { Exception e = o as Exception; // What happens if we cannot start? - Trace.WriteLine(new LogMessage("Main", "Unhandled Exception: " + e.Message), LogType.Error.ToString()); - Trace.WriteLine(new LogMessage("Main", "Stack Trace: " + e.StackTrace), LogType.Audit.ToString()); + Trace.WriteLine(new LogMessage("Main", "Unhandled Exception: " + source + ": " + e.Message), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("Main", "Stack Trace: " + e.StackTrace), LogType.Error.ToString()); // Should we quit or continue if (quit) diff --git a/Logic/ApplicationSettings.cs b/Logic/ApplicationSettings.cs index 3523c67a..a3b0bc56 100644 --- a/Logic/ApplicationSettings.cs +++ b/Logic/ApplicationSettings.cs @@ -52,9 +52,9 @@ private static readonly Lazy /// private List ExcludedProperties; - public string ClientVersion { get; } = "3 R304.1"; + public string ClientVersion { get; } = "3 R305.1"; public string Version { get; } = "6"; - public int ClientCodeVersion { get; } = 304; + public int ClientCodeVersion { get; } = 305; private ApplicationSettings() { diff --git a/Logic/Schedule.cs b/Logic/Schedule.cs index 0b303c49..7cd7091d 100644 --- a/Logic/Schedule.cs +++ b/Logic/Schedule.cs @@ -517,7 +517,7 @@ public void NextLayout() } // Make sure we can get this sequence - if (sequence > nextLayout.CycleScheduleItems.Count) + if (sequence >= nextLayout.CycleScheduleItems.Count) { sequence = 0; } diff --git a/Logic/ScheduleManager.cs b/Logic/ScheduleManager.cs index 9c4fa41a..b0ec9283 100644 --- a/Logic/ScheduleManager.cs +++ b/Logic/ScheduleManager.cs @@ -866,6 +866,7 @@ private List ResolveNormalAndInterrupts(List schedul int interruptPick = (int)Math.Floor(1.0 * pickCount / resolvedInterrupt.Count); int normalIndex = 0; int interruptIndex = 0; + int totalSecondsAllocated = 0; // Pick as many times as we need to consume the larger list for (int i = 0; i < pickCount; i++) @@ -878,6 +879,7 @@ private List ResolveNormalAndInterrupts(List schedul normalIndex = 0; } resolved.Add(resolvedNormal[normalIndex]); + totalSecondsAllocated += resolvedNormal[normalIndex].Duration; normalIndex++; } @@ -885,10 +887,27 @@ private List ResolveNormalAndInterrupts(List schedul if (i % interruptPick == 0 && interruptIndex < resolvedInterrupt.Count) { resolved.Add(resolvedInterrupt[interruptIndex]); + totalSecondsAllocated += resolvedInterrupt[interruptIndex].Duration; interruptIndex++; } } + // We might have some time left over at the end + // Our pick indexes are ceiling/floor + // https://github.com/xibosignage/xibo-dotnetclient/issues/263 + while (totalSecondsAllocated < 3600) + { + // We fill up the rest of the schedule with normal events. + // continuing from where we left off + if (normalIndex >= resolvedNormal.Count) + { + normalIndex = 0; + } + resolved.Add(resolvedNormal[normalIndex]); + totalSecondsAllocated += resolvedNormal[normalIndex].Duration; + normalIndex++; + } + return resolved; } diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 685c566f..5d2ad680 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -1,5 +1,5 @@ /** - * Copyright (C) 2021 Xibo Signage Ltd + * Copyright (C) 2022 Xibo Signage Ltd * * Xibo - Digital Signage - http://www.xibo.org.uk * @@ -216,7 +216,10 @@ private void MouseInterceptor_MouseMoveEvent() { if (_screenSaver) { - System.Windows.Application.Current.Shutdown(); + if (System.Windows.Application.Current != null) + { + System.Windows.Application.Current.Shutdown(); + } } } @@ -509,7 +512,6 @@ private void ChangeToNextLayout(ScheduleItem scheduleItem) this.Scene.Children.Clear(); Trace.WriteLine(new LogMessage("MainForm", "ChangeToNextLayout: Destroy Layout Failed. Exception raised was: " + e.Message), LogType.Info.ToString()); - throw e; } // Prepare the next layout diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 4a5eaa02..171f4b36 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -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.304.1.0")] -[assembly: AssemblyFileVersion("3.304.1.0")] +[assembly: AssemblyVersion("3.305.0.1")] +[assembly: AssemblyFileVersion("3.305.0.1")] [assembly: Guid("3bd467a4-4ef9-466a-b156-a79c13a863f7")] diff --git a/Rendering/Layout.xaml.cs b/Rendering/Layout.xaml.cs index 90301889..c6caeeea 100644 --- a/Rendering/Layout.xaml.cs +++ b/Rendering/Layout.xaml.cs @@ -450,7 +450,7 @@ public void LoadFromFile(ScheduleItem scheduleItem, XmlDocument layoutXml, DateT { // Sequential sequence++; - if (sequence > parsedMedia[groupKey].Count) + if (sequence >= parsedMedia[groupKey].Count) { sequence = 0; } diff --git a/Rendering/Media.xaml.cs b/Rendering/Media.xaml.cs index bf198621..09fdef84 100644 --- a/Rendering/Media.xaml.cs +++ b/Rendering/Media.xaml.cs @@ -720,7 +720,7 @@ public static MediaOptions ParseOptions(XmlNode node) // Check isnt blacklisted if (CacheManager.Instance.IsUnsafeMedia(options.mediaid)) { - Trace.WriteLine(new LogMessage("Media", string.Format("ParseOptions: MediaID [{0}] has been blacklisted.", options.mediaid)), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("Media", string.Format("ParseOptions: MediaID [{0}] has been blacklisted.", options.mediaid)), LogType.Info.ToString()); throw new Exception("Unsafe Media"); } diff --git a/Rendering/WebCef.cs b/Rendering/WebCef.cs index 76773e75..0cec8af6 100644 --- a/Rendering/WebCef.cs +++ b/Rendering/WebCef.cs @@ -137,8 +137,15 @@ private void WebView_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs if (e.Frame.IsMain && !Expired && !IsNativeOpen()) { // Initialise Interactive Control - webView.GetBrowser().MainFrame.ExecuteJavaScriptAsync("xiboIC.config({hostname:\"localhost\", port: " - + ApplicationSettings.Default.EmbeddedServerPort + "})"); + try + { + webView.GetBrowser().MainFrame.ExecuteJavaScriptAsync("xiboIC.config({hostname:\"localhost\", port: " + + ApplicationSettings.Default.EmbeddedServerPort + "})"); + } + catch + { + Trace.WriteLine(new LogMessage("WebCef: WebView_FrameLoadEnd", "Cant execute xiboIC"), LogType.Info.ToString()); + } } } diff --git a/XiboClient.csproj b/XiboClient.csproj index d1da1860..70e16f62 100644 --- a/XiboClient.csproj +++ b/XiboClient.csproj @@ -363,6 +363,7 @@ - echo F|xcopy /Y "$(TargetPath)" "$(TargetDir)\Xibo.scr" + echo F|xcopy /Y "$(TargetPath)" "$(TargetDir)Xibo.scr" +echo F|xcopy /Y "$(TargetDir)XiboClient.exe.config" "$(TargetDir)Xibo.scr.config" \ No newline at end of file