Exemplo n.º 1
0
        public static void UseQuartzJobMildd(this IApplicationBuilder app, ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            try
            {
                if (Appsettings.app("Middleware", "QuartzNetJob", "Enabled").ObjToBool())
                {
                    var allQzServices = tasksQzServices.Query().Result;
                    foreach (var item in allQzServices)
                    {
                        if (item.IsStart)
                        {
                            var ResuleModel = schedulerCenter.AddScheduleJobAsync(item).Result;
                            if (ResuleModel.success)
                            {
                                Console.WriteLine($"QuartzNetJob{item.Name}启动成功!");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                log.Error($"An error was reported when starting the job service.\n{e.Message}");
                throw;
            }
        }
Exemplo n.º 2
0
        public async Task <object> RedisChche()
        {
            var    data = new MessageModel <object>();
            var    list = _cache.Exist("list");
            object c    = new();

            if (list.Result == true)
            {
                c = _cache.GetValue("list").Result;
            }
            else
            {
                c = await tasksQzServices.Query();

                TimeSpan c1 = DateTime.Now.AddDays(60) - DateTime.Now;
                c = _cache.Set("list", c, c1);
            }
            return(c);
        }