public static async Task StartupAsync()
 {
     try
     {
         Server _server = new Server
         {
             Services = { QuartzServices.BindService(new QuartzJobService()) },
             Ports    = { new ServerPort("localhost", 40001, ServerCredentials.Insecure) }
         };
         _server.Start();
         var Db       = DBClientManage.GetSqlSugarClient();
         var schedule = Db.Queryable <ScheduleEntity>().Where(w => w.RunStatus == JobRunStatus.run).ToList();
         foreach (var item in schedule)
         {
             if (!string.IsNullOrEmpty(item.AssemblyName) && !string.IsNullOrEmpty(item.ClassName))
             {
                 await SchedulerCenter.GetSchedulerCenter().RunScheduleJob(item);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
        public override async Task <QuartzNetResult> StopScheduleAsync(ScheduleModel schedule, ServerCallContext context)
        {
            var result = new QuartzNetResult();
            BaseQuartzNetResult baseQuartz = await SchedulerCenter.GetSchedulerCenter().StopScheduleAsync();

            result.Code = baseQuartz.Code;
            result.Msg  = baseQuartz.Msg;
            return(result);
        }
        public override async Task <QuartzNetResult> RunScheduleJob(ScheduleModel schedule, ServerCallContext context)
        {
            var result = new QuartzNetResult()
            {
                Code = -1, Msg = "ʧ°Ü"
            };
            var Db       = DBClientManage.GetSqlSugarClient();
            var Schedule = await Db.Queryable <ScheduleEntity>().FirstAsync(w => w.Id == schedule.JonId);

            if (Schedule != null)
            {
                BaseQuartzNetResult baseQuartz = await SchedulerCenter.GetSchedulerCenter().RunScheduleJob(Schedule);

                result.Code = baseQuartz.Code;
                result.Msg  = baseQuartz.Msg;
            }
            return(result);
        }
示例#4
0
 static SchedulerCenter()
 {
     SchedulerCenterInstance = new SchedulerCenter();
 }
示例#5
0
 public bool Stop(HostControl hostControl)
 {
     SchedulerCenter.GetSchedulerCenter().StopScheduleAsync().Wait();
     return(true);
 }