fixes
This commit is contained in:
parent
7fb047fd28
commit
08069dda58
|
|
@ -1,5 +1,6 @@
|
||||||
using Mango.Nop.Core.Loggers;
|
using Mango.Nop.Core.Loggers;
|
||||||
using Nop.Core.Domain.Catalog;
|
using Nop.Core.Domain.Catalog;
|
||||||
|
using Nop.Core.Domain.Orders;
|
||||||
using Nop.Data;
|
using Nop.Data;
|
||||||
using System.Transactions;
|
using System.Transactions;
|
||||||
|
|
||||||
|
|
@ -10,6 +11,7 @@ public interface IMgDbContextBase //: IAcDbContextBase
|
||||||
ILogger Logger { get; init; }
|
ILogger Logger { get; init; }
|
||||||
INopDataProvider DataProvider { get; init; }
|
INopDataProvider DataProvider { get; init; }
|
||||||
|
|
||||||
|
IRepository<Order> Orders { get; set; }
|
||||||
IRepository<Product> Products { get; set; }
|
IRepository<Product> Products { get; set; }
|
||||||
|
|
||||||
bool Transaction(Func<TransactionScope, bool> callbackTransactionBody, bool throwException = false);
|
bool Transaction(Func<TransactionScope, bool> callbackTransactionBody, bool throwException = false);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using Mango.Nop.Core.Loggers;
|
||||||
using Mango.Nop.Services;
|
using Mango.Nop.Services;
|
||||||
using Nop.Core.Caching;
|
using Nop.Core.Caching;
|
||||||
using Nop.Core.Domain.Catalog;
|
using Nop.Core.Domain.Catalog;
|
||||||
|
using Nop.Core.Domain.Orders;
|
||||||
using Nop.Data;
|
using Nop.Data;
|
||||||
|
|
||||||
namespace Mango.Nop.Core.Repositories;
|
namespace Mango.Nop.Core.Repositories;
|
||||||
|
|
@ -24,10 +25,14 @@ public abstract class MgDbContextBase : IMgDbContextBase
|
||||||
public ILogger Logger { get; init; }
|
public ILogger Logger { get; init; }
|
||||||
public INopDataProvider DataProvider { get; init; }
|
public INopDataProvider DataProvider { get; init; }
|
||||||
|
|
||||||
|
public IRepository<Order> Orders { get; set; }
|
||||||
|
public IRepository<OrderItem> OrderItems { get; set; }
|
||||||
|
|
||||||
public IRepository<Product> Products { get; set; }
|
public IRepository<Product> Products { get; set; }
|
||||||
|
|
||||||
//public IHttpContextAccessor HttpContextAccessor { get; init; }
|
//public IHttpContextAccessor HttpContextAccessor { get; init; }
|
||||||
|
|
||||||
public MgDbContextBase(IRepository<Product> productRepository, INopDataProvider dataProvider, IMgLockService lockService, ILogger logger)
|
public MgDbContextBase(IRepository<Product> productRepository, IRepository<Order> orderRepository, IRepository<OrderItem> orderItemRepository, INopDataProvider dataProvider, IMgLockService lockService, ILogger logger)
|
||||||
{
|
{
|
||||||
LockService = lockService;
|
LockService = lockService;
|
||||||
|
|
||||||
|
|
@ -35,6 +40,9 @@ public abstract class MgDbContextBase : IMgDbContextBase
|
||||||
DataProvider = dataProvider;
|
DataProvider = dataProvider;
|
||||||
|
|
||||||
Products = productRepository;
|
Products = productRepository;
|
||||||
|
|
||||||
|
Orders = orderRepository;
|
||||||
|
OrderItems = orderItemRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TransactionScope CreateTransactionScope(TransactionScopeOption transactionScopeOption = TransactionScopeOption.Required)
|
private static TransactionScope CreateTransactionScope(TransactionScopeOption transactionScopeOption = TransactionScopeOption.Required)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Mango.Nop.Services;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents plugin event consumer
|
/// Represents plugin event consumer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class MgEventConsumer(IMgDbContextBase ctx, IHttpContextAccessor httpContextAccessor, IEnumerable<IAcLogWriterBase> logWriters) :
|
public abstract class MgEventConsumerBase(IMgDbContextBase ctx, IHttpContextAccessor httpContextAccessor, IEnumerable<IAcLogWriterBase> logWriters) :
|
||||||
IConsumer<EntityUpdatedEvent<Product>>,
|
IConsumer<EntityUpdatedEvent<Product>>,
|
||||||
IConsumer<EntityInsertedEvent<Product>>,
|
IConsumer<EntityInsertedEvent<Product>>,
|
||||||
IConsumer<CustomerRegisteredEvent>,
|
IConsumer<CustomerRegisteredEvent>,
|
||||||
|
|
@ -28,7 +28,7 @@ public abstract class MgEventConsumer(IMgDbContextBase ctx, IHttpContextAccessor
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
protected ILogger Logger { get; } = new Logger<MgEventConsumer>(logWriters.ToArray());
|
protected ILogger Logger { get; } = new Logger<MgEventConsumerBase>(logWriters.ToArray());
|
||||||
protected readonly IHttpContextAccessor HttpContextAccessor = httpContextAccessor;
|
protected readonly IHttpContextAccessor HttpContextAccessor = httpContextAccessor;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
namespace Mango.Nop.Services;
|
|
||||||
|
|
||||||
public abstract class MgLockService : IMgLockService
|
|
||||||
{
|
|
||||||
public SemaphoreSlim SemaphoreSlim { get; protected init; }
|
|
||||||
|
|
||||||
protected MgLockService() : this(new SemaphoreSlim(1))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected MgLockService(SemaphoreSlim semaphoreSlim)
|
|
||||||
{
|
|
||||||
SemaphoreSlim = semaphoreSlim;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
namespace Mango.Nop.Services;
|
||||||
|
|
||||||
|
public abstract class MgLockServiceBase : IMgLockService
|
||||||
|
{
|
||||||
|
public SemaphoreSlim SemaphoreSlim { get; protected init; }
|
||||||
|
|
||||||
|
protected MgLockServiceBase() : this(new SemaphoreSlim(1))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MgLockServiceBase(SemaphoreSlim semaphoreSlim)
|
||||||
|
{
|
||||||
|
SemaphoreSlim = semaphoreSlim;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Mango.Nop.Services;
|
namespace Mango.Nop.Services;
|
||||||
|
|
||||||
public abstract class MgSessionItem(string sessionKey) : IMgSessionItem
|
public abstract class MgSessionItemBase(string sessionKey) : IMgSessionItem
|
||||||
{
|
{
|
||||||
public string SessionId { get; protected set; } = sessionKey;
|
public string SessionId { get; protected set; } = sessionKey;
|
||||||
public string? SignaRConnectionId { get; set; }
|
public string? SignaRConnectionId { get; set; }
|
||||||
|
|
@ -3,7 +3,7 @@ using AyCode.Utils.Extensions;
|
||||||
|
|
||||||
namespace Mango.Nop.Services;
|
namespace Mango.Nop.Services;
|
||||||
|
|
||||||
public abstract class MgSessionService<TSessionItem> : IMgSessionService<TSessionItem> where TSessionItem : class, IMgSessionItem
|
public abstract class MgSessionServiceBase<TSessionItem> : IMgSessionService<TSessionItem> where TSessionItem : class, IMgSessionItem
|
||||||
{
|
{
|
||||||
protected ConcurrentDictionary<string, TSessionItem> Sessions { get; } = new();
|
protected ConcurrentDictionary<string, TSessionItem> Sessions { get; } = new();
|
||||||
|
|
||||||
Loading…
Reference in New Issue