// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider) { ChainServicesExecuter.SetServiceProvider(serviceProvider); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseMigrationsEndPoint(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); endpoints.MapHub <EventsHub>("/eventsHub"); }); }
public Task Execute(IJobExecutionContext context) { lock (_lock) { var unitOfWork = serviceProvider.GetService(typeof(IUnitOfWork)) as IUnitOfWork; var repository = unitOfWork.GetRepository <IQueueRepository>(); var queues = repository.List(q => !q.Processed && q.CreatedDateTime < DateTime.Now.AddSeconds(10), q => q.OrderBy(a => a.CreatedDateTime)); logger.LogInformation($"{queues.Count} items found to process"); foreach (var queue in queues) { var requestObject = JsonConvert.DeserializeObject(queue.Request, Type.GetType(queue.TypeDefinition)); ChainServicesExecuter.Execute(requestObject, null, queue); queue.Processed = true; queue.ProcessDateTime = DateTime.Now; hubContext.Clients.Client(EventsHub.Connections[queue.HubId][0]).SendAsync("eventRaised", "yout order has done", "success"); } unitOfWork.SaveChanges(); return(Task.CompletedTask); } }