noplogger improvements, fixes, etc...
This commit is contained in:
parent
a261318005
commit
0c604bde9e
|
|
@ -17,6 +17,7 @@ using Nop.Services.Catalog;
|
|||
using FruitBank.Common.Dtos;
|
||||
using Mango.Nop.Core.Extensions;
|
||||
using Nop.Core.Domain.Orders;
|
||||
using WebMarkupMin.Core.Loggers;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
|
||||
|
|
@ -177,6 +178,9 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
{
|
||||
try
|
||||
{
|
||||
//Logger.Warning($"UpdateShippingItemAsync");
|
||||
//throw new Exception($"Teszt");
|
||||
|
||||
ProductDto? productDto = null;
|
||||
var productIsMeasurable = false;
|
||||
|
||||
|
|
@ -313,6 +317,10 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
if (!await SetupShippingItemPalletMeauringValues(shippingItemPallet)) return null;
|
||||
|
||||
await ShippingItemPallets.InsertAsync(shippingItemPallet);
|
||||
|
||||
var shippingItem = await ShippingItems.GetByIdAsync(shippingItemPallet.ShippingItemId, false);
|
||||
await UpdateShippingItemAsync(shippingItem);
|
||||
|
||||
return shippingItemPallet;
|
||||
}
|
||||
|
||||
|
|
@ -324,6 +332,10 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
if (!await SetupShippingItemPalletMeauringValues(shippingItemPallet)) return null;
|
||||
|
||||
await ShippingItemPallets.UpdateAsync(shippingItemPallet);
|
||||
|
||||
var shippingItem = await ShippingItems.GetByIdAsync(shippingItemPallet.ShippingItemId, false);
|
||||
await UpdateShippingItemAsync(shippingItem);
|
||||
|
||||
return shippingItemPallet;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,14 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using AyCode.Core.Loggers;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using FruitBank.Common.Dtos;
|
||||
using AyCode.Core.Loggers;
|
||||
using FruitBank.Common.Entities;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.Loggers;
|
||||
using FruitBank.Common.Server;
|
||||
using Humanizer;
|
||||
using Mango.Nop.Core.Loggers;
|
||||
using Mango.Nop.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Nop.Core;
|
||||
using Nop.Core.Domain.Catalog;
|
||||
using Nop.Core.Events;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Controllers;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||
using Nop.Services.Common;
|
||||
using Nop.Services.Events;
|
||||
using System.Globalization;
|
||||
using Mango.Nop.Core.Extensions;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.EventConsumers;
|
||||
|
|
@ -87,53 +77,62 @@ public class FruitBankEventConsumer(IHttpContextAccessor httpContextAcc, FruitBa
|
|||
bool? isMeasurable = null;
|
||||
var isMeasurableChanged = false;
|
||||
|
||||
var productDto = product.Id > 0 ? await ctx.ProductDtos.GetByIdAsync(product.Id, false) : null;
|
||||
|
||||
//IsMeasurable
|
||||
isMeasurable = form[nameof(IMeasurable.IsMeasurable)].ToString().Contains("true");
|
||||
var productDtoIsMeasurable = productDto?.GenericAttributes.GetValueOrNull<bool>(nameof(IMeasurable.IsMeasurable));
|
||||
|
||||
if (productDtoIsMeasurable == null || productDtoIsMeasurable.Value != isMeasurable.Value)
|
||||
try
|
||||
{
|
||||
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, bool>(product.Id, nameof(IMeasurable.IsMeasurable), isMeasurable.Value);
|
||||
isMeasurableChanged = true;
|
||||
var productDto = product.Id > 0 ? await ctx.ProductDtos.GetByIdAsync(product.Id, false) : null;
|
||||
|
||||
//IsMeasurable
|
||||
isMeasurable = form[nameof(IMeasurable.IsMeasurable)].ToString().Contains("true");
|
||||
var productDtoIsMeasurable = productDto?.GenericAttributes.GetValueOrNull<bool>(nameof(IMeasurable.IsMeasurable));
|
||||
|
||||
if (productDtoIsMeasurable == null || productDtoIsMeasurable.Value != isMeasurable.Value)
|
||||
{
|
||||
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, bool>(product.Id, nameof(IMeasurable.IsMeasurable), isMeasurable.Value);
|
||||
isMeasurableChanged = true;
|
||||
}
|
||||
|
||||
//NetWeight
|
||||
var netWeight = double.Round(CommonHelper.To<double>(form[nameof(IMeasuringNetWeight.NetWeight)].ToString()), 1);
|
||||
var productDtoNetWeight = productDto?.GenericAttributes.GetValueOrNull<double>(nameof(IMeasuringNetWeight.NetWeight));
|
||||
|
||||
if (productDtoNetWeight == null || double.Round(productDtoNetWeight.Value, 1) != netWeight)
|
||||
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, double>(product.Id, nameof(IMeasuringNetWeight.NetWeight), netWeight);
|
||||
|
||||
//Tára
|
||||
var tare = double.Round(CommonHelper.To<double>(form[nameof(ITare.Tare)].ToString()), 1);
|
||||
if (tare < 0) throw new Exception($"FruitBankEventConsumer->SaveProductCustomAttributesAsync(); (tare < 0); productId: {product.Id}; tare: {tare}");
|
||||
|
||||
if (productDto == null || productDto.Tare != tare)
|
||||
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, double>(product.Id, nameof(ITare.Tare), tare);
|
||||
|
||||
//IncomingQuantity
|
||||
var incomingQuantity = CommonHelper.To<int>(form[nameof(IIncomingQuantity.IncomingQuantity)].ToString());
|
||||
if (incomingQuantity < 0) throw new Exception($"FruitBankEventConsumer->SaveProductCustomAttributesAsync(); (incomingQuantity < 0); productId: {product.Id}; incomingQuantity: {incomingQuantity}");
|
||||
|
||||
if (productDto == null || productDto.IncomingQuantity != incomingQuantity)
|
||||
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, int>(product.Id, nameof(IIncomingQuantity.IncomingQuantity), incomingQuantity);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error($"FruitBankEventConsumer->SaveProductCustomAttributesAsync; {ex.Message}", ex);
|
||||
}
|
||||
|
||||
//NetWeight
|
||||
var netWeight = double.Round(CommonHelper.To<double>(form[nameof(IMeasuringNetWeight.NetWeight)].ToString()), 1);
|
||||
var productDtoNetWeight = productDto?.GenericAttributes.GetValueOrNull<double>(nameof(IMeasuringNetWeight.NetWeight));
|
||||
|
||||
if (productDtoNetWeight == null || double.Round(productDtoNetWeight.Value, 1) != netWeight)
|
||||
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, double>(product.Id, nameof(IMeasuringNetWeight.NetWeight), netWeight);
|
||||
|
||||
//Tára
|
||||
var tare = double.Round(CommonHelper.To<double>(form[nameof(ITare.Tare)].ToString()), 1);
|
||||
if (tare < 0) throw new Exception($"FruitBankEventConsumer->SaveProductCustomAttributesAsync(); (tare < 0); productId: {product.Id}; tare: {tare}");
|
||||
|
||||
if (productDto == null || productDto.Tare != tare)
|
||||
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, double>(product.Id, nameof(ITare.Tare), tare);
|
||||
|
||||
//IncomingQuantity
|
||||
var incomingQuantity = CommonHelper.To<int>(form[nameof(IIncomingQuantity.IncomingQuantity)].ToString());
|
||||
if (incomingQuantity < 0) throw new Exception($"FruitBankEventConsumer->SaveProductCustomAttributesAsync(); (incomingQuantity < 0); productId: {product.Id}; incomingQuantity: {incomingQuantity}");
|
||||
|
||||
if (productDto == null || productDto.IncomingQuantity != incomingQuantity)
|
||||
await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync<Product, int>(product.Id, nameof(IIncomingQuantity.IncomingQuantity), incomingQuantity);
|
||||
|
||||
return (isMeasurableChanged, isMeasurable);
|
||||
}
|
||||
|
||||
public async Task HandleEventAsync(EntityInsertedEvent<ShippingItemPallet> eventMessage)
|
||||
{
|
||||
Logger.Info($"HandleEventAsync EntityInsertedEvent<ShippingItemPallet>; id: {eventMessage.Entity.Id}");
|
||||
return;
|
||||
|
||||
Logger.Info($"HandleEventAsync EntityInsertedEvent<ShippingItemPallet>; id: {eventMessage.Entity.Id}");
|
||||
await UpdateShippingItemMeasuringValuesAsync(eventMessage.Entity);
|
||||
}
|
||||
|
||||
public async Task HandleEventAsync(EntityUpdatedEvent<ShippingItemPallet> eventMessage)
|
||||
{
|
||||
Logger.Info($"HandleEventAsync EntityUpdatedEvent<ShippingItemPallet>; id: {eventMessage.Entity.Id}");
|
||||
return;
|
||||
|
||||
Logger.Info($"HandleEventAsync EntityUpdatedEvent<ShippingItemPallet>; id: {eventMessage.Entity.Id}");
|
||||
await UpdateShippingItemMeasuringValuesAsync(eventMessage.Entity);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
using AyCode.Core.Loggers;
|
||||
using DevExpress.AspNetCore;
|
||||
|
||||
using FruitBank.Common;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.Server.Interfaces;
|
||||
using FruitBank.Common.Server.Services.Loggers;
|
||||
using FruitBank.Common.Server.Services.SignalRs;
|
||||
using Mango.Nop.Core.Loggers;
|
||||
|
|
@ -16,6 +16,9 @@ using Microsoft.Extensions.Configuration;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Nop.Core.Domain.Orders;
|
||||
using Nop.Core.Infrastructure;
|
||||
using Nop.Data;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Controllers;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Factories;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Filters;
|
||||
|
|
@ -27,9 +30,6 @@ using Nop.Services.Events;
|
|||
using Nop.Web.Areas.Admin.Factories;
|
||||
using Nop.Web.Areas.Admin.Models.Catalog;
|
||||
using Nop.Web.Areas.Admin.Models.Orders;
|
||||
using FruitBank.Common.Server.Interfaces;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Controllers;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Infrastructure;
|
||||
|
||||
|
|
@ -50,9 +50,10 @@ public class PluginNopStartup : INopStartup
|
|||
//register services and interfaces
|
||||
|
||||
services.AddSingleton<ILockService, LockService>();
|
||||
services.AddTransient<INopLoggerMsSqlNopDataProvider, NopLoggerMsSqlNopDataProvider>();
|
||||
|
||||
services.AddScoped<IAcLogWriterBase, ConsoleLogWriter>();
|
||||
//services.AddScoped<IAcLogWriterBase, NopLogWriter>();
|
||||
services.AddScoped<IAcLogWriterBase, NopLogWriter>();
|
||||
services.AddScoped<LoggerToLoggerApiController2>();
|
||||
//services.AddSingleton<SessionService>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue