diff --git a/src/Ghosts.Domain/Code/WorkingHours.cs b/src/Ghosts.Domain/Code/WorkingHours.cs index f0e18c63..36841820 100755 --- a/src/Ghosts.Domain/Code/WorkingHours.cs +++ b/src/Ghosts.Domain/Code/WorkingHours.cs @@ -3,6 +3,7 @@ using System; using System.Linq; using System.Threading; +using Ghosts.Domain.Code.Helpers; using NLog; namespace Ghosts.Domain.Code @@ -98,6 +99,7 @@ private static void Sleep(TimelineHandler handler, int msToSleep) private static void Sleep(TimelineHandler handler, TimeSpan sleep) { + // TODO: We need a way to kill this handler like handler.SafeKill(); Sleep(handler, (int)sleep.TotalMilliseconds); } } diff --git a/src/ghosts.client.linux/Handlers/Sftp.cs b/src/ghosts.client.linux/Handlers/Sftp.cs index ecc43c6d..d75ce396 100644 --- a/src/ghosts.client.linux/Handlers/Sftp.cs +++ b/src/ghosts.client.linux/Handlers/Sftp.cs @@ -6,7 +6,6 @@ using Ghosts.Domain; using Newtonsoft.Json; using Ghosts.Domain.Code; -using WorkingHours = ghosts.client.linux.Infrastructure.WorkingHours; namespace ghosts.client.linux.handlers { diff --git a/src/ghosts.client.linux/Handlers/Ssh.cs b/src/ghosts.client.linux/Handlers/Ssh.cs index 4f8cab80..ec89e45a 100644 --- a/src/ghosts.client.linux/Handlers/Ssh.cs +++ b/src/ghosts.client.linux/Handlers/Ssh.cs @@ -6,7 +6,6 @@ using Ghosts.Domain; using Newtonsoft.Json; using Ghosts.Domain.Code; -using WorkingHours = ghosts.client.linux.Infrastructure.WorkingHours; /* * Used Package Renci.sshNet @@ -28,7 +27,6 @@ namespace ghosts.client.linux.handlers /// public class Ssh : BaseHandler { - private Credentials CurrentCreds = null; private SshSupport CurrentSshSupport = null; //current SshSupport for this object public int jitterfactor = 0; @@ -216,11 +214,5 @@ public void Command(TimelineHandler handler, TimelineEvent timelineEvent, string } } - - - - - } - } diff --git a/src/ghosts.client.linux/Infrastructure/WorkingHours.cs b/src/ghosts.client.linux/Infrastructure/WorkingHours.cs deleted file mode 100644 index 30793aa5..00000000 --- a/src/ghosts.client.linux/Infrastructure/WorkingHours.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2017 Carnegie Mellon University. All Rights Reserved. See LICENSE.md file for terms. - -using System; -using System.Threading; -using NLog; -using Ghosts.Domain; - -namespace ghosts.client.linux.Infrastructure; - -/// -/// This largely replicates the same class in Domain, -/// but adds a kill switch for the handler so that -/// when out of office, the app is sure to be closed -/// -public static class WorkingHours -{ - private static readonly Logger _log = LogManager.GetCurrentClassLogger(); - - public static void Is(TimelineHandler handler) - { - var timeOn = handler.UtcTimeOn; - var timeOff = handler.UtcTimeOff; - var defaultTimespan = new TimeSpan(0, 0, 0); - - if (timeOn == defaultTimespan && timeOff == defaultTimespan) //ignore timelines that are unset (00:00:00) - return; - - var isOvernight = timeOff < timeOn; - - _log.Debug( - $"For {handler.HandlerType}: Local time: {DateTime.Now.TimeOfDay} UTC: {DateTime.UtcNow.TimeOfDay} On: {timeOn} Off: {timeOff} Overnight? {isOvernight}"); - - if (isOvernight) - { - while (DateTime.UtcNow.TimeOfDay < timeOn) - { - var sleep = Math.Abs((timeOn - DateTime.UtcNow.TimeOfDay).TotalMilliseconds); - if (sleep > 300000) - sleep = 300000; - Sleep(handler, Convert.ToInt32(sleep)); - } - } - else - { - while (DateTime.UtcNow.TimeOfDay < timeOn || - DateTime.UtcNow.TimeOfDay > timeOff) - { - Sleep(handler, 60000); - } - } - } - - private static void Sleep(TimelineHandler handler, int sleep) - { - _log.Trace($"Sleeping for {sleep} and killing processes..."); - //TODO - have to port the ProcessManager stuff - //ProcessManager.KillProcessAndChildrenByHandler(handler); - Thread.Sleep(sleep); - } -} \ No newline at end of file diff --git a/src/ghosts.client.linux/config/timeline.json b/src/ghosts.client.linux/config/timeline.json index b0092581..6801d234 100755 --- a/src/ghosts.client.linux/config/timeline.json +++ b/src/ghosts.client.linux/config/timeline.json @@ -19,6 +19,7 @@ "Initial": "about:blank", "UtcTimeOn": "00:00:00", "UtcTimeOff": "24:00:00", + "UtcTimeBlocks": [ "14:00:00", "17:00:00", "18:00:00", "22:00:00" ], "Loop": "True", "TimeLineEvents": [ { diff --git a/src/ghosts.client.linux/ghosts.client.linux.csproj b/src/ghosts.client.linux/ghosts.client.linux.csproj index c6b3be06..5b0d1f39 100755 --- a/src/ghosts.client.linux/ghosts.client.linux.csproj +++ b/src/ghosts.client.linux/ghosts.client.linux.csproj @@ -4,10 +4,11 @@ Exe win7-x64;ubuntu.16.10-x64;osx.10.12-x64 - 7.0.0.0 - 7.0.0.0 - 7.0.0.0 - 7.0.236.0 + 7.1.0.0 + 7.1.0.0 + 7.1.0.0 + 7.1.0.0 + false Dustin Updyke for Carnegie Mellon University