这是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
45 changes: 36 additions & 9 deletions Control/Region.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Xibo - Digitial Signage - http://www.xibo.org.uk
* Copyright (C) 2006-2014 Daniel Garner
* Copyright (C) 2006-2015 Daniel Garner
*
* This file is part of Xibo.
*
Expand Down Expand Up @@ -38,8 +38,8 @@ class Region : Panel

private Media _media;
private RegionOptions _options;
public bool _hasExpired = false;
public bool _layoutExpired = false;
private bool _hasExpired = false;
private bool _layoutExpired = false;
private int _currentSequence = -1;

// Stat objects
Expand Down Expand Up @@ -101,6 +101,23 @@ public RegionOptions regionOptions
}
}

/// <summary>
/// Inform the region that the layout has expired
/// </summary>
public void setLayoutExpired()
{
_layoutExpired = true;
}

/// <summary>
/// Has this region expired
/// </summary>
/// <returns></returns>
public bool hasExpired()
{
return _hasExpired;
}

///<summary>
/// Evaulates the change in options
///</summary>
Expand Down Expand Up @@ -343,6 +360,9 @@ private void ParseOptionsForMediaNode(XmlNode mediaNode, XmlAttributeCollection
// There will be some stuff on option nodes
XmlNode optionNode = mediaNode.FirstChild;

// Track if an update interval has been provided in the XLF
bool updateIntervalProvided = false;

// Loop through each option node
foreach (XmlNode option in optionNode.ChildNodes)
{
Expand Down Expand Up @@ -371,6 +391,8 @@ private void ParseOptionsForMediaNode(XmlNode mediaNode, XmlAttributeCollection
}
else if (option.Name == "updateInterval")
{
updateIntervalProvided = true;

try
{
_options.updateInterval = int.Parse(option.InnerText);
Expand Down Expand Up @@ -410,6 +432,10 @@ private void ParseOptionsForMediaNode(XmlNode mediaNode, XmlAttributeCollection
_options.javaScript = raw.InnerText;
}
}

// Media Types without an update interval should be set to something rather high
if (!updateIntervalProvided)
_options.updateInterval = int.MaxValue;
}

/// <summary>
Expand Down Expand Up @@ -508,10 +534,9 @@ private Media CreateNextMediaNode(RegionOptions options)
/// <param name="media"></param>
private void StartMedia(Media media)
{
media.RenderMedia();

Trace.WriteLine(new LogMessage("Region - StartMedia", "Starting media"), LogType.Audit.ToString());

media.RenderMedia();
Controls.Add(media);
}

Expand All @@ -536,8 +561,7 @@ private void StopMedia(Media media)
}
catch (Exception ex)
{
Debug.WriteLine("No media to remove");
Debug.WriteLine(ex.Message);
Trace.WriteLine(new LogMessage("Region - Stop Media", "Unable to dispose. Ex = " + ex.Message), LogType.Audit.ToString());
}
}

Expand Down Expand Up @@ -585,6 +609,10 @@ private void media_DurationElapsedEvent(int filesPlayed)
// Increment the _current sequence by the number of filesPlayed (minus 1)
_currentSequence = _currentSequence + (filesPlayed - 1);

// If this layout has been expired we know that everything will soon be torn down, so do nothing
if (_layoutExpired)
return;

// make some decisions about what to do next
try
{
Expand Down Expand Up @@ -641,8 +669,7 @@ protected override void Dispose(bool disposing)
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
Debug.WriteLine("There was no media to dispose", "Region - Dispose");
Trace.WriteLine(new LogMessage("Region - Dispose", "Unable to dispose media. Ex = " + ex.Message), LogType.Audit.ToString());
}
finally
{
Expand Down
4 changes: 4 additions & 0 deletions Log/ClientInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ public void AddToLogGrid(string message, LogType logType)
return;
}

// Prevent the log grid getting too large (clear at 500 messages)
if (logDataGridView.RowCount > 500)
logDataGridView.Rows.Clear();

int newRow = logDataGridView.Rows.Add();

LogMessage logMessage;
Expand Down
6 changes: 3 additions & 3 deletions Log/LogMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public override string ToString()
// Just do this with a string builder rather than an XML builder.
String theMessage;

theMessage = String.Format("<message>{0}</message>", SecurityElement.Escape(_message));
theMessage += String.Format("<method>{0}</method>", _method);
theMessage += String.Format("<logdate>{0}</logdate>", LogDate);
theMessage = String.Format("<logdate>{0}</logdate>", LogDate);
theMessage += String.Format("<thread>{0}</thread>", _thread);
theMessage += String.Format("<method>{0}</method>", _method);
theMessage += String.Format("<message>{0}</message>", SecurityElement.Escape(_message));

if (_scheduleId != 0) theMessage += String.Format("<scheduleid>{0}</scheduleid>", _scheduleId.ToString());
if (_layoutId != 0) theMessage += String.Format("<layoutid>{0}</layoutid>", _scheduleId.ToString());
Expand Down
106 changes: 61 additions & 45 deletions Log/StatLog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Xibo - Digitial Signage - http://www.xibo.org.uk
* Copyright (C) 2009-2014 Spring Signage Ltd
* Copyright (C) 2009-2015 Spring Signage Ltd
*
* This file is part of Xibo.
*
Expand Down Expand Up @@ -32,6 +32,7 @@ namespace XiboClient
{
class StatLog
{
public static object _locker = new object();
private Collection<Stat> _stats;
private HardwareKey _hardwareKey;

Expand Down Expand Up @@ -194,58 +195,73 @@ private void FlushToFile()
/// </summary>
private void ProcessQueueToXmds()
{
Debug.WriteLine(new LogMessage("FlushToXmds", String.Format("IN")), LogType.Audit.ToString());

// If we haven't had a successful connection recently, then don't log
if (ApplicationSettings.Default.XmdsLastConnection.AddSeconds((int)ApplicationSettings.Default.CollectInterval) < DateTime.Now)
return;

// Get a list of all the log files waiting to be sent to XMDS.
string[] logFiles = Directory.GetFiles(ApplicationSettings.Default.LibraryPath, "*" + ApplicationSettings.Default.StatsLogFile + "*");

foreach (string fileName in logFiles)
try
{
// If we have some, create an XMDS object
using (xmds.xmds logtoXmds = new xmds.xmds())
{
logtoXmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds;

// construct the log message
StringBuilder builder = new StringBuilder();
builder.Append("<log>");

foreach (string entry in File.ReadAllLines(fileName))
builder.Append(entry);

builder.Append("</log>");
// If we haven't had a successful connection recently, then don't log
if (ApplicationSettings.Default.XmdsLastConnection.AddSeconds((int)ApplicationSettings.Default.CollectInterval) < DateTime.Now)
return;

try
{
logtoXmds.SubmitStats(ApplicationSettings.Default.ServerKey, _hardwareKey.Key, builder.ToString());

// Delete the file we are on
File.Delete(fileName);
}
catch (WebException webEx)
{
// Increment the quantity of XMDS failures and bail out
ApplicationSettings.Default.IncrementXmdsErrorCount();
lock (_locker)
{
// Get a list of all the log files waiting to be sent to XMDS.
string[] logFiles = Directory.GetFiles(ApplicationSettings.Default.LibraryPath, "*" + ApplicationSettings.Default.StatsLogFile + "*");

// Log this message, but dont abort the thread
Trace.WriteLine(new LogMessage("ProcessQueueToXmds", "WebException: " + webEx.Message), LogType.Error.ToString());
// Track processed files
int filesProcessed = 0;

// Drop out the loop
break;
}
catch (Exception e)
// Loop through each file
foreach (string fileName in logFiles)
{
Trace.WriteLine(new LogMessage("FlushToXmds", string.Format("Exception when submitting to XMDS: {0}", e.Message)), LogType.Error.ToString());
// Only process as many files in one go as configured
if (filesProcessed >= ApplicationSettings.Default.MaxLogFileUploads)
break;

// If we have some, create an XMDS object
using (xmds.xmds logtoXmds = new xmds.xmds())
{
logtoXmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds;

// construct the log message
StringBuilder builder = new StringBuilder();
builder.Append("<log>");

foreach (string entry in File.ReadAllLines(fileName))
builder.Append(entry);

builder.Append("</log>");

try
{
logtoXmds.SubmitStats(ApplicationSettings.Default.ServerKey, _hardwareKey.Key, builder.ToString());

// Delete the file we are on
File.Delete(fileName);
}
catch (WebException webEx)
{
// Increment the quantity of XMDS failures and bail out
ApplicationSettings.Default.IncrementXmdsErrorCount();

// Log this message, but dont abort the thread
Trace.WriteLine(new LogMessage("ProcessQueueToXmds", "WebException: " + webEx.Message), LogType.Error.ToString());

// Drop out the loop
break;
}
catch (Exception e)
{
Trace.WriteLine(new LogMessage("FlushToXmds", string.Format("Exception when submitting to XMDS: {0}", e.Message)), LogType.Error.ToString());
}

filesProcessed++;
}
}
}
}

// Log out
Debug.WriteLine(new LogMessage("FlushToXmds", String.Format("OUT")), LogType.Audit.ToString());
catch (Exception e)
{
Trace.WriteLine(new LogMessage("FlushToXmds", string.Format("Unknown Exception: {0}", e.Message)), LogType.Error.ToString());
}
}
}

Expand Down
Loading