remove logs; fixes;

This commit is contained in:
Loretta 2024-12-03 10:34:40 +01:00
parent 2a3fc24632
commit d1cdb62e64
5 changed files with 39 additions and 28 deletions

View File

@ -70,7 +70,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Components
{
//await base.InvokeAsync(widgetZone, additionalData);
await _logger.InformationAsync($"Admin auction widget called from {widgetZone}!");
//await _logger.InformationAsync($"AuctionAdminViewComponent.InvokeAsync(); Admin auction widget called from {widgetZone}!");
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName))
return Content(string.Empty);
@ -83,14 +84,19 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Components
var productId = 0;
if (!widgetZone.Equals(AdminWidgetZones.ProductDetailsButtons))
{
await _logger.InformationAsync($"Admin auction widget not in the right widgetzone {widgetZone}!");
await _logger.InformationAsync($"AuctionAdminViewComponent.InvokeAsync(); Admin auction widget not in the right widgetzone {widgetZone}!");
return Content(string.Empty);
}
var product = (additionalData as ProductModel);
//ProductDetailsModel detailsModel = await _productModelFactory.PrepareProductDetailsModelAsync(product.Price);
productId = product.Id;
if (additionalData is not ProductModel productModel)
{
await _logger.ErrorAsync($"AuctionAdminViewComponent.InvokeAsync(); (productModel == null); widgetZone: {widgetZone};");
return Content(string.Empty);
}
productId = productModel.Id;
var auctions = await _auctionService.GetAllAuctionsAsync() ?? new List<Auction>();
@ -98,12 +104,12 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Components
ViewBag.Auctions = auctions;
ProductAssignToAuctionViewModel viewModel = new ProductAssignToAuctionViewModel();
viewModel.ProductId = productId;
viewModel.StartingPrice = product.OldPrice;
viewModel.BidPrice = product.OldPrice;
viewModel.StartingPrice = productModel.OldPrice;
viewModel.BidPrice = productModel.OldPrice;
//viewModel.InAuctions = await _auctionService.GetAllAuctionsAsync()
viewModel.InAuctions = [];
await _logger.InformationAsync($"Admin auction widget called from {widgetZone}! II. ");
//await _logger.InformationAsync($"AuctionAdminViewComponent.InvokeAsync(); Admin auction widget called from {widgetZone}! II. ");
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/AdminProductAuctionSettingsBox.cshtml", viewModel);
}

View File

@ -54,7 +54,7 @@ public class AuctionViewComponent : NopViewComponent
/// </returns>
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
{
await _logger.InformationAsync("Auction widget called");
//await _logger.InformationAsync("Auction widget called");
//ensure that a widget is active and enabled
var customer = await _workContext.GetCurrentCustomerAsync();

View File

@ -48,7 +48,7 @@ public class AuctionController(AuctionService auctionService, ILogger logger, IP
[HttpPost]
public async Task<IActionResult> RefreshAuctionWidget([FromBody] RefreshWidgetRequest request)
{
await logger.InformationAsync($"Refresh auction widget called from {request.WidgetZone} with data of {request.ProductId}");
//await logger.InformationAsync($"Refresh auction widget called from {request.WidgetZone} with data of {request.ProductId}");
var product = await productService.GetProductByIdAsync(request.ProductId);
var detailsModel = await productModelFactory.PrepareProductDetailsModelAsync(product);

View File

@ -29,38 +29,43 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
_signalRMessageHandler = signalRMessageHandler;
}
public override async Task OnConnectedAsync()
public override async Task OnConnectedAsync()
{
//await _logger.InformationAsync($"Caller connected: id{_hubCallerContext.ConnectionId}");
var userId = Context.ConnectionId;
await _logger.InformationAsync($"Caller connected with id: {userId}");
var userName = Context.GetHttpContext().Request.Query["ConnectionId"];
if (!string.IsNullOrEmpty(userName))
{
await _logger.InformationAsync($"Caller connected with name: {userName}");
}
await base.OnConnectedAsync();
var connectionId = Context.ConnectionId;
//await _logger.InformationAsync($"AuctionHub.OnConnectedAsync(); Caller connected with id: {connectionId}");
var httpContext = Context.GetHttpContext();
if (httpContext == null)
{
await _logger.WarningAsync($"AuctionHub.OnConnectedAsync(); (httpContext == null); connectionId: {connectionId}");
}
else
{
var userName = httpContext.Request.Query["ConnectionId"];
if (!string.IsNullOrEmpty(userName))
{
await _logger.InformationAsync($"AuctionHub.OnConnectedAsync(); Caller connected with name: {userName}; connectionId: {connectionId}");
}
}
await base.OnConnectedAsync();
}
public async Task ReceiveRegularMessageFromClient(string message)
{
await _logger.InformationAsync(message);
// Broadcast the message received from the client to all clients
//await _logger.InformationAsync($"AuctionHub.OnConnectedAsync(); message: {message}");
Console.Write($"Received message: {message}");
await Clients.All.SendAsync("Send", message);
//await _signalRservice.TestHub();
}
public async Task ReceiveMessageFromClient(MessageWrapper message)
{
// Log the message type and data
await _logger.InformationAsync($"Received message of type: {message.MessageType}");
//await _logger.InformationAsync($"AuctionHub.OnConnectedAsync(); Received message of type: {message.MessageType}");
await _signalRMessageHandler.HandleMessage(message);
}
}
}

View File

@ -204,7 +204,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
await auctionService.UpdateProductToAuctionMappingAsync(productToAuction);
}
var bidsCount = await auctionService.GetBidsCountByProductToAuctionIdAsync(productToAuction.Id);
var bidsCount = productToAuction.BidsCount;//await auctionService.GetBidsCountByProductToAuctionIdAsync(productToAuction.Id);
var productToauctionChangedNotification = new MessageWrapper
{
MessageType = nameof(ProductToAuctionStatusNotification),