From a563c482347586a7eabb9bebb8da1ee2d81926e6 Mon Sep 17 00:00:00 2001 From: Johnny Reijnst Date: Sun, 10 Aug 2025 09:53:12 +0200 Subject: [PATCH] Upload --- .gitignore | 133 +++++++++++++++++++++++++++++++++++++ CronApp.sln | 24 +++++++ Dockerfile | 9 +++ Scheduler/Program.cs | 33 +++++++++ Scheduler/Scheduler.csproj | 14 ++++ docker-compose.yml | 9 +++ 6 files changed, 222 insertions(+) create mode 100644 .gitignore create mode 100644 CronApp.sln create mode 100644 Dockerfile create mode 100644 Scheduler/Program.cs create mode 100644 Scheduler/Scheduler.csproj create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b956f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,133 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.svclog +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml +*.azurePubxml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +packages/ +## TODO: If the tool you use requires repositories.config, also uncomment the next line +!packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +![Ss]tyle[Cc]op.targets +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml + +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +_NCrunch* \ No newline at end of file diff --git a/CronApp.sln b/CronApp.sln new file mode 100644 index 0000000..5d03046 --- /dev/null +++ b/CronApp.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scheduler", "Scheduler\Scheduler.csproj", "{87BE8E89-77CB-43F1-E470-643184C5C445}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {87BE8E89-77CB-43F1-E470-643184C5C445}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {87BE8E89-77CB-43F1-E470-643184C5C445}.Debug|Any CPU.Build.0 = Debug|Any CPU + {87BE8E89-77CB-43F1-E470-643184C5C445}.Release|Any CPU.ActiveCfg = Release|Any CPU + {87BE8E89-77CB-43F1-E470-643184C5C445}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {78FB926B-235E-4140-99B4-2747F5212FEF} + EndGlobalSection +EndGlobal diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d44a074 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src +COPY . . +RUN dotnet publish -c Release -o /app + +FROM mcr.microsoft.com/dotnet/runtime:8.0 +WORKDIR /app +COPY --from=build /app . +ENTRYPOINT ["dotnet", "CronApp.dll"] diff --git a/Scheduler/Program.cs b/Scheduler/Program.cs new file mode 100644 index 0000000..2b8145d --- /dev/null +++ b/Scheduler/Program.cs @@ -0,0 +1,33 @@ +using Quartz; +using Quartz.Impl; + +class Program +{ + static async Task Main() + { + var scheduler = await new StdSchedulerFactory().GetScheduler(); + await scheduler.Start(); + + var job = JobBuilder.Create() + .WithIdentity("job1", "group1") + .Build(); + + var trigger = TriggerBuilder.Create() + .WithIdentity("trigger1", "group1") + .WithCronSchedule("0 * * ? * *") // every minute + .Build(); + + await scheduler.ScheduleJob(job, trigger); + + await Task.Delay(-1); + } +} + +public class MyJob : IJob +{ + public Task Execute(IJobExecutionContext context) + { + Console.WriteLine($"Job ran at {DateTime.Now}"); + return Task.CompletedTask; + } +} diff --git a/Scheduler/Scheduler.csproj b/Scheduler/Scheduler.csproj new file mode 100644 index 0000000..a6a167c --- /dev/null +++ b/Scheduler/Scheduler.csproj @@ -0,0 +1,14 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c11a871 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3.8" + +services: + cronapp: + build: + context: . + dockerfile: Dockerfile + container_name: cronapp + restart: unless-stopped