MPOSAirDataCleanUp 1.2.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package MPOSAirDataCleanUp --version 1.2.6
NuGet\Install-Package MPOSAirDataCleanUp -Version 1.2.6
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MPOSAirDataCleanUp" Version="1.2.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MPOSAirDataCleanUp --version 1.2.6
#r "nuget: MPOSAirDataCleanUp, 1.2.6"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MPOSAirDataCleanUp as a Cake Addin
#addin nuget:?package=MPOSAirDataCleanUp&version=1.2.6

// Install MPOSAirDataCleanUp as a Cake Tool
#tool nuget:?package=MPOSAirDataCleanUp&version=1.2.6

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.

  1. ServiceCollectionsExtensions Define the clean up services like so:
public static void AddDataCleanUp(this IServiceCollection services)
{
	services.AddDataCleanUpServices();

	services.AddSingleton<ICleanUpService, CleanUpService<VoucherDbContext>>();
}
  1. 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:

  1. ConfigureServices
         services.AddDataCleanUp();
  1. 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. [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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 662 10/17/2022
3.1.1 1,057 6/16/2022
3.1.0 1,340 5/4/2022
3.0.5 506 5/3/2022
3.0.4 521 5/3/2022
3.0.3 496 5/2/2022
3.0.2 1,070 9/30/2021
3.0.1 369 9/28/2021
3.0.0 408 9/27/2021
2.0.0 464 9/3/2021
1.4.0 426 8/23/2021
1.3.2 356 5/14/2021
1.3.1 365 4/12/2021
1.3.0 398 4/9/2021
1.2.10 385 3/24/2021
1.2.9 342 3/18/2021
1.2.8 373 3/10/2021
1.2.7 327 3/9/2021
1.2.6 357 2/8/2021
1.2.5 338 2/3/2021
1.2.4 332 2/2/2021
1.2.3 319 2/2/2021
1.2.2 390 1/22/2021
1.2.1 369 1/21/2021
1.2.0 343 1/21/2021
1.1.1 367 1/21/2021
1.1.0 375 1/21/2021
1.0.3 343 1/20/2021