123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Hosting;
- using Quartz;
- using System;
- using System.Linq;
- using wispro.sp.api.Job;
- namespace wispro.sp.api
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- var host = CreateHostBuilder(args).Build();
- using (var serviceScope = host.Services.CreateScope())
- {
- var services = serviceScope.ServiceProvider;
- try
- {
- var context = services.GetRequiredService<spDbContext>();
- var result = context.Database.EnsureCreated();
- if (result)
- {
- System.Diagnostics.Debug.Write("数据库创建成功!");
- }
- else
- {
- System.Diagnostics.Debug.Write("数据库创建失败!");
- }
- }
- catch (Exception ex)
- {
- //var logger = services.GetRequiredService<ILogger<Program>>();
- //logger.LogError(ex, "An error occurred.");
- }
- }
- #region 每月获取绩效数据Job
- JobKey jobKey = new JobKey("ImportReportData");
- var trigger = TriggerBuilder.Create()
- .WithDescription("导入每月报表")
- .WithSchedule(CronScheduleBuilder.CronSchedule(utility.ConfigHelper.GetSectionValue("IPEasySetting:ScheduleSetting")).WithMisfireHandlingInstructionDoNothing())
- .Build();
- _ = QuartzUtil.Add(typeof(ImportReportJob), jobKey, trigger);
- #endregion
- #region 每天更新绩效数据
- JobKey jobKey1 = new JobKey("UpdateSchedule");
- var trigger1 = TriggerBuilder.Create()
- .WithDescription("更新绩效数据")
- .WithSchedule(CronScheduleBuilder.CronSchedule(utility.ConfigHelper.GetSectionValue("UpdateScheduleSetting")).WithMisfireHandlingInstructionDoNothing())
- .Build();
- _ = QuartzUtil.Add(typeof(UpdateJXDataFromIPEasyJob), jobKey1, trigger1);
- #endregion
- #region 疑似绩效数据通知
- JobKey jobKey2 = new JobKey("InvalidData");
- var trigger2 = TriggerBuilder.Create()
- .WithDescription("疑似绩效数据通知")
- .WithSchedule(CronScheduleBuilder.CronSchedule(utility.ConfigHelper.GetSectionValue("InvalidDataScheduleSetting")).WithMisfireHandlingInstructionDoNothing())
- .Build();
- _ = QuartzUtil.Add(typeof(InvalidDataMessageJob), jobKey2, trigger2);
- #endregion
- #region 通知代理人反馈
- JobKey jobKey3 = new JobKey("AgentMessage");
- var trigger3 = TriggerBuilder.Create()
- .WithDescription("通知代理人开始反馈")
- .WithSchedule(CronScheduleBuilder.CronSchedule(utility.ConfigHelper.GetSectionValue("AgentMessageScheduleSetting")).WithMisfireHandlingInstructionDoNothing())
- .Build();
- _ = QuartzUtil.Add(typeof(AgentMessageJob), jobKey3, trigger3);
- #endregion
- host.Run();
- }
- public static IHostBuilder CreateHostBuilder(string[] args) =>
- Host.CreateDefaultBuilder(args)
- .ConfigureWebHostDefaults(webBuilder =>
- {
- webBuilder.UseStartup<Startup>();
- });
-
- }
- }
|