MPOSAirDataCleanUp 1.3.2
See the version list below for details.
dotnet add package MPOSAirDataCleanUp --version 1.3.2
NuGet\Install-Package MPOSAirDataCleanUp -Version 1.3.2
<PackageReference Include="MPOSAirDataCleanUp" Version="1.3.2" />
paket add MPOSAirDataCleanUp --version 1.3.2
#r "nuget: MPOSAirDataCleanUp, 1.3.2"
// Install MPOSAirDataCleanUp as a Cake Addin #addin nuget:?package=MPOSAirDataCleanUp&version=1.3.2 // Install MPOSAirDataCleanUp as a Cake Tool #tool nuget:?package=MPOSAirDataCleanUp&version=1.3.2
MPOSAirDataCleanUp
MPOSAirDataCleanUp is a database table rows clean up library. It's usage it's enforced with the methods described bellow. However, the explanation can be simplified:
- Specify the DbContext type to be used.
- Add 1 or more entities.
- Add a start time.
- Add a clean up period.
- Optional: add restrictions
Installation
To install the package, simply search the MPOSAirDataCleanUp package on nuget.org and install it in the same project where Entity Framework Core resides.
The following example illustrates the usage within a Web API project.
- ServiceCollectionsExtensions Define the clean up services like so:
public static void AddDataCleanUp(this IServiceCollection services)
{
services.AddDataCleanUpServices();
services.AddSingleton<ICleanUpService, CleanUpService<VoucherDbContext>>();
}
- ApplicationBuilderExtensions The following method configures the clean up service:
public static void ConfigureDataCleanUp(this IApplicationBuilder app)
{
var cleanUpService = (ICleanUpService)app.ApplicationServices.GetService(typeof(ICleanUpService));
var service = cleanUpService.WithContext(typeof(YourContext))
.ForEntity(typeof(YourEntity), (x) => x.CreatedDate > DateTime.Now.AddDays(-1))
.WithPeriod(CleanUpPeriod.Minutely)
.WithUtcStartTime("12:10:00")
.WithRestrictions(null);
Task.Run(async () => await service.InitializeCleanUp(new System.Threading.CancellationToken()));
}
Then, in StartUp.cs, you have the following:
- ConfigureServices
services.AddDataCleanUp();
- Configure
app.ConfigureDataCleanUp();
Dependencies
MPOSAirDataCleanUp is heavily dependent on MposAirDataContracts v2.0.0. The dependency is so strong, that if you do not inherit your project entities from DataContracts, it will result in null elements being selected for your DbContext.
A new table will need to be created in your database. This table is used by MPOSAirDataCleanUp to keep track of cleaned entities. To this end, the DataCleaningEntityTypeConfiguration file already exists in the package. Simply add it to your Entity Framework configuration. Example:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new DataCleaningEntityTypeConfiguration());
}
It's ok if you are not using Configuration files. When overriding OnModelCreating just configure the DataCleaning entity type.
Remember to add the migration when using Code First approach.
Any and all Unit of Work, Repositories or Entities should rely and inherit from MposAirDataContracts.
Method Description
Currently, the CleanUpService supports the following methods. Their usage is strictly enforced.
[REQUIRED] - WithContext(DbContext context) - The database context that needs cleaning. [REQUIRED] - ForEntity(Type entityType, Func<IEntity, bool> filter) - The entity that will be cleaned, along with a filter. Remember to cast the entity to it's type when using the filter, as above. [OPTIONAL] - AndForEntity(Type entityType, Func<IEntity, bool> filter) - Add another entity that will be cleaned, along with a filter. Remember to cast the entity to it's type when using the filter, as above. [REQUIRED] - WithUtcStartTime(string startTime) - Add the UTC start time to the cleaning process. Supported format: "14:00:00". [REQUIRED] - WithPeriod(CleanUpPeriod period) - Add the period to the cleaning process. V1.0.0 does not support other dates than the predefined ones for Weekly, Monthly and Yearly periods. [OPTIONAL] - WithRestrictions(CleanUpRestrictions restrictions) - Add restrictions to the cleaning process. Current restrictions include not cleaning during business hours. [OPTIONAL] - WithNoRestrictions() - No restrictions to the cleaning process. Current restrictions include not cleaning during business hours. [REQUIRED] - InitializeCleanUp() - Starts the cleaning process.
CleanUpPeriod Options
- Daily - if the set time is before the current UTC time, then the next cleaning process will take place the next day.
- Weekly - every Sunday
- Monthly - the 1st of every month
- Yearly - the last day of the year
CAUTION
Any and all exceptions are captured and shown into the console output of the application that uses the nuget.
Make sure the table DataCleanings exists, otherwise, the nuget throws the error into the console and the cleaning will not take place.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Microsoft.AspNetCore.Hosting.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- MposAirDataContracts (>= 2.0.0)
- MposAirLogging (>= 4.1.0)
- Newtonsoft.Json (>= 12.0.3)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 3.1.4)
- Serilog (>= 2.9.0)
- Serilog.Sinks.Console (>= 3.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
4.0.1 | 690 | 10/17/2022 | |
3.1.1 | 1,088 | 6/16/2022 | |
3.1.0 | 1,361 | 5/4/2022 | |
3.0.5 | 533 | 5/3/2022 | |
3.0.4 | 544 | 5/3/2022 | |
3.0.3 | 519 | 5/2/2022 | |
3.0.2 | 1,097 | 9/30/2021 | |
3.0.1 | 397 | 9/28/2021 | |
3.0.0 | 429 | 9/27/2021 | |
2.0.0 | 487 | 9/3/2021 | |
1.4.0 | 450 | 8/23/2021 | |
1.3.2 | 385 | 5/14/2021 | |
1.3.1 | 390 | 4/12/2021 | |
1.3.0 | 434 | 4/9/2021 | |
1.2.10 | 412 | 3/24/2021 | |
1.2.9 | 364 | 3/18/2021 | |
1.2.8 | 396 | 3/10/2021 | |
1.2.7 | 352 | 3/9/2021 | |
1.2.6 | 376 | 2/8/2021 | |
1.2.5 | 366 | 2/3/2021 | |
1.2.4 | 360 | 2/2/2021 | |
1.2.3 | 342 | 2/2/2021 | |
1.2.2 | 421 | 1/22/2021 | |
1.2.1 | 389 | 1/21/2021 | |
1.2.0 | 371 | 1/21/2021 | |
1.1.1 | 390 | 1/21/2021 | |
1.1.0 | 397 | 1/21/2021 | |
1.0.3 | 372 | 1/20/2021 |