这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Logic/ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }
Expand Down
2 changes: 1 addition & 1 deletion Logic/ScheduleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private Collection<LayoutSchedule> 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;
}
}
Expand Down
38 changes: 23 additions & 15 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -512,6 +516,8 @@ void splashScreenTimer_Tick(object sender, EventArgs e)
timer.Stop();
timer.Dispose();

_showingSplash = false;

_schedule.NextLayout();
}

Expand All @@ -520,13 +526,6 @@ void splashScreenTimer_Tick(object sender, EventArgs e)
/// </summary>
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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -763,6 +769,8 @@ private static void GenerateBackgroundImage(string sourceFile, int backgroundWid
/// </summary>
private void ShowSplashScreen()
{
_showingSplash = true;

if (!string.IsNullOrEmpty(ApplicationSettings.Default.SplashOverride))
{
try
Expand Down
2 changes: 1 addition & 1 deletion Media/CefWebMedia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
125 changes: 88 additions & 37 deletions Media/IeWebMedia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -97,47 +94,85 @@ public IeWebMedia(RegionOptions options)
Show();
}

/// <summary>
/// Web Browser finished loading document
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}

/// <summary>
/// Is the cached HTML ready
/// </summary>
/// <returns>true if there is something to show, false if nothing</returns>
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;
}

/// <summary>
/// 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
/// </summary>
private void ReadControlMeta()
{
Expand All @@ -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());
}
}
}
Expand Down Expand Up @@ -188,21 +223,30 @@ 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))
// 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
Expand All @@ -225,18 +269,25 @@ private void xmds_GetResourceCompleted(object sender, XiboClient.xmds.GetResourc
string html = cachedFile.Replace("</head>", "<style type='text/css'>body {" + bodyStyle + " }</style></head>");
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("<body>", "<body><h1 style='color:white'>" + DateTime.Now.ToString() + "</h1>");

// Write to the library
using (StreamWriter sw = new StreamWriter(File.Open(_filePath, FileMode.Create, FileAccess.Write, FileShare.Read)))
{
sw.Write(html);
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)
Expand Down
3 changes: 2 additions & 1 deletion Media/Media.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <summary>
Expand Down
Binary file modified XiboClient.v11.suo
Binary file not shown.
18 changes: 13 additions & 5 deletions XmdsAgents/FileAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public FileAgent()
/// </summary>
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);
Expand All @@ -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")
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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();
}
Expand Down
Loading