From b55013b44e1c16aef023663af1176be899140f59 Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Fri, 11 Mar 2016 11:21:16 +0000 Subject: [PATCH 1/8] Bumped version --- Logic/ApplicationSettings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Logic/ApplicationSettings.cs b/Logic/ApplicationSettings.cs index 63f2af1b..664fdc7f 100644 --- a/Logic/ApplicationSettings.cs +++ b/Logic/ApplicationSettings.cs @@ -37,9 +37,9 @@ public class ApplicationSettings private static string _default = "default"; // Application Specific Settings we want to protect - private string _clientVersion = "1.7.6"; + private string _clientVersion = "1.7.7"; private string _version = "4"; - private int _clientCodeVersion = 110; + private int _clientCodeVersion = 111; public string ClientVersion { get { return _clientVersion; } } public string Version { get { return _version; } } From e73c4c72b84b1abef55432e33ff985976c2c87b1 Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Fri, 11 Mar 2016 11:24:28 +0000 Subject: [PATCH 2/8] Prevent config file updates with each register XMDS call. xibosignage/xibo#736 --- XiboClient.v11.suo | Bin 195584 -> 195584 bytes XmdsAgents/RegisterAgent.cs | 14 +++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/XiboClient.v11.suo b/XiboClient.v11.suo index fe515b6af3f9c81c448d1125d38c949d75363797..f3061fa84caecd37e7d071021ab094d9071a012d 100644 GIT binary patch delta 380 zcmZqp!QJqKdxC*169W_oFfa%Knan`^@Bjb*AW`OxzVd8r3yjX$wpULsVrpX4+x(SH zosm})C?^HPN_FNW$_DX4VDkeO9!3rb8_4^@DZnzBML}osjw+tb zHVQ`=7YVQ|;$hlkQ^CmepLueXZQJAq9+}ND5>I$1ac$uQ`3HpmZ{Ex0%s6@CR^!da z8fO_76)-K*G28Ux0h6Z}&^|^emWg1Qu1Ux1)YUxZa5eS&{8yZrZ&3o{ zWCzvU$+?M>Cp#z$PhPTBVY9KuS;j>?OpA2PCV3s6>?~}!`HPn*<77X3_Q?WK7A!(Q UlQ#QAZDDLmYfEEXmc}#<0P6E=6951J diff --git a/XmdsAgents/RegisterAgent.cs b/XmdsAgents/RegisterAgent.cs index 622a0b21..15368775 100644 --- a/XmdsAgents/RegisterAgent.cs +++ b/XmdsAgents/RegisterAgent.cs @@ -112,19 +112,12 @@ public static string ProcessRegisterXml(string xml) string message = ""; bool error = false; - // Work out if we need to do anything (have the settings changed since the last time) - string md5 = Hashes.MD5(xml); - try { // Load the result into an XML document XmlDocument result = new XmlDocument(); result.LoadXml(xml); - // If the XML we received has not changed, then go no further. - if (ApplicationSettings.Default.Hash == md5) - return result.DocumentElement.Attributes["message"].Value; - // Test the XML if (result.DocumentElement.Attributes["code"].Value == "READY") { @@ -143,6 +136,13 @@ public static string ProcessRegisterXml(string xml) if (result.DocumentElement.ChildNodes.Count <= 0) throw new Exception("Configuration not set for this display"); + // Hash after removing the date + result.DocumentElement.Attributes["date"].Value = ""; + string md5 = Hashes.MD5(result.OuterXml); + + if (md5 == ApplicationSettings.Default.Hash) + return result.DocumentElement.Attributes["message"].Value; + foreach (XmlNode node in result.DocumentElement.ChildNodes) { Object value = node.InnerText; From 972ecab22f98e9311e7aa56d928e7f49543b7e8e Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Fri, 11 Mar 2016 11:24:28 +0000 Subject: [PATCH 3/8] Prevent config file updates with each register XMDS call. xibosignage/xibo#736 --- XiboClient.v11.suo | Bin 195584 -> 195584 bytes XmdsAgents/RegisterAgent.cs | 22 +++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/XiboClient.v11.suo b/XiboClient.v11.suo index fe515b6af3f9c81c448d1125d38c949d75363797..f3061fa84caecd37e7d071021ab094d9071a012d 100644 GIT binary patch delta 380 zcmZqp!QJqKdxC*169W_oFfa%Knan`^@Bjb*AW`OxzVd8r3yjX$wpULsVrpX4+x(SH zosm})C?^HPN_FNW$_DX4VDkeO9!3rb8_4^@DZnzBML}osjw+tb zHVQ`=7YVQ|;$hlkQ^CmepLueXZQJAq9+}ND5>I$1ac$uQ`3HpmZ{Ex0%s6@CR^!da z8fO_76)-K*G28Ux0h6Z}&^|^emWg1Qu1Ux1)YUxZa5eS&{8yZrZ&3o{ zWCzvU$+?M>Cp#z$PhPTBVY9KuS;j>?OpA2PCV3s6>?~}!`HPn*<77X3_Q?WK7A!(Q UlQ#QAZDDLmYfEEXmc}#<0P6E=6951J diff --git a/XmdsAgents/RegisterAgent.cs b/XmdsAgents/RegisterAgent.cs index 622a0b21..cbdb8326 100644 --- a/XmdsAgents/RegisterAgent.cs +++ b/XmdsAgents/RegisterAgent.cs @@ -112,19 +112,12 @@ public static string ProcessRegisterXml(string xml) string message = ""; bool error = false; - // Work out if we need to do anything (have the settings changed since the last time) - string md5 = Hashes.MD5(xml); - try { // Load the result into an XML document XmlDocument result = new XmlDocument(); result.LoadXml(xml); - // If the XML we received has not changed, then go no further. - if (ApplicationSettings.Default.Hash == md5) - return result.DocumentElement.Attributes["message"].Value; - // Test the XML if (result.DocumentElement.Attributes["code"].Value == "READY") { @@ -143,6 +136,21 @@ public static string ProcessRegisterXml(string xml) if (result.DocumentElement.ChildNodes.Count <= 0) throw new Exception("Configuration not set for this display"); + // Hash after removing the date + try + { + result.DocumentElement.Attributes["date"].Value = ""; + } + catch + { + // No date, no need to remove + } + + string md5 = Hashes.MD5(result.OuterXml); + + if (md5 == ApplicationSettings.Default.Hash) + return result.DocumentElement.Attributes["message"].Value; + foreach (XmlNode node in result.DocumentElement.ChildNodes) { Object value = node.InnerText; From bf73bd901a870978506ea70622c95bd6a31b2fb7 Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Fri, 11 Mar 2016 11:46:01 +0000 Subject: [PATCH 4/8] Protect against DurationElapsedEvent being null (because the media object has been destroyed) xibosignage/xibo#738 --- Media/Media.cs | 3 ++- XiboClient.v11.suo | Bin 195584 -> 197120 bytes 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Media/Media.cs b/Media/Media.cs index 7788b53c..dfdae7ff 100644 --- a/Media/Media.cs +++ b/Media/Media.cs @@ -229,7 +229,8 @@ public void SignalElapsedEvent() Trace.WriteLine(new LogMessage("Media - SignalElapsedEvent", "Media Complete"), LogType.Audit.ToString()); - DurationElapsedEvent(_filesPlayed); + if (DurationElapsedEvent != null) + DurationElapsedEvent(_filesPlayed); } /// diff --git a/XiboClient.v11.suo b/XiboClient.v11.suo index f3061fa84caecd37e7d071021ab094d9071a012d..2fd5489d7f8ee177b16f3e79d1b97d970e984e90 100644 GIT binary patch delta 3506 zcmeI#drVu`9S87xF2>l{#$X&UgopE@29xsCLaGd#7+4?)gr)(SvNR4bpmBKF&I7XG zJk(}cO7Z=%+^ChJ*6a9Znc8yIBJJre=}X;1{b!rhP0glF`=ioSZ6pfSi1+=uux8Ub zjcJnOSXPL%850k{Um;F6@0kG;!zq)5QCQXnTK}O0d5fR@0P)`2I9;YCj`Qvb2?= zx?Bqn%Sqw#znhfwK1V*TkF&dqXNqGwoxUTJgUXc(o)~&Nz0$yyUhF8Q7wN@Rd(#Nw zQCJ<}IN}h5SL#lnJPD^@0w#f{=rWvvvk;+WOU=5c5lsV+G_z7F^ea=Y;VSlS0`+BF zH?E#2L3!5SD;bq*?x&%jj+#7~(NX7=1)0wPD`Y|z*dQD1unuw{7aWiW`LG@epb(0n z7@V*HHo_*@3|pWC9sn1VLK(QBTuAg%kKFpMwv?MDE9M(U zQGi`u;*tY)(QWhoWX}Q$Tc*tGae$XD-eLthrFv0Zq1)9M(t#RYGLqfCM&X)v179pZ zIb3C)MZn7dZ%T7W_$b`mMmOZDR9;7SX-my%Vr}PF27TOLs9JdNtAe7h)@U`ZAB*`X zZVGA)RGMDLxKHuvBuPuSgqD&sC-h1f7755-p9~k0Px;@?}?jeX&)Tc{Vzdhb8HXOT@1@WSx35SKg6z z@m}ECm^keF-r|Lyx6UjdNKvy&MTMD1#>^%+bx*0NHGJgbcbO!q7fVH*I71Ej9<8eO z2O>J!5PL}etklKo4dmVA5gyH(9~ZG*a%`ipzVXXn*S@PRTA%yehp$LYL2B^WmA=Bv zu6HcmXIfLl-Hc}gC8vY8$bX`OrZ%0WHcy(Cwr9zxv@K`u{L}XLfAKpvHQxJ9<$G^_ zw+EeT$lD%|b^rTA_h9IpDIRnQqLa?wBz5uBw~No#p1GZ zCtXWFa!1f_d%g2Vrc%V#g?Os)%5&+${F*_;h1rVlKwd3%(l-P>y|qU5q>Bp2$zy#% z|3Lq6DA+UJKQI&w^^Yfa=>>nWdJUcBxldc?1x5yjdVBn%qk*Abe`siAIM^Qw4Gj+j z|Jr<^#U$K9UehU5yG3Yg?DDczg z%VlZdEvtA(7V<*WCPu{EMj_7?3Eh(}G3SzhLY1X5TX#Gaj9E6 zCI#@<2Jerfei%oc_|W89zS2%L?~Z)R=X=ol2v_Z~RXB~1tjeji1DY7>*_pvPh j)6Ylx$fVN_XFM+!BAbO*katTwc37z1ZQ?Rr_J{rg2Y-(C delta 3135 zcmb`|32+p}8VB(CW+$6HCa_r|S&|Tz6l%~2A;I87A)`SIiiC(qR6IC>J`EVcF7LTS zvS>^!r7+B=4&J(D#al6>1}|Je@py{B^LXCzKA)m)6p#@A-zH0;1tnT`)o=Ujo}QlW zo}S)lvmV{%Z7V8rD2k#&GWit6k3i~n_4f8koy0{j1Z+CuE;7|RXYq`N8K>89gL)|~ zx4YF`Y8r^k1%SJHMkHSJ|fJG33Ff4|D!N1{Rh=8IemXC3P1!veSn_I%IsZd31B+Na)g>fSwb8Qn67a?g+ryj~qc7jbva z3{Acjt}ZX6Tn^_px#d%FfxR)e!=8?hp%8B9Py|RSE!>e3!5XjLeRYye- zWP&8Zs;S@r4bs2~>EHr4ctGach#W_GoP2V3>U~OXMk+NqcltI>)9t z5}W8U3qte{4i`*wlblk?;|G&Ylm8*j-d>PSu}amfU!NSp;R#&^Rt=J3Q$1$MB$v!6 zh@#BKX(0F_jUy#f+~h+ne@4k^CQ7Q3pH&HmORHQm201z8Qd%*BQ|;}irK?<7o{@|0 zE=NrZw89nO#Ztf*ypq-cLgPLR> zcfwt8H{1jF!UJ$W$P0WB`D%CwI>3g9;SqQgI$;ew29LuN@FYA1YvE~#!!xiB*2A;# zoT4--8xTAXFTjiN68r~VhF4%Cyb7COGi-tX!fWt4ya8{*|KKfn8{UC;;XQaCK7cOx z5I%yB;S=~&&fL!sd=6j0m+%#Q4d1~3;am6)w!-)D1N;aH=!T!*XV?bYVF&yIJD~@5 zK`+Qb6PxKN{%fDkCAiy^p88Yld@a_XnimA^V5DpRzj$+Lh|b{f*-f;9yYYK6htIhx z7IONQq3=uKGPn}3!?-Z2=SA?`t5MdG%cErseku30vCogLBCb9x%g$>2hB}%Jbw5v@ zkh5dO#Nj;AUKd-f^Yl4>UiEdMJ$~&5N5|F(ab$Z7-##OUS6`#q`E4H&t3NEZ7w@=| zIJjm6uSn!QVo;nq%q>IhEgy^ubj>m^BD9fz4s7d}<_xBcIz+$eB_O4&8r(b^f6o<49im!noDh$!J(Y+5 zG%We>KY3eu?Xb>xIvJ{M>{?5@Lz#jx$bYCqv8H&btldMp)r7#x97wm)gVw@4nqv*o z=}fs?r#X~k?w7i1%gCj(JIw(!mI_L7e_t9IKLLRc_8qGFD{)b%!2kdN From 29b894a8a61254f6cc2414b532fe86ae1235d8a9 Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Tue, 15 Mar 2016 16:41:17 +0000 Subject: [PATCH 5/8] Race condition when there are 0 valid layouts xibosignage/xibo#744 --- MainForm.cs | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index 30304ab9..bd9a4612 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -50,6 +50,7 @@ public partial class MainForm : Form private int _scheduleId; private int _layoutId; private bool _screenSaver = false; + private bool _showingSplash = false; double _layoutWidth; double _layoutHeight; @@ -483,16 +484,19 @@ private void ChangeToNextLayout(string layoutPath) catch (Exception ex) { Trace.WriteLine(new LogMessage("MainForm - ChangeToNextLayout", "Layout Change to " + layoutPath + " failed. Exception raised was: " + ex.Message), LogType.Error.ToString()); - - ShowSplashScreen(); - // In 10 seconds fire the next layout? - System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); - timer.Interval = 10000; - timer.Tick += new EventHandler(splashScreenTimer_Tick); + if (!_showingSplash) + { + ShowSplashScreen(); + + // In 10 seconds fire the next layout? + System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); + timer.Interval = 15000; + timer.Tick += new EventHandler(splashScreenTimer_Tick); - // Start the timer - timer.Start(); + // Start the timer + timer.Start(); + } } // We have finished changing the layout @@ -512,6 +516,8 @@ void splashScreenTimer_Tick(object sender, EventArgs e) timer.Stop(); timer.Dispose(); + _showingSplash = false; + _schedule.NextLayout(); } @@ -520,13 +526,6 @@ void splashScreenTimer_Tick(object sender, EventArgs e) /// private void PrepareLayout(string layoutPath) { - // Create a start record for this layout - _stat = new Stat(); - _stat.type = StatType.Layout; - _stat.scheduleID = _scheduleId; - _stat.layoutID = _layoutId; - _stat.fromDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - // Get this layouts XML XmlDocument layoutXml = new XmlDocument(); DateTime layoutModifiedTime; @@ -677,6 +676,13 @@ private void PrepareLayout(string layoutPath) } } + // Create a start record for this layout + _stat = new Stat(); + _stat.type = StatType.Layout; + _stat.scheduleID = _scheduleId; + _stat.layoutID = _layoutId; + _stat.fromDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + foreach (XmlNode region in listRegions) { // Is there any media @@ -763,6 +769,8 @@ private static void GenerateBackgroundImage(string sourceFile, int backgroundWid /// private void ShowSplashScreen() { + _showingSplash = true; + if (!string.IsNullOrEmpty(ApplicationSettings.Default.SplashOverride)) { try From 2f419b43466b5bdf208000f0bb22fc26173aee87 Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Tue, 12 Apr 2016 10:08:45 +0100 Subject: [PATCH 6/8] Tone down the logging for network errors - no point recording network errors and then trying to send them when there is no network. xibosignage/xibo#748 --- Media/CefWebMedia.cs | 2 +- Media/IeWebMedia.cs | 2 +- XiboClient.v11.suo | Bin 197120 -> 195072 bytes XmdsAgents/FileAgent.cs | 18 +++++++++++++----- XmdsAgents/LibraryAgent.cs | 2 +- XmdsAgents/LogAgent.cs | 4 ++-- XmdsAgents/RegisterAgent.cs | 4 ++-- XmdsAgents/RequiredFilesAgent.cs | 4 ++-- XmdsAgents/ScheduleAgent.cs | 4 ++-- 9 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Media/CefWebMedia.cs b/Media/CefWebMedia.cs index 659a12ff..24df28e2 100644 --- a/Media/CefWebMedia.cs +++ b/Media/CefWebMedia.cs @@ -193,7 +193,7 @@ private void xmds_GetResourceCompleted(object sender, XiboClient.xmds.GetResourc // Success / Failure if (e.Error != null) { - Trace.WriteLine(new LogMessage("xmds_GetResource", "Unable to get Resource: " + e.Error.Message), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("xmds_GetResource", "Unable to get Resource: " + e.Error.Message), LogType.Info.ToString()); // We have failed to update from XMDS, do we have a cached file we can revert to if (File.Exists(_filePath)) diff --git a/Media/IeWebMedia.cs b/Media/IeWebMedia.cs index 29fa4e5a..dedf502d 100644 --- a/Media/IeWebMedia.cs +++ b/Media/IeWebMedia.cs @@ -188,7 +188,7 @@ private void xmds_GetResourceCompleted(object sender, XiboClient.xmds.GetResourc // Success / Failure if (e.Error != null) { - Trace.WriteLine(new LogMessage("xmds_GetResource", "Unable to get Resource: " + e.Error.Message), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("xmds_GetResource", "Unable to get Resource: " + e.Error.Message), LogType.Info.ToString()); // We have failed to update from XMDS, do we have a cached file we can revert to if (File.Exists(_filePath)) diff --git a/XiboClient.v11.suo b/XiboClient.v11.suo index 2fd5489d7f8ee177b16f3e79d1b97d970e984e90..cf31624917b74b6f3b05392417f5e34b210acf06 100644 GIT binary patch delta 572 zcmZ|KO(=vx7zgm3@$P!Dm}Tvq7$guVsJwa)PPTp z>V+fJemCSnCB(oBRbYevdZj8fs8@RK68q~vAGzp+VZLdCDLYplewr2J)}J@a`%s;n z6CruS8)aOC(wGmY8$k~FtK^(xP;bJbIhioyjsh+-$CYs1wmgkoUbhC?*5?n)?_Ok= z-+A_sQqPo2lRbW63g;u!D(JsAug@$kdiE;8Ri|C0b2Y%vBmFGEb^~90TAXa$E-aV5 ze;iren-#BnQJDw^)u68WxElMr%RzVjyfOLln2F&OO_uc+%Sc`7iVn&{RtW1yel~g^C_pNn#aB zF4F81gdB2Ms(6S9yN6y>_Min3L=nVe=%ptQf{9g3^?RiU5gqvP&12roeD4*%`ipl1 ziz$-JM>{-TNs?l~rbA0)uxZ!gqlx*_oIS&;6yJtI2>e3yLsOuIJPp-=0{B5W9^8kd z8$>~X=j4H;XsO^N)C1iO{Gc5aNRkrJ9YEAY*p6Hym-I2ax!hHyA=g$_82Hz6(X}15 z4XAJH?k=bsbO06ffH*(riH(Gj9S0H63#yne86=PDZw+WLL`F zs`jS0|MQip!_gy``LV$RJTvYXr!`v}tGmq$vN_3&yzZqTOcT%Grw0367m=up&*o>T zWH<7DGQv+4na-qtG^ZLRkF&qB>eetU%s+$^%J}Qx+5B)Dt%oYpJ-4pcdHICSpIMzs zL!G(z{^X5BH7aX+VDuf0SfKkJpcdz diff --git a/XmdsAgents/FileAgent.cs b/XmdsAgents/FileAgent.cs index 5ceb746a..059c75c1 100644 --- a/XmdsAgents/FileAgent.cs +++ b/XmdsAgents/FileAgent.cs @@ -123,7 +123,7 @@ public FileAgent() /// public void Run() { - Trace.WriteLine(new LogMessage("FileAgent - Run", "Thread Started"), LogType.Info.ToString()); + Trace.WriteLine(new LogMessage("FileAgent - Run", "Thread Started"), LogType.Audit.ToString()); // Get the required file id from the list of required files. RequiredFile file = _requiredFiles.GetRequiredFile(_requiredFileId, _requiredFileType); @@ -136,7 +136,7 @@ public void Run() try { - Trace.WriteLine(new LogMessage("FileAgent - Run", "Thread alive and Lock Obtained"), LogType.Info.ToString()); + Trace.WriteLine(new LogMessage("FileAgent - Run", "Thread alive and Lock Obtained"), LogType.Audit.ToString()); if (file.FileType == "resource") { @@ -187,7 +187,7 @@ public void Run() else { // Just error - we will pick it up again the next time we download - Trace.WriteLine(new LogMessage("FileAgent - Run", "Downloaded file failed MD5 check. Calculated [" + md5 + "] & XMDS [ " + file.Md5 + "] . " + file.SaveAs), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("FileAgent - Run", "Downloaded file failed MD5 check. Calculated [" + md5 + "] & XMDS [ " + file.Md5 + "] . " + file.SaveAs), LogType.Info.ToString()); } } else @@ -280,13 +280,21 @@ public void Run() else { // Just error - we will pick it up again the next time we download - Trace.WriteLine(new LogMessage("FileAgent - Run", "Downloaded file failed MD5 check. Calculated [" + md5 + "] & XMDS [ " + file.Md5 + "] . " + file.SaveAs), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("FileAgent - Run", "Downloaded file failed MD5 check. Calculated [" + md5 + "] & XMDS [ " + file.Md5 + "] . " + file.SaveAs), LogType.Info.ToString()); } } // Inform the Player thread that a file has been modified. OnComplete(file.Id, file.FileType); } + catch (WebException webEx) + { + // Log this message, but dont abort the thread + Trace.WriteLine(new LogMessage("FileAgent - Run", "Web Exception in Run: " + webEx.Message), LogType.Info.ToString()); + + // Mark as not downloading + file.Downloading = false; + } catch (Exception ex) { // Log this message, but dont abort the thread @@ -297,7 +305,7 @@ public void Run() } // Release the Semaphore - Trace.WriteLine(new LogMessage("FileAgent - Run", "Releasing Lock"), LogType.Info.ToString()); + Trace.WriteLine(new LogMessage("FileAgent - Run", "Releasing Lock"), LogType.Audit.ToString()); _fileDownloadLimit.Release(); } diff --git a/XmdsAgents/LibraryAgent.cs b/XmdsAgents/LibraryAgent.cs index b8fcf5c9..80ea75bd 100644 --- a/XmdsAgents/LibraryAgent.cs +++ b/XmdsAgents/LibraryAgent.cs @@ -92,7 +92,7 @@ public void Run() // Only do something if enabled if (!ApplicationSettings.Default.EnableExpiredFileDeletion) { - Trace.WriteLine(new LogMessage("LibraryAgent - Run", "Expired File Deletion Disabled"), LogType.Info.ToString()); + Trace.WriteLine(new LogMessage("LibraryAgent - Run", "Expired File Deletion Disabled"), LogType.Audit.ToString()); return; } diff --git a/XmdsAgents/LogAgent.cs b/XmdsAgents/LogAgent.cs index 46daf08f..9a3dc84a 100644 --- a/XmdsAgents/LogAgent.cs +++ b/XmdsAgents/LogAgent.cs @@ -63,7 +63,7 @@ public void Run() HardwareKey key = new HardwareKey(); - Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Woken and Lock Obtained"), LogType.Info.ToString()); + Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Woken and Lock Obtained"), LogType.Audit.ToString()); using (xmds.xmds xmds = new xmds.xmds()) { @@ -84,7 +84,7 @@ public void Run() ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread - Trace.WriteLine(new LogMessage("LogAgent - Run", "WebException in Run: " + webEx.Message), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("LogAgent - Run", "WebException in Run: " + webEx.Message), LogType.Info.ToString()); } catch (Exception ex) { diff --git a/XmdsAgents/RegisterAgent.cs b/XmdsAgents/RegisterAgent.cs index cbdb8326..7c14ce6c 100644 --- a/XmdsAgents/RegisterAgent.cs +++ b/XmdsAgents/RegisterAgent.cs @@ -91,12 +91,12 @@ public void Run() ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread - Trace.WriteLine(new LogMessage("RegisterAgent - Run", "WebException in Run: " + webEx.Message), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("RegisterAgent - Run", "WebException in Run: " + webEx.Message), LogType.Info.ToString()); } catch (Exception ex) { // Log this message, but dont abort the thread - Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Exception in Run: " + ex.Message), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Exception in Run: " + ex.Message), LogType.Info.ToString()); } } diff --git a/XmdsAgents/RequiredFilesAgent.cs b/XmdsAgents/RequiredFilesAgent.cs index 63a8d9af..31715055 100644 --- a/XmdsAgents/RequiredFilesAgent.cs +++ b/XmdsAgents/RequiredFilesAgent.cs @@ -130,7 +130,7 @@ public void Run() { _clientInfoForm.RequiredFilesStatus = string.Format("Waiting: {0} Active Downloads", filesToDownload.ToString()); - Trace.WriteLine(new LogMessage("RequiredFilesAgent - Run", "Currently Downloading Files, skipping collect"), LogType.Info.ToString()); + Trace.WriteLine(new LogMessage("RequiredFilesAgent - Run", "Currently Downloading Files, skipping collect"), LogType.Audit.ToString()); } else { @@ -219,7 +219,7 @@ public void Run() ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread - Trace.WriteLine(new LogMessage("RequiredFilesAgent - Run", "WebException in Run: " + webEx.Message), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("RequiredFilesAgent - Run", "WebException in Run: " + webEx.Message), LogType.Info.ToString()); _clientInfoForm.RequiredFilesStatus = "Error: " + webEx.Message; } diff --git a/XmdsAgents/ScheduleAgent.cs b/XmdsAgents/ScheduleAgent.cs index 20998677..c825286c 100644 --- a/XmdsAgents/ScheduleAgent.cs +++ b/XmdsAgents/ScheduleAgent.cs @@ -112,7 +112,7 @@ public void Run() // If we are restarting, reset _manualReset.Reset(); - Trace.WriteLine(new LogMessage("ScheduleAgent - Run", "Thread Woken and Lock Obtained"), LogType.Info.ToString()); + Trace.WriteLine(new LogMessage("ScheduleAgent - Run", "Thread Woken and Lock Obtained"), LogType.Audit.ToString()); _clientInfoForm.ScheduleStatus = "Running: Get Data from Xibo Server"; @@ -156,7 +156,7 @@ public void Run() ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread - Trace.WriteLine(new LogMessage("ScheduleAgent - Run", "WebException in Run: " + webEx.Message), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("ScheduleAgent - Run", "WebException in Run: " + webEx.Message), LogType.Info.ToString()); _clientInfoForm.ScheduleStatus = "Error: " + webEx.Message; } From e2da9df4e54834b7e36a10fc9135dde0e73d7a6f Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Tue, 12 Apr 2016 11:43:52 +0100 Subject: [PATCH 7/8] Tone down schedule manager logging. No need to Error log with each invalid layout. --- Logic/ScheduleManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Logic/ScheduleManager.cs b/Logic/ScheduleManager.cs index fbaf791b..af3714ef 100644 --- a/Logic/ScheduleManager.cs +++ b/Logic/ScheduleManager.cs @@ -277,7 +277,7 @@ private Collection LoadNewSchdule() { if (!_cacheManager.IsValidLayout(layout.id + ".xlf")) { - Trace.WriteLine(new LogMessage("ScheduleManager - LoadNewSchedule", "Layout invalid: " + layout.id), LogType.Error.ToString()); + Trace.WriteLine(new LogMessage("ScheduleManager - LoadNewSchedule", "Layout invalid: " + layout.id), LogType.Info.ToString()); continue; } } From 5b25f6e89e55ba8d2024b3819dfe7cfd11690dbe Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Tue, 12 Apr 2016 11:52:55 +0100 Subject: [PATCH 8/8] Lazy Loading of GetResource (for IE media) xibosignage/xibo#759 --- Media/IeWebMedia.cs | 123 +++++++++++++++++++++++++++++++------------- XiboClient.v11.suo | Bin 195072 -> 195072 bytes 2 files changed, 87 insertions(+), 36 deletions(-) diff --git a/Media/IeWebMedia.cs b/Media/IeWebMedia.cs index dedf502d..48ffab6c 100644 --- a/Media/IeWebMedia.cs +++ b/Media/IeWebMedia.cs @@ -38,6 +38,7 @@ class IeWebMedia : Media private RegionOptions _options; private WebBrowser _webBrowser; private int _documentCompletedCount = 0; + private bool _reloadOnXmdsRefresh = false; public IeWebMedia(RegionOptions options) : base(options.width, options.height, options.top, options.left) @@ -74,21 +75,17 @@ public IeWebMedia(RegionOptions options) // Nativate directly _webBrowser.Navigate(_filePath); } - else + else if (HtmlReady()) { - // Check to see if the HTML is ready for us. - if (HtmlReady()) - { - // Write to temporary file - ReadControlMeta(); + // Write to temporary file + ReadControlMeta(); - // Navigate to temp file - _webBrowser.Navigate(_filePath); - } - else - { - RefreshFromXmds(); - } + // Navigate to temp file + _webBrowser.Navigate(_filePath); + } + else + { + Debug.WriteLine("HTML Resource is not ready to be shown (meaning the file doesn't exist at all) - wait for the download the occur and then show"); } Controls.Add(_webBrowser); @@ -97,47 +94,85 @@ public IeWebMedia(RegionOptions options) Show(); } + /// + /// Web Browser finished loading document + /// + /// + /// void _webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { _documentCompletedCount++; + // Prevent double document completions if (_documentCompletedCount > 1) return; // Start the timer base.RestartTimer(); + // Don't do anything if we are already disposed if (_disposed) return; + // Show the browser _webBrowser.Visible = true; } + /// + /// Is the cached HTML ready + /// + /// true if there is something to show, false if nothing private bool HtmlReady() { // Check for cached resource files in the library // We want to check the file exists first - if (!File.Exists(_filePath) || _options.updateInterval == 0) + if (!File.Exists(_filePath)) + { + // File doesn't exist at all. + _reloadOnXmdsRefresh = true; + + // Refresh + RefreshFromXmds(); + + // Return false return false; + } // It exists - therefore we want to get the last time it was updated DateTime lastWriteDate = File.GetLastWriteTime(_filePath); + // Does it update every time? + if (_options.updateInterval == 0) + { + // Comment in to force a re-request with each reload of the widget + //_reloadOnXmdsRefresh = true; + + // File exists but needs updating + RefreshFromXmds(); + + // Comment in to force a re-request with each reload of the widget + //return false; + } // Compare the last time it was updated to the layout modified time (always refresh when the layout has been modified) // Also compare to the update interval (refresh if it has not been updated for longer than the update interval) - if (_options.LayoutModifiedDate.CompareTo(lastWriteDate) > 0 || DateTime.Now.CompareTo(lastWriteDate.AddMinutes(_options.updateInterval)) > 0) + else if (_options.LayoutModifiedDate.CompareTo(lastWriteDate) > 0 || DateTime.Now.CompareTo(lastWriteDate.AddMinutes(_options.updateInterval)) > 0) { - return false; + // File exists but needs updating. + RefreshFromXmds(); } else { - UpdateCacheIfNecessary(); - return true; + // File exists and is in-date - nothing to do } + + // Refresh the local file cache with any new dimensions, etc. + UpdateCacheIfNecessary(); + + return true; } /// - /// Updates the position of the background and saves to a temporary file + /// Pulls the duration out of the temporary file and sets the media Duration to the same /// private void ReadControlMeta() { @@ -159,7 +194,7 @@ private void ReadControlMeta() } catch { - Trace.WriteLine(new LogMessage("Html - SaveToTemporaryFile", "Unable to pull duration using RegEx").ToString()); + Trace.WriteLine(new LogMessage("Html - ReadControlMeta", "Unable to pull duration using RegEx").ToString()); } } } @@ -190,19 +225,28 @@ private void xmds_GetResourceCompleted(object sender, XiboClient.xmds.GetResourc { Trace.WriteLine(new LogMessage("xmds_GetResource", "Unable to get Resource: " + e.Error.Message), LogType.Info.ToString()); - // We have failed to update from XMDS, do we have a cached file we can revert to - if (File.Exists(_filePath)) + // We have failed to update from XMDS + // id we have been asked to reload on XmdsRefresh, check to see if we have a file to load, + // if not expire on a short timer. + if (_reloadOnXmdsRefresh) { - // Cached file to revert to - UpdateCacheIfNecessary(); - - _webBrowser.Navigate(_filePath); - } - else - { - // No cache to revert to - // Start the timer so that we expire - base.RenderMedia(); + if (File.Exists(_filePath)) + { + // Cached file to revert to + UpdateCacheIfNecessary(); + + // Navigate to the file + _webBrowser.Navigate(_filePath); + } + else + { + // No cache to revert to + Trace.WriteLine(new LogMessage("xmds_GetResource", "We haven't been able to download this widget and there isn't a pre-cached one to use. Skipping."), LogType.Info.ToString()); + + // Start the timer so that we expire + Duration = 2; + base.RenderMedia(); + } } } else @@ -225,6 +269,10 @@ private void xmds_GetResourceCompleted(object sender, XiboClient.xmds.GetResourc string html = cachedFile.Replace("", ""); html = html.Replace("[[ViewPortWidth]]", _width.ToString()); + // Comment in to write out the update date at the end of the file (in the body) + // This is useful if you want to check how frequently the file is updating + //html = html.Replace("", "

" + DateTime.Now.ToString() + "

"); + // Write to the library using (StreamWriter sw = new StreamWriter(File.Open(_filePath, FileMode.Create, FileAccess.Write, FileShare.Read))) { @@ -232,11 +280,14 @@ private void xmds_GetResourceCompleted(object sender, XiboClient.xmds.GetResourc sw.Close(); } - // Read the control meta back out - ReadControlMeta(); + if (_reloadOnXmdsRefresh) + { + // Read the control meta back out + ReadControlMeta(); - // Handle Navigate in here because we will not have done it during first load - _webBrowser.Navigate(_filePath); + // Handle Navigate in here because we will not have done it during first load + _webBrowser.Navigate(_filePath); + } } } catch (ObjectDisposedException) diff --git a/XiboClient.v11.suo b/XiboClient.v11.suo index cf31624917b74b6f3b05392417f5e34b210acf06..414f33f6ff19cd2a41d5a2aeefff53e35cbb54a8 100644 GIT binary patch delta 1370 zcma)*T}%{L6vy`tv+ls|hLKgFb&*l%?zpbF2qe`4E-o=@APZ(2CBXuX+CI{VxqlznOc^ znS1X!|2sEfITM!i+fcD&%b04jt-&w{ET&Q^j^<1>rG$`Zy;NeKZ#zBr1AQV5h*|nm ziYl9sUje9PN05%@G%7wgE0+Sgn^!px*a9Tvl3Fa8dK+FL(7;O$z<94b_#TiB;8BKg zC0GSypwmIQ@DT5~6RZZs;3OykLEr%2gDrqpDZ<+c@<9z)2SR{zxp-G+#_U&NycxU$ zhC7RBURGp|oBzno+3rKLpK9mcw0p7~s|0uL>F0GItnJm#xwhqg~B0T7r%yXT5e6e;oST($#DJj|M@G{Vj;z5{^jv0q{T{U zN~)lEENT~ADc#;5G_9CR80)6&oN`@2^aNlt)M+8}Npm5tV;J;v7-qCh3U$wSBfs?Y z(cg_z`SedF)Ln7Rl#bMkTw%wTrT=~X(Rovg&55KpvZS^b}}{G$^|e-<{3H3ufdnJ2)DOdxq$%i7HA=c9nF5aF~v^1z{Wri)2N&`-}3kkGdb9x%4#k`|NYNwyT)#wU&-`NHlz< zk}CD4oUdyNF|Up`TrQwrpL)$F`bsfcw^dY8Rp{m`-7N~EyjG|Sx7OBBMn5l1|wZ! KGSVeo{pMdtT(`ym delta 1389 zcmb7^T}%{L6vyu!W}R7gw~S>)swhK2KzE_5Kocprs8mt0U}6C)3LD zaqgLW{&RLB30EZHIu_`6XDLpvAw<3qA`MI@lSw!s&u>XeSxC7`j-&hH;ZsBhl+WZ3 z^hl}K5t1xG3~dei=}=mou3$3n*+P+rvz!HN9+GNKRV79X!D?WFCpe!D&(E3*?**Jw zgI@q%19>hemEN|z{z^$3swF_0X<96`L(c7w#zS*w9!>Ke*&j} z0k^><;E?IQ-A(qm>sP6>(yT1{p~y~nO!@y(q~|MEbB(?Z8ER8mDBL_sLuCO9Z;!^k zrcP#Ko>TIr9DhbM*3&g*1tn5G+!T#3x#n<6?i!YhZ{z+3gOh+Q?jHL4U0sW?$}I!4 zlN;ZbR1>;PeV0n9w0(=wG~#LgWK){_}Ds z_}(gMJU+DZ>gufV5&O-Wa~TthhG|W(lp>uGvd&ddMZjAP#VE6i%X8T{d{4Ar()louGSxM*K(`Kw9Rdk z(pvt+So`~`TQ~3dsAl?7VC?$kmYG_reIFVlAGQ5-