static async Task Main(string[] args) { #region Quartz try { var cancelSource = new CancellationTokenSource(); LocalConf local = new LocalConf(); //从工厂中获取一个调度器实例化 IScheduler scheduler = await StdSchedulerFactory.GetDefaultScheduler(); Console.WriteLine(local.QuartzNow); if (local.QuartzNow) { IJobDetail job2 = JobBuilder.Create <AutoUpdateJob>() .WithIdentity("WinAutoUpdaterJob2", "JobGroup") .Build(); ITrigger trigger2 = TriggerBuilder.Create() .WithIdentity("WinAutoUpdaterJobTrigger2", "JobTriggerGroup") .StartNow() .Build(); await scheduler.ScheduleJob(job2, trigger2); } IJobDetail job = JobBuilder.Create <AutoUpdateJob>() .WithIdentity("WinAutoUpdaterJob", "JobGroup") .Build(); ITrigger trigger = TriggerBuilder.Create() .WithIdentity("WinAutoUpdaterJobTrigger", "JobTriggerGroup") .WithCronSchedule(local.QuartzCron) .Build(); await scheduler.ScheduleJob(job, trigger); await scheduler.Start(); } catch (Exception ex) { Console.WriteLine(ex.Message); } #endregion Console.ReadKey(); }
/// <summary> /// 开始 /// </summary> public bool Start() { try { _local = new LocalConf(); //更新 bool reUpdate = Update(); if (!reUpdate) { return(false); } //重启 ReStart(); return(true); } catch (Exception) { return(false); } }
public async Task Execute(IJobExecutionContext context) { //MessageBox.Show("我开始执行了"); //const string jobName = "自动升级Job"; LocalConf local = new LocalConf(); try { //ErrorRetryHelper.Handle(local.ReTry, () => //{ // AutoUpdate au = new AutoUpdate(); // var flag = au.Start(); // return flag; //}); AutoUpdate au = new AutoUpdate(); au.Start(); } catch (Exception e) { Console.WriteLine(e); throw; } }
/// <summary> /// 获取软件版本号 /// </summary> /// <returns></returns> public string GetAppVersion() { LocalConf conf = new LocalConf(); return("猪猪全景图下载器 v" + conf.Version); }