Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cancellation token #160

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.1.51</Version>
<Version>0.0.1.52</Version>
<Description>asp core servces.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,services,asp,aspnet</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.1.51</Version>
<Version>0.0.1.52</Version>
<Description>asp core servces.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,services,asp,aspnet,aspcore,efcore</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.1.51</Version>
<Version>0.0.1.52</Version>
<Description>core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,client,clients</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.1.51</Version>
<Version>0.0.1.52</Version>
<Description>core contracts.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,contract,contracts,dto,dtos</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using EasyMicroservices.Cores.Interfaces;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace EasyMicroservices.Cores.Database.Interfaces;
Expand All @@ -20,14 +21,16 @@ public interface IDatabaseWidget<TEntity, T> : IWidget<T>
/// <param name="baseUnitOfWork"></param>
/// <param name="entity"></param>
/// <param name="contract"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task AddProcess(IDatabaseWidgetManager databaseWidgetManager, IBaseUnitOfWork baseUnitOfWork, TEntity entity, T contract);
Task AddProcess(IDatabaseWidgetManager databaseWidgetManager, IBaseUnitOfWork baseUnitOfWork, TEntity entity, T contract, CancellationToken cancellationToken = default);
/// <summary>
///
/// </summary>
/// <param name="databaseWidgetManager"></param>
/// <param name="baseUnitOfWork"></param>
/// <param name="items"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task AddBulkProcess(IDatabaseWidgetManager databaseWidgetManager, IBaseUnitOfWork baseUnitOfWork, Dictionary<T, TEntity> items);
Task AddBulkProcess(IDatabaseWidgetManager databaseWidgetManager, IBaseUnitOfWork baseUnitOfWork, Dictionary<T, TEntity> items, CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using EasyMicroservices.Cores.Interfaces;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace EasyMicroservices.Cores.Database.Interfaces;
Expand All @@ -16,8 +17,9 @@ public interface IDatabaseWidgetManager : IWidgetManager
/// <param name="baseUnitOfWork"></param>
/// <param name="entity"></param>
/// <param name="contract"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task Add<TEntity, T>(IBaseUnitOfWork baseUnitOfWork, TEntity entity, T contract)
Task Add<TEntity, T>(IBaseUnitOfWork baseUnitOfWork, TEntity entity, T contract, CancellationToken cancellationToken = default)
where TEntity : class;
/// <summary>
///
Expand All @@ -26,7 +28,8 @@ Task Add<TEntity, T>(IBaseUnitOfWork baseUnitOfWork, TEntity entity, T contract)
/// <typeparam name="TEntity"></typeparam>
/// <param name="baseUnitOfWork"></param>
/// <param name="items"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task AddBulk<TEntity, T>(IBaseUnitOfWork baseUnitOfWork, Dictionary<T, TEntity> items)
Task AddBulk<TEntity, T>(IBaseUnitOfWork baseUnitOfWork, Dictionary<T, TEntity> items, CancellationToken cancellationToken = default)
where TEntity : class;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1023,12 +1023,12 @@
{
await InternalUpdateBulk(easyWritableQueryable, result.Select(x => x.Entity).ToList(), false, true, true, true, cancellationToken)
.AsCheckedResult();
await easyWritableQueryable.SaveChangesAsync();
await easyWritableQueryable.SaveChangesAsync(cancellationToken);
}
var response = result.Select(x => x.Entity).ToList();
var widgetManager = _baseUnitOfWork.GetDatabaseWidgetManager();
await widgetManager.AddBulk(_baseUnitOfWork, items);
await ActivityChangeLogLogic.AddBuldAsync(response, _baseUnitOfWork);

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'

Check failure on line 1031 in src/CSharp/EasyMicroservices.Cores.Database/Database/Logics/DatabaseLogicInfrastructure.cs

View workflow job for this annotation

GitHub Actions / os-tests

'ActivityChangeLogLogic' does not contain a definition for 'AddBuldAsync'
return response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using EasyMicroservices.Cores.Widgets;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Threading;
using System.Threading.Tasks;

namespace EasyMicroservices.Cores.Database.Managers;
Expand All @@ -20,8 +21,9 @@ public class DatabaseWidgetManager : WidgetManager, IDatabaseWidgetManager
/// <param name="baseUnitOfWork"></param>
/// <param name="entity"></param>
/// <param name="contract"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task Add<TEntity, T>(IBaseUnitOfWork baseUnitOfWork, TEntity entity, T contract)
public async Task Add<TEntity, T>(IBaseUnitOfWork baseUnitOfWork, TEntity entity, T contract, CancellationToken cancellationToken = default)
where TEntity : class
{
var widgets = GetWidgetsByType(typeof(T));
Expand All @@ -41,8 +43,9 @@ public async Task Add<TEntity, T>(IBaseUnitOfWork baseUnitOfWork, TEntity entity
/// <typeparam name="T"></typeparam>
/// <param name="baseUnitOfWork"></param>
/// <param name="items"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task AddBulk<TEntity, T>(IBaseUnitOfWork baseUnitOfWork, Dictionary<T, TEntity> items) where TEntity : class
public async Task AddBulk<TEntity, T>(IBaseUnitOfWork baseUnitOfWork, Dictionary<T, TEntity> items, CancellationToken cancellationToken = default) where TEntity : class
{
var widgets = GetWidgetsByType(typeof(T));
foreach (var widget in widgets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace EasyMicroservices.Cores.Widgets;
Expand Down Expand Up @@ -64,9 +65,10 @@ public Task Initialize(params TObjectContract[] parameters)
/// <param name="baseUnitOfWork"></param>
/// <param name="entity"></param>
/// <param name="contract"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task AddProcess(IDatabaseWidgetManager databaseWidgetManager, IBaseUnitOfWork baseUnitOfWork, TEntity entity, TObjectContract contract)
public async Task AddProcess(IDatabaseWidgetManager databaseWidgetManager, IBaseUnitOfWork baseUnitOfWork, TEntity entity, TObjectContract contract, CancellationToken cancellationToken = default)
{
var reportEntity = await baseUnitOfWork
.GetMapper()
Expand All @@ -77,7 +79,7 @@ public async Task AddProcess(IDatabaseWidgetManager databaseWidgetManager, IBase
});
DatabaseExtensions.SetIdToRecordId(logic.GetReadableContext(), entity, reportEntity);
await logic
.Add(reportEntity)
.Add(reportEntity, cancellationToken)
.AsCheckedResult();
}

Expand All @@ -87,8 +89,9 @@ await logic
/// <param name="databaseWidgetManager"></param>
/// <param name="baseUnitOfWork"></param>
/// <param name="items"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task AddBulkProcess(IDatabaseWidgetManager databaseWidgetManager, IBaseUnitOfWork baseUnitOfWork, Dictionary<TObjectContract, TEntity> items)
public async Task AddBulkProcess(IDatabaseWidgetManager databaseWidgetManager, IBaseUnitOfWork baseUnitOfWork, Dictionary<TObjectContract, TEntity> items, CancellationToken cancellationToken = default)
{
var reportEntities = await baseUnitOfWork
.GetMapper()
Expand All @@ -99,7 +102,7 @@ public async Task AddBulkProcess(IDatabaseWidgetManager databaseWidgetManager, I
});
DatabaseExtensions.SetIdToRecordId(logic.GetReadableContext(), reportEntities);
await logic
.AddBulk(reportEntities.Values.ToList())
.AddBulk(reportEntities.Values.ToList(), cancellationToken)
.AsCheckedResult();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.1.51</Version>
<Version>0.0.1.52</Version>
<Description>core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.1;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.1.51</Version>
<Version>0.0.1.52</Version>
<Description>ef core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,ef,efcore</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.1.51</Version>
<Version>0.0.1.52</Version>
<Description>core of infrastructure.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,infrastructure</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.1.51</Version>
<Version>0.0.1.52</Version>
<Description>ef core of Relational database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,database,ef,efcore,Relational</PackageTags>
Expand Down
Loading