Exemple #1
0
 /// <summary>
 /// Save config to redis and update memory
 /// </summary>
 /// <param name="config"></param>
 /// <param name="scheduledTasks"></param>
 public static void Save(ConfigDto config, List<ScheduledTaskDto> scheduledTasks)
 {
     var configService = new ConfigService();
     configService.SaveScheduledTasks(scheduledTasks);
     config.ScheduledTaskIds = scheduledTasks.Select(x => x.TaskId).ToList();
     configService.SaveConfig(config);
     _scheduledTasks = scheduledTasks;
     _configuration = config;
 }
Exemple #2
0
        /// <summary>
        /// Initialize configuration, create default and load
        /// </summary>
        public static void Init()
        {
            var config = Load();
            if (config != null) return;

            config = new ConfigDto();
            var scheduledTasks = new List<ScheduledTaskDto>();
            Save(config, scheduledTasks);
        }
Exemple #3
0
        /// <summary>
        /// Get config from redis
        /// </summary>
        public static ConfigDto Load()
        {
            var configService = new ConfigService();
            _configuration = configService.GetConfig();

            if (_configuration == null)
                return null;

            _scheduledTasks = configService.GetScheduledTasks(_configuration.ScheduledTaskIds);
            return _configuration;
        }
Exemple #4
0
 public void SaveConfig(ConfigDto config)
 {
     var query = new ConfigQuery();
     _configQueryHandler.CreateOrUpdateValueById<ConfigDto>(query, config);
 }