Exemple #1
0
//保存单个系统配置文件
func (this *IndexInfo) SaveSingleConf() (err error) {
	var (
		cfgPath string = "config/config.ini"
		retErr  error
	)
	cfg, _ := goconfig.LoadConfigFile(cfgPath)
	IndexInfoToCfg(this, cfg)
	retErr = goconfig.SaveConfig(cfg, cfgPath)
	iniPath := "xml/" + this.Dirname + "/" + this.Dirname + ".ini"
	xmlIniCfg, _ := goconfig.LoadConfigFile(iniPath)
	IndexInfoToIni(this, xmlIniCfg)
	retErr = goconfig.SaveConfig(xmlIniCfg, iniPath)
	return retErr
}
Exemple #2
0
//保存所有配置文件
func (this *IndexInfo) SaveAllConf() (err error) {
	var (
		cfgPath string = "config/config.ini"
		retErr  error
	)
	xmlInies := GetXmlIniNames()
	cfg, _ := goconfig.LoadConfigFile(cfgPath)
	IndexInfoToCfg(this, cfg)
	retErr = goconfig.SaveConfig(cfg, cfgPath)
	for _, v := range xmlInies {
		xmlIniCfg, _ := goconfig.LoadConfigFile(v)
		IndexInfoToIni(this, xmlIniCfg)
		retErr = goconfig.SaveConfig(xmlIniCfg, v)
	}
	return retErr
}
Exemple #3
0
/**合并文件*/
func joinFiles() {
	//判断密码是否以enc`开头,去掉enc`
	bakXmlInies := getXmlNames("xml_bak")
	for _, bakPath := range bakXmlInies {
		newIniPath := strings.Replace(bakPath, "xml_bak", "xml_ini", 1)
		bakXmlIniCfg, bakErr := goconfig.LoadConfigFile(bakPath)
		newXmlIniCfg, newErr := goconfig.LoadConfigFile(newIniPath)
		if bakXmlIniCfg != nil && newXmlIniCfg != nil && bakErr == nil && newErr == nil { //替换文件
			joinToIni(bakXmlIniCfg, newXmlIniCfg)
			retErr := goconfig.SaveConfig(newXmlIniCfg, newIniPath)
			if retErr != nil {
				logger.Error("retErr=", retErr)
			}
		}
	}
}
Exemple #4
0
/**设置xml*/
func joinXml() {
	defer func() {
		if err := recover(); err != nil {
			logger.Error("joinXml捕获到异常:", err)
		}
	}()
	content, err := ioutil.ReadFile("DataProvider.xml")
	if err != nil {
		panic(err)
		logger.Error(err)
	}
	var result Provider_upgrade
	err = xml.Unmarshal(content, &result)
	if err != nil {
		panic(err)
		logger.Error(err)
	}
	trans := ""
	notrans := ""
	j := 0
	for i := range result.Sys.Provider {
		logger.Info(result.Sys.Provider[i].Dictoryname)
		state := result.Sys.Provider[i].State
		if strings.EqualFold(state, "start") {
			logger.Info("state================", state)
			dirName := result.Sys.Provider[i].Dictoryname
			if strings.Contains(dirName, "Network") {
				notrans = "Network"
			} else {
				if j == 0 {
					trans = dirName
				} else {
					s := []string{trans, dirName}
					trans = strings.Join(s, ",")
				}
				j++
			}
		}
	}
	logger.Info("trans================", trans)
	logger.Info("notrans================", notrans)
	cfg, bakErr := goconfig.LoadConfigFile("conf/config.ini")
	if bakErr == nil {
		sites, _ := cfg.Get("config::sites")
		transferes, _ := cfg.Get("config::transferes")
		nosql, _ := cfg.Get("config::nosql")
		singletimer, _ := cfg.Get("config::singletimer")
		repeatetimer, _ := cfg.Get("config::repeatetimer")
		configpage, _ := cfg.Get("config::configpage")

		if len(trans) > 0 {
			transferes = trans
		}
		if len(notrans) > 0 {
			nosql = notrans
		}

		cfg.Set("config", "sites", sites)
		cfg.Set("config", "transferes", transferes)
		cfg.Set("config", "nosql", nosql)
		cfg.Set("config", "singletimer", singletimer)
		cfg.Set("config", "repeatetimer", repeatetimer)
		cfg.Set("config", "configpage", configpage)
		retErr := goconfig.SaveConfig(cfg, "conf/config.ini")
		if retErr != nil {
			logger.Error("retErr=", retErr)
		}
	}
}