/// <summary> /// 检查某节点是否已存在 /// </summary> /// <param name="keyWord"></param> /// <returns></returns> public static bool CheckKeyWordExist(string keyWord) { bool isExist = false; List <DbtuneInfo> dbtuneConfigSet = DbtuneXMLOperate.ListKeyWord(); if (dbtuneConfigSet.Count != 0) { for (int i = 0; i < dbtuneConfigSet.Count; i++) { if (keyWord == dbtuneConfigSet[i].KeyWord) { isExist = true; break; } } } return(isExist); }
/// <summary> /// 展示配置关键字 /// </summary> /// <param name="dbtuneKeyWord"></param> /// <returns></returns> public bool DeleteConfigEX(string dbtuneKeyWord) { try { if (DbtuneXMLOperate.CheckKeyWordExist(dbtuneKeyWord)) { this._dbtuneHelper.DeleteConfig(dbtuneKeyWord); DbtuneXMLOperate.DeleteKeyWord(dbtuneKeyWord); return(true); } else { return(false); } } catch (Exception ex) { LogHelper.Error.Append(ex); throw ex; } }
/// <summary> /// 新增并更改一条配置 /// </summary> /// <returns></returns> public bool AlterParamValueEX() { try { //导出默认配置 if (this._dbtuneHelper.ExportConfig()) { //增加配置 if (this._dbtuneHelper.AddConfig(this._dbtuneKeyWord)) { //导入配置 if (this._dbtuneHelper.ImportConfig()) { string dbtuneParamValue = string.Empty; //创建配置值 if (this._partitionWay == EnumPartitionWay.List) { dbtuneParamValue = CreateDbtuneParamValueInList(); } else if (this._partitionWay == EnumPartitionWay.Range) { dbtuneParamValue = CreateDbtuneParamValueInRange(); } //替换配置值 if (this._dbtuneHelper.AlterConfig(this._dbtuneKeyWord, PartitionKeyWordInfo.DBTUNE_PARAM_NAME, dbtuneParamValue)) { DbtuneXMLOperate.InsertKeyWord(new DbtuneInfo() { KeyWord = this._dbtuneKeyWord, ParamName = PartitionKeyWordInfo.DBTUNE_PARAM_NAME, ParamValue = dbtuneParamValue }); return(true); } else { return(false); } } else { return(false); } } else { return(false); } } else { return(false); } } catch (Exception ex) { LogHelper.Error.Append(ex); return(false); } }