在一个Net Core需求中,需要在每天的凌晨三点去抓取两个电商仓库的剩余的每个料号的数量来写会自己的表中,
用到了HangFire的定时任务
Quartz.NET总结(三)Quartz 配置
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseHangfireServer(); app.UseHangfireDashboard("/hangfire", new DashboardOptions() { Authorization = new[] { new Code.HangfireMyAuthorizeFilter() } }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); //BackgroundJob.Enqueue<Inv.InventoryTransfer>(x => x.SyncTransfer("Commercial")); } else { //Bob add 设置每天凌晨三点获取一次即时库存 string Cron_GetIMInventory = Configuration.GetSection("AppSettings").GetValue<string>("CronGetIMInventory");//获取到每天的凌晨三点钟 RecurringJob.AddOrUpdate<DS.PutOMSOrder>("PutOMSOrder", x => x.GetIMInventory(), Cron_GetIMInventory, System.TimeZoneInfo.Local); app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(); app.Run(async (context) => { await context.Response.WriteAsync("Hello World!"); }); }