diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config new file mode 100644 index 0000000..67f8ea0 --- /dev/null +++ b/.nuget/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe new file mode 100644 index 0000000..8f61340 Binary files /dev/null and b/.nuget/NuGet.exe differ diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets new file mode 100644 index 0000000..83fe906 --- /dev/null +++ b/.nuget/NuGet.targets @@ -0,0 +1,136 @@ + + + + $(MSBuildProjectDirectory)\..\ + + + false + + + false + + + true + + + false + + + + + + + + + + + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) + + + + + $(SolutionDir).nuget + packages.config + + + + + $(NuGetToolsPath)\NuGet.exe + @(PackageSource) + + "$(NuGetExePath)" + mono --runtime=v4.0.30319 $(NuGetExePath) + + $(TargetDir.Trim('\\')) + + -RequireConsent + -NonInteractive + + "$(SolutionDir) " + "$(SolutionDir)" + + + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) + $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(BuildDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CronNET.sln b/CronNET.sln index 3d79796..c421a8b 100755 --- a/CronNET.sln +++ b/CronNET.sln @@ -1,10 +1,19 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C# Express 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CronNET", "CronNET\CronNET.csproj", "{F31D7AF3-FDFA-44F1-9C63-305BAF11D002}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CronNETTests", "CronNETTests\CronNETTests.csproj", "{6FCFBDF4-ECB7-4FC2-A376-E962B11D487D}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{EA4722C9-7FD3-4D8C-BA24-AAAFC5E52EAC}" + ProjectSection(SolutionItems) = preProject + .nuget\NuGet.Config = .nuget\NuGet.Config + .nuget\NuGet.exe = .nuget\NuGet.exe + .nuget\NuGet.targets = .nuget\NuGet.targets + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/CronNET.sln.DotSettings.user b/CronNET.sln.DotSettings.user new file mode 100644 index 0000000..4c74edf --- /dev/null +++ b/CronNET.sln.DotSettings.user @@ -0,0 +1,4 @@ + + True + CronScheduleTests + <Session><Elements><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests" type="NUnitTestFixtureElement" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.divided_array_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="divided_array_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.generate_days_of_month_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="generate_days_of_month_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.generate_days_of_weeks" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="generate_days_of_weeks" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.generate_hours_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="generate_hours_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.generate_minutes_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="generate_minutes_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.generate_months_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="generate_months_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.generate_values_divided_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="generate_values_divided_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.generate_values_range_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="generate_values_range_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.is_time_day_of_month_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="is_time_day_of_month_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.is_time_day_of_week_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="is_time_day_of_week_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.is_time_hour_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="is_time_hour_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.is_time_minute_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="is_time_minute_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.is_time_month_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="is_time_month_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.is_time_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="is_time_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.is_valid_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="is_valid_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.list_array_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="list_array_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.ppp" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="ppp" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.range_array_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="range_array_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /><UnitTestElement Provider="nUnit" Id="CronTests.CronScheduleTests.wild_array_test" ParentId="CronTests.CronScheduleTests" type="NUnitTestElement" TypeName="CronTests.CronScheduleTests" MethodName="wild_array_test" Project="6FCFBDF4-ECB7-4FC2-A376-E962B11D487D" /></Elements></Session> \ No newline at end of file diff --git a/CronNET.v12.suo b/CronNET.v12.suo new file mode 100644 index 0000000..83ab8d6 Binary files /dev/null and b/CronNET.v12.suo differ diff --git a/CronNET/CronDaemon.cs b/CronNET/CronDaemon.cs index fdc0f53..ae612fd 100755 --- a/CronNET/CronDaemon.cs +++ b/CronNET/CronDaemon.cs @@ -5,10 +5,17 @@ using System.Threading; namespace CronNET { - public class CronDaemon + public interface ICronDaemon + { + void AddJob(string schedule, ThreadStart action); + void Start(); + void Stop(); + } + + public class CronDaemon : ICronDaemon { private readonly System.Timers.Timer timer = new System.Timers.Timer(30000); - private readonly List cron_jobs = new List(); + private readonly List cron_jobs = new List(); private DateTime _last= DateTime.Now; public CronDaemon() @@ -41,7 +48,7 @@ namespace CronNET if (DateTime.Now.Minute != _last.Minute) { _last = DateTime.Now; - foreach (CronJob job in cron_jobs) + foreach (ICronJob job in cron_jobs) job.execute(DateTime.Now); } } diff --git a/CronNET/CronJob.cs b/CronNET/CronJob.cs index a98c416..97f2b05 100755 --- a/CronNET/CronJob.cs +++ b/CronNET/CronJob.cs @@ -3,9 +3,15 @@ using System.Threading; namespace CronNET { - public class CronJob + public interface ICronJob { - private readonly CronSchedule _cron_schedule = new CronSchedule(); + void execute(DateTime date_time); + void abort(); + } + + public class CronJob : ICronJob + { + private readonly ICronSchedule _cron_schedule = new CronSchedule(); private readonly ThreadStart _thread_start; private Thread _thread; diff --git a/CronNET/CronSchedule.cs b/CronNET/CronSchedule.cs index 23ddc6f..5b6dfb6 100755 --- a/CronNET/CronSchedule.cs +++ b/CronNET/CronSchedule.cs @@ -4,7 +4,13 @@ using System.Text.RegularExpressions; namespace CronNET { - public class CronSchedule + public interface ICronSchedule + { + bool isValid(string expression); + bool isTime(DateTime date_time); + } + + public class CronSchedule : ICronSchedule { #region Readonly Class Members diff --git a/CronNET/Properties/AssemblyInfo.cs b/CronNET/Properties/AssemblyInfo.cs index 46d110f..5154305 100755 --- a/CronNET/Properties/AssemblyInfo.cs +++ b/CronNET/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.1")] +[assembly: AssemblyFileVersion("1.0.0.1")] diff --git a/CronNETTests/CronNETTests.csproj b/CronNETTests/CronNETTests.csproj index f7b9711..c4c8dd0 100755 --- a/CronNETTests/CronNETTests.csproj +++ b/CronNETTests/CronNETTests.csproj @@ -31,6 +31,8 @@ false false true + ..\ + true true @@ -50,9 +52,8 @@ 4 - - False - C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\framework\nunit.framework.dll + + ..\packages\NUnit.2.6.3\lib\nunit.framework.dll @@ -90,7 +91,11 @@ true + + + +