这是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
13 changes: 12 additions & 1 deletion Control/WatchDogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class WatchDogManager
public static void Start()
{
// Check to see if the WatchDog EXE exists where we expect it to be
// Uncomment to test local watchdog install.
//string path = @"C:\Program Files (x86)\Xibo Player\watchdog\x86\XiboClientWatchdog.exe";
string path = Path.GetDirectoryName(Application.ExecutablePath) + @"\watchdog\x86\XiboClientWatchdog.exe";
string args = "-p \"" + Application.ExecutablePath + "\" -l \"" + ApplicationSettings.Default.LibraryPath + "\"";

Expand All @@ -21,7 +23,16 @@ public static void Start()
{
try
{
Process.Start(path, args);
Process process = new Process();
ProcessStartInfo info = new ProcessStartInfo();

info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
info.FileName = "cmd.exe";
info.Arguments = "/c start \"watchdog\" \"" + path + "\" " + args;

process.StartInfo = info;
process.Start();
}
catch (Exception e)
{
Expand Down
27 changes: 27 additions & 0 deletions Log/ClientInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public partial class ClientInfo : Form
public delegate void StatusDelegate(string status);
public delegate void AddLogMessage(string message, LogType logType);

// Delegate for updating the status file
public delegate void UpdateStatusFile();

/// <summary>
/// Set the schedule status
/// </summary>
Expand Down Expand Up @@ -244,5 +247,29 @@ private void saveFileDialog_FileOk(object sender, CancelEventArgs e)

MessageBox.Show("Log saved as " + saveFileDialog.FileName, "Log Saved");
}

/// <summary>
/// Update Status Marker File
/// </summary>
public void UpdateStatusMarkerFile()
{
if (InvokeRequired)
{
BeginInvoke(new UpdateStatusFile(updateStatusFile));
}
else
{
updateStatusFile();
}
}

/// <summary>
/// Update status file
/// </summary>
private void updateStatusFile()
{
File.WriteAllText(Path.Combine(ApplicationSettings.Default.LibraryPath, "status.json"),
"{\"lastActivity\":\"" + DateTime.Now.ToString() + "\",\"state\":\"" + Thread.State.ToString() + "\",\"xmdsLastActivity\":\"" + ApplicationSettings.Default.XmdsLastConnection.ToString() + "\",\"xmdsCollectInterval\":\"" + ApplicationSettings.Default.CollectInterval.ToString() + "\"}");
}
}
}
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.8";
private string _clientVersion = "1.7.9";
private string _version = "4";
private int _clientCodeVersion = 112;
private int _clientCodeVersion = 113;

public string ClientVersion { get { return _clientVersion; } }
public string Version { get { return _version; } }
Expand Down
87 changes: 0 additions & 87 deletions Logic/CacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,93 +231,6 @@ public bool IsValidPath(String path)
}
}

/// <summary>
/// Is the provided layout file a valid layout (has all media)
/// </summary>
/// <param name="layoutFile"></param>
/// <returns></returns>
public bool IsValidLayout(string layoutFile)
{
lock (_locker)
{
Debug.WriteLine("Checking if Layout " + layoutFile + " is valid");

if (!IsValidPath(layoutFile))
return false;


// Load the XLF, get all media ID's
XmlDocument layoutXml = new XmlDocument();
layoutXml.Load(ApplicationSettings.Default.LibraryPath + @"\" + layoutFile);

try
{
XmlNodeList mediaNodes = layoutXml.SelectNodes("//media");

// Store some information about the validity of local video to decide if this layout should be valid or not.
int countInvalidLocalVideo = 0;

foreach (XmlNode media in mediaNodes)
{
// Is this a stored media type?
switch (media.Attributes["type"].Value)
{
case "video":
case "image":
case "flash":
case "powerpoint":

// Get the path and see if its
if (!IsValidPath(GetUri(media)))
{
Trace.WriteLine(new LogMessage("CacheManager - IsValidLayout", "Invalid Media: " + media.Attributes["id"].Value.ToString()), LogType.Audit.ToString());
return false;
}

break;

default:
continue;
}
}

// If the number of invalid local video elements is equal to the number of elements on the layout, then don't show
if (countInvalidLocalVideo == mediaNodes.Count)
return false;
}
catch (Exception ex)
{
Trace.WriteLine(new LogMessage("CacheManager - IsValidLayout", "Exception checking media. " + ex.Message), LogType.Audit.ToString());
return false;
}

// Also check to see if there is a background image that needs to be downloaded
try
{
XmlNode layoutNode = layoutXml.SelectSingleNode("/layout");
XmlAttributeCollection layoutAttributes = layoutNode.Attributes;

if (layoutAttributes["background"] != null && !string.IsNullOrEmpty(layoutAttributes["background"].Value))
{
if (!IsValidPath(layoutAttributes["background"].Value))
{
Debug.WriteLine("Invalid background: " + layoutAttributes["background"].Value);
return false;
}
}
}
catch
{
// We dont want a missing background attribute to stop this process
return true;
}

Debug.WriteLine("Layout " + layoutFile + " is valid");

return true;
}
}

/// <summary>
/// Get the URI of this media item
/// </summary>
Expand Down
51 changes: 50 additions & 1 deletion Logic/Schedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ class Schedule
private int _currentLayout = 0;
private string _scheduleLocation;

/// <summary>
/// The current layout id
/// </summary>
public int CurrentLayoutId
{
get
{
return _currentLayoutId;
}
set
{
_currentLayoutId = value;

if (_scheduleManager != null)
_scheduleManager.CurrentLayoutId = _currentLayoutId;
}
}
private int _currentLayoutId;

private bool _forceChange = false;

// Key
Expand Down Expand Up @@ -118,6 +137,7 @@ public Schedule(string scheduleLocation, ref CacheManager cacheManager, ref Clie
_scheduleManager = new ScheduleManager(_cacheManager, scheduleLocation);
_scheduleManager.OnNewScheduleAvailable += new ScheduleManager.OnNewScheduleAvailableDelegate(_scheduleManager_OnNewScheduleAvailable);
_scheduleManager.OnRefreshSchedule += new ScheduleManager.OnRefreshScheduleDelegate(_scheduleManager_OnRefreshSchedule);
_scheduleManager.OnScheduleManagerCheckComplete += _scheduleManager_OnScheduleManagerCheckComplete;
_scheduleManager.ClientInfoForm = _clientInfoForm;

// Create a schedule manager thread
Expand Down Expand Up @@ -206,6 +226,35 @@ void _scheduleManager_OnRefreshSchedule()
_layoutSchedule = _scheduleManager.CurrentSchedule;
}

/// <summary>
/// Schedule Manager has completed its check cycle
/// </summary>
void _scheduleManager_OnScheduleManagerCheckComplete()
{
if (agentThreadsAlive())
{
// Update status marker on the main thread.
_clientInfoForm.UpdateStatusMarkerFile();
}
else
{
Trace.WriteLine(new LogMessage("Schedule - OnScheduleManagerCheckComplete", "Agent threads are dead, not updating status.json"), LogType.Error.ToString());
}
}

/// <summary>
/// Are all the required agent threads alive?
/// </summary>
/// <returns></returns>
private bool agentThreadsAlive()
{
return _scheduleAgentThread.IsAlive &&
_registerAgentThread.IsAlive &&
_requiredFilesAgentThread.IsAlive &&
_logAgentThread.IsAlive &&
_libraryAgentThread.IsAlive;
}

/// <summary>
/// Moves the layout on
/// </summary>
Expand Down Expand Up @@ -268,7 +317,7 @@ private void LayoutFileModified(string layoutPath)
if (_layoutSchedule[_currentLayout].layoutFile == ApplicationSettings.Default.LibraryPath + @"\" + layoutPath)
{
// What happens if the action of downloading actually invalidates this layout?
if (!_cacheManager.IsValidLayout(layoutPath))
if (!_cacheManager.IsValidPath(layoutPath))
{
Trace.WriteLine(new LogMessage("Schedule - LayoutFileModified", "The current layout is now invalid, refreshing the current schedule."), LogType.Audit.ToString());

Expand Down
Loading