private void UpdateJsonConfigData(ConfigModel.JsonConfig newJsonObj)
        {
            var modifiedJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(newJsonObj);

            File.WriteAllText(_jsonFileName, modifiedJsonString, Encoding.UTF8);
            RefreshConfigData();
        }
        private void RefreshConfigData()
        {
            this._config = null;
//            using (StreamReader r = new StreamReader(_jsonFileName))
//            {
//                string json = r.ReadToEnd();
//                ConfigModel.JsonConfig config = ConfigUtil.Deserialize<ConfigModel.JsonConfig>(json);
//                this._config = config;
//
//            }
        }
        private void RefreshConfigData()
        {
            ConfigModel.JsonConfig config = null;
            using (StreamReader r = new StreamReader(_jsonFileName, System.Text.Encoding.Default))
            {
                string json = r.ReadToEnd();
                config = ConfigUtil.Deserialize <ConfigModel.JsonConfig>(json);
            }

            if (config != null &&
                (config.Alert != null || config.AlertRecord != null || config.Apikey != null || config.Focus != null || config.Period != null))
            {
                this._config = config;
            }
            else
            {
                //如果抓不到config 就init一個新的
                UpdateJsonConfigData(new ConfigModel.JsonConfig()
                {
                    Apikey = "", Alert = new List <ConfigModel.AlertRule>(), AlertRecord = new List <ConfigModel.AlertRecord>(),
                    Focus  = new ConfigModel.FocusSetting(), Period = new List <ConfigModel.PeriodRule>()
                });
            }
        }
        public ConfigModel.PeriodRule GetPeriodRuleByPeriodName(ConfigModel.JsonConfig config, string periodName)
        {
            var period = _config.Period.FirstOrDefault(s => String.Equals(s.PeriodName, periodName, StringComparison.CurrentCultureIgnoreCase));

            return(period);
        }
 public ConfigModel.PeriodRule GetPeriodRuleByPeriodName(ConfigModel.JsonConfig config, string periodName)
 {
     return(_config.GetPeriodRuleByPeriodName(config, periodName));
 }
 private void UpdateJsonConfigData(ConfigModel.JsonConfig newJsonObj)
 {
     throw new NotImplementedException();
 }
 public ConfigModel.PeriodRule GetPeriodRuleByPeriodName(ConfigModel.JsonConfig config, string periodName)
 {
     throw new NotImplementedException();
 }