diff --git a/BaseFiles/Common/Common.csproj b/BaseFiles/Common/Common.csproj
index 6a5fcadab..b020b1b02 100644
--- a/BaseFiles/Common/Common.csproj
+++ b/BaseFiles/Common/Common.csproj
@@ -36,6 +36,9 @@
PreserveNewest
+
+ Always
+
PreserveNewest
diff --git a/BaseFiles/Common/html/ui/core/popup.cronwizard.js b/BaseFiles/Common/html/ui/core/popup.cronwizard.js
index db963def4..aeaa3c8dd 100644
--- a/BaseFiles/Common/html/ui/core/popup.cronwizard.js
+++ b/BaseFiles/Common/html/ui/core/popup.cronwizard.js
@@ -729,8 +729,8 @@ $$.getMonthCron = function(dateFrom, dateTo, dayOccur, monthOccur) {
cron = '* * '+(df!=1?'1-':'')+dt+' '+mt+' *';
cronItems.push(cron);
if (mf > mt || mt-mf > 1 || (mf == mt && dt < df)) {
- var mfn = mf<11 ? mf+1 : 0;
- var mtp = mt>0 ? mt-1 : 11;
+ var mfn = mf<12 ? mf+1 : 1;
+ var mtp = mt>1 ? mt-1 : 12;
cron = '* * * '+mfn+(mfn!=mtp?'-'+mtp:'')+' *';
cronItems.push(cron);
}
diff --git a/BaseFiles/Common/postinstall.lock b/BaseFiles/Common/postinstall.lock
new file mode 100644
index 000000000..e69de29bb
diff --git a/HomeGenie.Tests/SchedulerServiceTest.cs b/HomeGenie.Tests/SchedulerServiceTest.cs
index a5d068df9..72b7965c4 100644
--- a/HomeGenie.Tests/SchedulerServiceTest.cs
+++ b/HomeGenie.Tests/SchedulerServiceTest.cs
@@ -74,6 +74,16 @@ public void CronExpressionWithExcept(string expression)
DisplayOccurences(expression, occurences);
Assert.That(occurences.Count, Is.EqualTo(12));
}
+
+ [Test]
+ [TestCase("[ (* * 1-31 11 *) : (* * 1-15 1 *) : (* * * 12 *) ]")]
+ public void CronExpressionAcrossYears(string expression)
+ {
+ var occurences = _scheduler.GetScheduling(new DateTime(2018, 6, 1), new DateTime(2019, 6, 30), expression);
+
+ DisplayOccurences(expression, occurences);
+ Assert.That(occurences.Count, Is.EqualTo((30+31+15)*1440));
+ }
private static List GetOccurencesForDate(SchedulerService scheduler, DateTime date, string expression)
{
@@ -90,4 +100,4 @@ private void DisplayOccurences(string cronExpression, List occurences)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/HomeGenie/Program.cs b/HomeGenie/Program.cs
index 52d09f98b..78e500129 100644
--- a/HomeGenie/Program.cs
+++ b/HomeGenie/Program.cs
@@ -42,36 +42,53 @@ static void Main(string[] args)
Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);
- // Move MIG libraries from root folder to lib/mig
- // TODO: find a better solution to this
- string[] migFiles =
- {
- "MIG.HomeAutomation.dll",
- "MIG.Protocols.dll",
- "LibUsb.Common.dll",
- "LibUsbDotNet.LibUsbDotNet.dll",
- "XTenLib.dll",
- "ZWaveLib.dll"
- };
- foreach (var f in migFiles)
+ PostInstallCheck();
+
+ _homegenie = new HomeGenieService();
+ do { System.Threading.Thread.Sleep(2000); } while (_isrunning);
+ }
+
+ private static void PostInstallCheck()
+ {
+ string postInstallLock = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "postinstall.lock");
+ if (File.Exists(postInstallLock))
{
- string source = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, f);
- if (!File.Exists(source)) continue;
+ // Move MIG interface plugins from root folder to lib/mig
+ // TODO: find a better solution to this
+ string[] migFiles =
+ {
+ "MIG.HomeAutomation.dll",
+ "MIG.Protocols.dll",
+ "LibUsb.Common.dll",
+ "LibUsbDotNet.LibUsbDotNet.dll",
+ "XTenLib.dll",
+ "ZWaveLib.dll"
+ };
+ foreach (var f in migFiles)
+ {
+ string source = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, f);
+ if (!File.Exists(source)) continue;
+ try
+ {
+ string dest = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lib", "mig", f);
+ if (File.Exists(dest)) File.Delete(dest);
+ File.Move(source, dest);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("{0}\n{1}\n", e.Message, e.StackTrace);
+ }
+ }
+ // TODO: place any other post-install stuff here
try
{
- string dest = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lib", "mig", f);
- if (File.Exists(dest)) File.Delete(dest);
- File.Move(source, dest);
+ File.Delete(postInstallLock);
}
catch (Exception e)
{
- Console.WriteLine(e.Message);
- Console.WriteLine(e.StackTrace);
+ Console.WriteLine("{0}\n{1}\n", e.Message, e.StackTrace);
}
}
-
- _homegenie = new HomeGenieService();
- do { System.Threading.Thread.Sleep(2000); } while (_isrunning);
}
internal static void Quit(bool restartService)