Add AuctionBackgroundService, MgBackgroundServiceBase, OnDateTimeReceive
This commit is contained in:
parent
ec55100b1d
commit
49c9a4516a
|
|
@ -42,6 +42,10 @@
|
||||||
console.log("SignalR connected! connectionId: " + window.ConnectionId);
|
console.log("SignalR connected! connectionId: " + window.ConnectionId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connection.on("OnDateTimeReceive", dateTime => {
|
||||||
|
console.log("SignalR date received! dateTime: " + dateTime);
|
||||||
|
});
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
connection.start().catch(function (err) {
|
connection.start().catch(function (err) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,6 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
||||||
hubOptions.KeepAliveInterval = TimeSpan.FromMinutes(10);
|
hubOptions.KeepAliveInterval = TimeSpan.FromMinutes(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
//register services and interfaces
|
|
||||||
//IRepository<AuctionBid> _customerBidRepository;
|
|
||||||
//protected readonly IShortTermCacheManager _shortTermCacheManager;
|
|
||||||
// protected readonly IStaticCacheManager _staticCacheManager;
|
|
||||||
|
|
||||||
services.AddScoped<ILocalizationService, LocalizationService>();
|
services.AddScoped<ILocalizationService, LocalizationService>();
|
||||||
services.AddScoped<ISettingService, SettingService>();
|
services.AddScoped<ISettingService, SettingService>();
|
||||||
services.AddScoped<AuctionEventConsumer>();
|
services.AddScoped<AuctionEventConsumer>();
|
||||||
|
|
@ -72,13 +67,15 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
||||||
services.AddScoped<AuctionBidDbTable>();
|
services.AddScoped<AuctionBidDbTable>();
|
||||||
services.AddScoped<AuctionDbContext>();
|
services.AddScoped<AuctionDbContext>();
|
||||||
|
|
||||||
services.AddScoped<MyProductModelFactory>();
|
services.AddScoped<MyProductModelFactory>(); //TODO: ez mi? - J.
|
||||||
//services.AddScoped<SignalRMessageHandler>();
|
|
||||||
services.AddScoped<IOrderService, OrderService>();
|
services.AddScoped<IOrderService, OrderService>();
|
||||||
services.AddScoped<IOrderProcessingService, OrderProcessingService>();
|
services.AddScoped<IOrderProcessingService, OrderProcessingService>();
|
||||||
services.AddScoped<IShoppingCartService, ShoppingCartService>();
|
services.AddScoped<IShoppingCartService, ShoppingCartService>();
|
||||||
services.AddScoped<IStoreContext, WebStoreContext>();
|
services.AddScoped<IStoreContext, WebStoreContext>();
|
||||||
services.AddScoped<ICurrencyService, CurrencyService>();
|
services.AddScoped<ICurrencyService, CurrencyService>();
|
||||||
|
|
||||||
|
services.AddHostedService<AuctionBackgroundService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using Mango.Nop.Services;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Hubs;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Hubs.Messages;
|
||||||
|
using Nop.Services.Logging;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
|
||||||
|
public class AuctionBackgroundService(ILogger logger, IServiceProvider service, IHubContext<AuctionHub> auctionHubContext, AuctionService auctionService) : MgBackgroundServiceBase(logger, service)
|
||||||
|
{
|
||||||
|
protected override async Task OnExecuteAsync()
|
||||||
|
{
|
||||||
|
//var auctionDto = auctionService.GetProductToAuctionDtosByAuctionId()
|
||||||
|
//await auctionHubContext.Clients.All.SendAsync("send", new MessageWrapper());
|
||||||
|
|
||||||
|
await auctionHubContext.Clients.All.SendAsync("OnDateTimeReceive", DateTime.Now.ToString("G"));
|
||||||
|
await Task.Delay(15000);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue