improvements, fixes
This commit is contained in:
parent
56123bc787
commit
23e7b6a603
|
|
@ -117,7 +117,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
{
|
{
|
||||||
_logger.Detail($"GetShippingItems invoked");
|
_logger.Detail($"GetShippingItems invoked");
|
||||||
|
|
||||||
return await ctx.ShippingItems.GetAll().ToListAsync();
|
return await ctx.ShippingItems.GetAll(true).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[SignalR(SignalRTags.GetShippingItemById)]
|
[SignalR(SignalRTags.GetShippingItemById)]
|
||||||
|
|
@ -125,7 +125,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
{
|
{
|
||||||
_logger.Detail($"GetShippingItemById invoked; id: {id}");
|
_logger.Detail($"GetShippingItemById invoked; id: {id}");
|
||||||
|
|
||||||
var shippingItem = await ctx.ShippingItems.GetByIdAsync(id);
|
var shippingItem = await ctx.ShippingItems.GetByIdAsync(id, true);
|
||||||
|
|
||||||
if (shippingItem.NetWeight <= 0) _logger.Error($"shippingItem.NetWeight == 0");
|
if (shippingItem.NetWeight <= 0) _logger.Error($"shippingItem.NetWeight == 0");
|
||||||
return shippingItem;
|
return shippingItem;
|
||||||
|
|
@ -162,7 +162,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
||||||
{
|
{
|
||||||
_logger.Detail($"GetShippingDocuments invoked");
|
_logger.Detail($"GetShippingDocuments invoked");
|
||||||
|
|
||||||
return await ctx.ShippingDocuments.GetAll().ToListAsync();
|
return await ctx.ShippingDocuments.GetAll(true).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[SignalR(SignalRTags.GetShippingDocumentById)]
|
[SignalR(SignalRTags.GetShippingDocumentById)]
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer.Interfaces;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using NUglify.Helpers;
|
using NUglify.Helpers;
|
||||||
using System.Transactions;
|
using System.Transactions;
|
||||||
|
using LinqToDB;
|
||||||
|
using Nop.Core.ComponentModel;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||||
|
|
||||||
|
|
@ -89,6 +91,8 @@ public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>
|
||||||
return Task.FromResult(false);
|
return Task.FromResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly ReaderWriterLockSlim _locker = new(LockRecursionPolicy.NoRecursion);
|
||||||
|
|
||||||
public async Task<bool> UpdateShippingItemAsync(ShippingItem shippingItem)
|
public async Task<bool> UpdateShippingItemAsync(ShippingItem shippingItem)
|
||||||
{
|
{
|
||||||
if (shippingItem == null)
|
if (shippingItem == null)
|
||||||
|
|
@ -97,8 +101,11 @@ public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>
|
||||||
return await Task.FromResult(false);
|
return await Task.FromResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
//using (new ReaderWriteLockDisposable(_locker))
|
||||||
{
|
//_locker.EnterWriteLock();
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
using var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Mi van ha nem jött meg a termék? Nem fogják tudni menteni... - J.
|
//Mi van ha nem jött meg a termék? Nem fogják tudni menteni... - J.
|
||||||
|
|
@ -133,15 +140,11 @@ public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>
|
||||||
await ShippingItems.UpdateAsync(shippingItem);
|
await ShippingItems.UpdateAsync(shippingItem);
|
||||||
|
|
||||||
//TODO: a measuredweight-eket is! - J.
|
//TODO: a measuredweight-eket is! - J.
|
||||||
if (shippingItem.ProductId == dbShippingItem.ProductId &&
|
if (shippingItem.ProductId != dbShippingItem.ProductId ||
|
||||||
shippingItem.IsMeasured == dbShippingItem.IsMeasured && shippingItem.IsMeasurable == dbShippingItem.IsMeasurable &&
|
shippingItem.IsMeasured != dbShippingItem.IsMeasured || shippingItem.IsMeasurable != dbShippingItem.IsMeasurable ||
|
||||||
shippingItem.MeasuredQuantity == dbShippingItem.MeasuredQuantity &&
|
shippingItem.MeasuredQuantity != dbShippingItem.MeasuredQuantity ||
|
||||||
shippingItem.MeasuredNetWeight == dbShippingItem.MeasuredNetWeight && shippingItem.MeasuredGrossWeight == dbShippingItem.MeasuredGrossWeight)
|
shippingItem.MeasuredNetWeight != dbShippingItem.MeasuredNetWeight || shippingItem.MeasuredGrossWeight != dbShippingItem.MeasuredGrossWeight)
|
||||||
{
|
{
|
||||||
return await Task.FromResult(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: productIdUnchanged-et lekezelni! - J.
|
|
||||||
var productIdUnchanged = shippingItem.ProductId == dbShippingItem.ProductId;
|
var productIdUnchanged = shippingItem.ProductId == dbShippingItem.ProductId;
|
||||||
|
|
||||||
if (shippingItem.IsMeasured)
|
if (shippingItem.IsMeasured)
|
||||||
|
|
@ -172,6 +175,8 @@ public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>
|
||||||
else Logger.Warning($"product == null; dbShippingItem.ProductId: {dbShippingItem.ProductId}");
|
else Logger.Warning($"product == null; dbShippingItem.ProductId: {dbShippingItem.ProductId}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//else //TODO: productIdUnchanged-et lekezelni! - J.
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error($"UpdateShippingItemAsync Transaction ERROR! Id: {shippingItem?.Id}", ex);
|
Logger.Error($"UpdateShippingItemAsync Transaction ERROR! Id: {shippingItem?.Id}", ex);
|
||||||
|
|
@ -179,7 +184,11 @@ public class FruitBankDbContext : MgDbContextBase, IPartnerDbSet<PartnerDbTable>
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.Complete();
|
transaction.Complete();
|
||||||
}
|
//}
|
||||||
|
//finally
|
||||||
|
//{
|
||||||
|
// _locker.ExitWriteLock();
|
||||||
|
//}
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue