-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update nugets and docs for cron jobs * Initial implementation of cron jobs plugin
- Loading branch information
Showing
62 changed files
with
2,872 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
DAL/PluginManager.DAL.TextFiles/Providers/CronJobProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* .Net Core Plugin Manager is distributed under the GNU General Public License version 3 and | ||
* is also available under alternative licenses negotiated directly with Simon Carter. | ||
* If you obtained Service Manager under the GPL, then the GPL applies to all loadable | ||
* Service Manager modules used on your system as well. The GPL (version 3) is | ||
* available at https://opensource.org/licenses/GPL-3.0 | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* The Original Code was created by Simon Carter (s1cart3r@gmail.com) | ||
* | ||
* Copyright (c) 2024 Simon Carter. All Rights Reserved. | ||
* | ||
* Product: PluginManager.DAL.TextFiles | ||
* | ||
* File: CronProvider.cs | ||
* | ||
* Purpose: ICronProvider for text based storage | ||
* | ||
* Date Name Reason | ||
* 25/08/2024 Simon Carter Initially Created | ||
* | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
using Middleware; | ||
|
||
using PluginManager.DAL.TextFiles.Tables; | ||
|
||
using SharedPluginFeatures; | ||
|
||
using SimpleDB; | ||
|
||
namespace PluginManager.DAL.TextFiles.Providers | ||
{ | ||
internal sealed class CronJobProvider : ICronJobProvider | ||
{ | ||
private readonly ISimpleDBOperations<CronJobDataRow> _cronJobSettings; | ||
|
||
public CronJobProvider(ISimpleDBOperations<CronJobDataRow> cronJobSettings) | ||
{ | ||
_cronJobSettings = cronJobSettings ?? throw new ArgumentNullException(nameof(cronJobSettings)); | ||
} | ||
|
||
public DateTime GetLastRun(ICronJob cronJob) | ||
{ | ||
CronJobDataRow cronJobDataRow = GetOrCreateCronJobDataRow(cronJob); | ||
|
||
return new DateTime(cronJobDataRow.LastRunTicks, DateTimeKind.Utc); | ||
} | ||
|
||
public void SetLastRun(ICronJob cronJob, DateTime lastRun) | ||
{ | ||
CronJobDataRow cronJobDataRow = GetOrCreateCronJobDataRow(cronJob); | ||
cronJobDataRow.LastRunTicks = lastRun.Ticks; | ||
_cronJobSettings.Update(cronJobDataRow); | ||
} | ||
|
||
private CronJobDataRow GetOrCreateCronJobDataRow(ICronJob cronJob) | ||
{ | ||
CronJobDataRow cronJobDataRow = _cronJobSettings.Select(cj => cj.JobId.Equals(cronJob.JobId) && cj.Name.Equals(cronJob.Name)).FirstOrDefault(); | ||
|
||
if (cronJobDataRow == null) | ||
{ | ||
cronJobDataRow = new() | ||
{ | ||
JobId = cronJob.JobId, | ||
Name = cronJob.Name, | ||
UpdatedTicks = DateTime.MinValue.Ticks | ||
}; | ||
|
||
_cronJobSettings.Insert(cronJobDataRow); | ||
} | ||
|
||
return cronJobDataRow; | ||
} | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
DAL/PluginManager.DAL.TextFiles/Tables/CronJob/CronJobDataRow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* .Net Core Plugin Manager is distributed under the GNU General Public License version 3 and | ||
* is also available under alternative licenses negotiated directly with Simon Carter. | ||
* If you obtained Service Manager under the GPL, then the GPL applies to all loadable | ||
* Service Manager modules used on your system as well. The GPL (version 3) is | ||
* available at https://opensource.org/licenses/GPL-3.0 | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* The Original Code was created by Simon Carter (s1cart3r@gmail.com) | ||
* | ||
* Copyright (c) 2024 Simon Carter. All Rights Reserved. | ||
* | ||
* Product: PluginManager.DAL.TextFiles | ||
* | ||
* File: CronJobDataRow.cs | ||
* | ||
* Purpose: Row definition for Table for cron jobs | ||
* | ||
* Date Name Reason | ||
* 26/08/2024 Simon Carter Initially Created | ||
* | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
using SimpleDB; | ||
|
||
namespace PluginManager.DAL.TextFiles.Tables | ||
{ | ||
[Table(Constants.TableNameCronJobs, CompressionType.None, CachingStrategy.SlidingMemory, WriteStrategy.Forced)] | ||
internal sealed class CronJobDataRow : TableRowDefinition | ||
{ | ||
private Guid _jobId; | ||
private string _name; | ||
private long _lastRunTicks; | ||
|
||
public Guid JobId | ||
{ | ||
get => _jobId; | ||
|
||
set | ||
{ | ||
if (_jobId == value) | ||
return; | ||
|
||
_jobId = value; | ||
Update(); | ||
} | ||
} | ||
|
||
public string Name | ||
{ | ||
get => _name; | ||
|
||
set | ||
{ | ||
if (_name == value) | ||
return; | ||
|
||
_name = value; | ||
Update(); | ||
} | ||
} | ||
|
||
public long LastRunTicks | ||
{ | ||
get => _lastRunTicks; | ||
|
||
set | ||
{ | ||
if (_lastRunTicks == value) | ||
return; | ||
|
||
_lastRunTicks = value; | ||
Update(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Docs/Custom/Cron.Plugin/Cron.Plugin.Classes/MasterCronThread/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/Cron.Plugin/Cron.Plugin.Provider/DefaultCronData/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/Cron.Plugin/Cron.Plugin/PluginInitialisation/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/Middleware/Middleware/ICronJobProvider/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/SharedPluginFeatures/SharedPluginFeatures.BaseClasses/CronJob/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/SharedPluginFeatures/SharedPluginFeatures.BaseClasses/DailyCronJob/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/SharedPluginFeatures/SharedPluginFeatures/CronJobSettings/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/SharedPluginFeatures/SharedPluginFeatures/CronPriority/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/SharedPluginFeatures/SharedPluginFeatures/CronRepeatFrequencyType/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/SharedPluginFeatures/SharedPluginFeatures/CronTrigger/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/SharedPluginFeatures/SharedPluginFeatures/ICronJob/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
1 change: 1 addition & 0 deletions
1
Docs/Custom/SharedPluginFeatures/SharedPluginFeatures/ICronJobSettings/SortOrder.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.