Пример #1
0
        /// <summary>
        /// 保存数据库配置 xiecongwen 20140822
        /// </summary>
        /// <param name="dbconfig"></param>
        /// <returns></returns>
        private void SaveDB(Model.DBConfig dbconfig)
        {
            string settingName = "BudBackup2Context";
            string connstr     = string.Format("server={0};uid={1};pwd={2};database={3};", dbconfig.ServerName, dbconfig.LoginName, dbconfig.Password, dbconfig.DatabaseName);

            ExeConfigUtil.SetConnectionString(settingName, connstr);
        }
Пример #2
0
        /// <summary>
        /// 获取配置
        /// </summary>
        /// <returns></returns>
        public Model.Config LoadConfig()
        {
            Model.Config config = new Model.Config();
            config.Path = new Model.PathConfig()
            {
                InputLogPath = ExeConfigUtil.GetAPPSettingValue("LogPath") ?? "",
                OutputPath   = ExeConfigUtil.GetAPPSettingValue("SSHPath") ?? ""
            };
            string dbconnctionstring = ExeConfigUtil.GetConnectionString("BudBackup2Context");

            //待完善:应使用正则表达式校验格式,防止用户收到配置错误
            string[] paras = dbconnctionstring.Split(';');
            config.DB = new Model.DBConfig()
            {
                ServerName   = paras[0].Split('=')[1],
                LoginName    = paras[1].Split('=')[1],
                Password     = paras[2].Split('=')[1],
                DatabaseName = paras[3].Split('=')[1]
            };

            //调度间隔
            config.SynchronizingTimeInterval = ExeConfigUtil.GetAPPSettingValue("SynchronizingTimeInterval") ?? "";

            //同步开始时间
            config.SSHLocalSyncTime = ExeConfigUtil.GetAPPSettingValue("SSHLocalSyncTime") ?? "";

            //read log time
            config.ReadLogTime = ExeConfigUtil.GetAPPSettingValue("readLogTime") ?? "";

            //DB Sync Time
            config.DBSyncTime = ExeConfigUtil.GetAPPSettingValue("DBSyncTime") ?? "";

            //SSH Boot Time
            config.SSHBootTime = ExeConfigUtil.GetAPPSettingValue("SSHBootTime") ?? "";

            return(config);
        }
Пример #3
0
 /// <summary>
 /// 保存路径信息 xiecongwen 20140822
 /// </summary>
 /// <param name="ptconfig"></param>
 /// <returns></returns>
 private void SavePath(Model.PathConfig ptconfig)
 {
     ExeConfigUtil.SetAPPSettingValue("LogPath", ptconfig.InputLogPath);
     ExeConfigUtil.SetAPPSettingValue("SSHPath", ptconfig.OutputPath);
     ConfigurationManager.RefreshSection("appSettings");
 }