Пример #1
0
        public static IApplicationBuilder UseAddTaskSchedulers(this IApplicationBuilder app, ISysTasksQzService tasksQzService, ITaskSchedulerServer schedulerServer)
        {
            var logger = NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();

            var tasks = tasksQzService.GetWhere(m => m.IsStart);

            foreach (var task in tasks)
            {
                var result = schedulerServer.AddTaskScheduleAsync(task).Result;
                logger.Debug(result.Message);
            }

            return(app);
        }
        public static IApplicationBuilder UseAddTaskSchedulers(this IApplicationBuilder app)
        {
            IServiceProvider     services         = app.ApplicationServices;
            ISysTasksQzService   _tasksQzService  = services.GetService <ISysTasksQzService>();
            ITaskSchedulerServer _schedulerServer = services.GetService <ITaskSchedulerServer>();

            var tasks = _tasksQzService.GetWhere(m => m.IsStart);

            foreach (var task in tasks)
            {
                _schedulerServer.AddTaskScheduleAsync(task);
            }

            return(app);
        }