RefreshSection() public static method

public static RefreshSection ( string sectionName ) : void
sectionName string
return void
Ejemplo n.º 1
0
        public static void UpdateDailyAnnoucement(int h, int m, int s, int interval, int loops, string command)
        {
            Configuration config = ConfManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            string delim = ConfManager.AppSettings["AnnMess"] == "" ? "" : "|";

            string annMess     = ConfManager.AppSettings["AnnMess"] + delim + command;
            string annTime     = ConfManager.AppSettings["AnnTime"] + delim + h + ":" + m;
            string annLoops    = ConfManager.AppSettings["AnnLoops"] + delim + loops;
            string annInterval = ConfManager.AppSettings["AnnInterval"] + delim + interval;

            config.AppSettings.Settings["AnnMess"].Value     = annMess;
            config.AppSettings.Settings["AnnTime"].Value     = annTime;
            config.AppSettings.Settings["AnnLoops"].Value    = annLoops;
            config.AppSettings.Settings["AnnInterval"].Value = annInterval;
            config.Save(ConfigurationSaveMode.Modified);
            ConfManager.RefreshSection("appSettings");


            //TelepresenceScheduler.DeleteDailyAnnouncement();
            //LoadDailyAnnouncement();
            Action action = new Action(() =>
            {
                SpeechGeneration.SpeakAsync(command);
            });

            TelepresenceScheduler.DailyIntervalInSeconds(h, m, s, interval, loops, action);
        }
Ejemplo n.º 2
0
        private void ChangeFoowwEnvironmentToTest(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            string appConfigPath              = GetStartupProjectDirectoryPath() + @"\app.config";
            string environmentNode            = "Environment";
            ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();

            configMap.ExeConfigFilename = appConfigPath;
            Configuration appConfig = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);

            // 没有配置,需要新增测试环境配置
            if (!appConfig.AppSettings.Settings.AllKeys.Contains(environmentNode))
            {
                appConfig.AppSettings.Settings.Add(environmentNode, "Test");
                appConfig.Save(ConfigurationSaveMode.Modified);
                //使connectionStrings配置节缓存失效,下次必须从磁盘读取
                ConfigurationManager.RefreshSection("appSettings");
                return;
            }

            // 否则改为测试
            string value = appConfig.AppSettings.Settings[environmentNode].Value;

            if (value.ToLower() != "test")
            {
                appConfig.AppSettings.Settings[environmentNode].Value = "Test";
                appConfig.Save(ConfigurationSaveMode.Modified);
                //使connectionStrings配置节缓存失效,下次必须从磁盘读取
                ConfigurationManager.RefreshSection("appSettings");
            }
        }
        public static void DeleteDailyAnnouncement()
        {
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);


            config.AppSettings.Settings["AnnMess"].Value     = "";
            config.AppSettings.Settings["AnnTime"].Value     = "";
            config.AppSettings.Settings["AnnLoops"].Value    = "";
            config.AppSettings.Settings["AnnInterval"].Value = "";
            config.Save(ConfigurationSaveMode.Modified);
            ConfManager.RefreshSection("appSettings");
            SchedulerService.DeleteAllTimersForEveryday();
        }