/// <summary>
        /// 测试连接
        /// </summary>
        /// <returns></returns>
        public bool TryConnect()
        {
            try
            {
                //外部命令行方法参数列表
                List <string> cmdParamSet = new List <string>();

                //使用变量替换参数模板
                string exportParam = DbtuneTemplate.DBTUNE_EXPORT_PARAM;
                exportParam = SetBaseParam(exportParam);
                exportParam = exportParam.Replace("{file_path}", this._filePath + DBTUNE_FILE_NAME);

                cmdParamSet.Add(exportParam);

                string cmdInvorkOutput = CmdInvork(cmdParamSet);

                if (RegexCheck.IsExist(cmdInvorkOutput, CMD_ERROR_STATE))
                {
                    LogHelper.Error.Append(cmdInvorkOutput);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error.Append(ex);

                return(false);
            }
        }
        /// <summary>
        /// 删除配置(删除整个关键字)
        /// </summary>
        /// <param name="keyWord">配置关键字</param>
        /// <returns></returns>
        public bool DeleteConfig(string keyWord)
        {
            try
            {
                List <string> cmdParamSet = new List <string>();

                string deleteParam = DbtuneTemplate.DBTUNE_DELETE_PARAM_1;
                deleteParam = SetBaseParam(deleteParam);
                deleteParam = deleteParam.Replace("{key_word}", keyWord);

                cmdParamSet.Add(deleteParam);

                //这里因为dbtune配置参数的导入命令需要用户确认,故在参数列表里传入一个'Y'
                cmdParamSet.Add("Y");

                string cmdInvorkOutput = CmdInvork(cmdParamSet);

                if (RegexCheck.IsExist(cmdInvorkOutput, CMD_ERROR_STATE))
                {
                    LogHelper.Error.Append(cmdInvorkOutput);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error.Append(ex);

                return(false);
            }
        }
        /// <summary>
        /// 插入配置参数
        /// </summary>
        /// <param name="keyWord">配置关键字</param>
        /// <param name="paramName">参数名</param>
        /// <param name="paramValue">参数内容</param>
        /// <returns></returns>
        public bool InsertConfig(string keyWord, string paramName, string paramValue)
        {
            try
            {
                List <string> cmdParamSet = new List <string>();

                string insertParam = DbtuneTemplate.DBTUNE_INSERT_PARAM;
                insertParam = SetBaseParam(insertParam);
                insertParam = insertParam.Replace("{key_word}", keyWord).Replace("{param_name}", paramName).Replace("{parameter_value}", paramValue);

                cmdParamSet.Add(insertParam);

                //这里因为dbtune配置参数的导入命令需要用户确认,故在参数列表里传入一个'Y'
                cmdParamSet.Add("Y");

                string cmdInvorkOutput = CmdInvork(cmdParamSet);

                if (RegexCheck.IsExist(cmdInvorkOutput, CMD_ERROR_STATE))
                {
                    LogHelper.Error.Append(cmdInvorkOutput);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error.Append(ex);

                return(false);
            }
        }
Exemple #4
0
        /// <summary>
        /// 创建(描述当前用户自定义dbtune配置的)XML文件
        /// </summary>
        private static void CreateXml(IDBHelper dbHelper, string filePath)
        {
            XDocument xml = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement(ROOT_NAME));

            xml.Save(string.Format("{0}\\{1}.xml", Environment.CurrentDirectory, UtilityConst.XML_NAME));

            DbtuneHelper dbtuneHelper = new DbtuneHelper(filePath, dbHelper.DBServiceName.Split('/')[0], dbHelper.DBPort, dbHelper.DBUser, dbHelper.DBPwd);

            List <string> keywordSet = dbtuneHelper.ListConfig();

            List <string> keywordScreenedSet = new List <string>();

            for (int i = 0; i < keywordSet.Count; i++)
            {
                if (!RegexCheck.IsExist(ScreenTemplate.ScreenDbtuneReservedKeyWord, keywordSet[i]))
                {
                    keywordScreenedSet.Add(keywordSet[i]);
                }
            }

            for (int i = 0; i < keywordScreenedSet.Count; i++)
            {
                InsertKeyWord(new DbtuneInfo()
                {
                    KeyWord    = keywordScreenedSet[i],
                    ParamName  = PartitionKeyWordInfo.DBTUNE_PARAM_NAME,
                    ParamValue = dbtuneHelper.ListConfig(keywordScreenedSet[i], PartitionKeyWordInfo.DBTUNE_PARAM_NAME)
                });
            }
        }
Exemple #5
0
 /// <summary>
 /// 检查分区流程涉及参数
 /// </summary>
 /// <returns></returns>
 internal static bool CheckPartitionParam(MemoEdit txbBlog, PartitionParam partitionParam)
 {
     if (partitionParam.DBHelper == null)
     {
         WriteBlog(txbBlog, "---  数据库连接异常, 请查看错误日志");
         return(false);
     }
     else if (RegexCheck.IsEmpty(partitionParam.TablespaceName))
     {
         WriteBlog(txbBlog, "---  未指定表空间");
         return(false);
     }
     else if (RegexCheck.IsEmpty(partitionParam.OriginTableName))
     {
         WriteBlog(txbBlog, "---  未指定初始表");
         return(false);
     }
     else if (RegexCheck.IsEmpty(partitionParam.BasicField))
     {
         WriteBlog(txbBlog, "---  未指定分区列");
         return(false);
     }
     else if (partitionParam.PartitionWay == EnumPartitionWay.Unknow)
     {
         WriteBlog(txbBlog, "---  未指定分区方式");
         return(false);
     }
     else if (!RegexCheck.IsFull(partitionParam.TablespaceSet))
     {
         WriteBlog(txbBlog, "---  存在没有指定表空间的分区");
         return(false);
     }
     else if (RegexCheck.IsExist(QueryUnityInfo.QueryTotalTable(partitionParam.DBHelper, partitionParam.TablespaceName), partitionParam.PartitionedTableName))
     {
         WriteBlog(txbBlog, "---  名字为 " + partitionParam.PartitionedTableName + "的表已经存在,请更改导出名");
         return(false);
     }
     else
     {
         if (partitionParam.PartitionWay == EnumPartitionWay.Range && partitionParam.PartitionCount == -1)
         {
             WriteBlog(txbBlog, "---未指定范围分区数");
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
Exemple #6
0
        /// <summary>
        /// 获取分区基准字段的基本类型
        /// </summary>
        /// <returns></returns>
        private EnumBaseDataType GetFieldBaseType()
        {
            Dictionary <string, string> columnInfoSet = QueryUnityInfo.QueryColumnInfo(this._featureClass);

            if (RegexCheck.IsExist(ScreenTemplate.ScreenNumericType, this._basicField))
            {
                return(EnumBaseDataType.NUMERIC);
            }
            else if (RegexCheck.IsExist(ScreenTemplate.ScreenCharacterType, this._basicField))
            {
                return(EnumBaseDataType.CHARACTER);
            }
            else
            {
                return(EnumBaseDataType.DATATIME);
            }
        }
        /// <summary>
        /// 导入配置
        /// </summary>
        /// <returns></returns>
        public bool ImportConfig()
        {
            try
            {
                string filePath = this._filePath + DBTUNE_FILE_NAME;

                if (!File.Exists(filePath))
                {
                    return(false);
                }

                List <string> cmdParamSet = new List <string>();

                string importParam = DbtuneTemplate.DBTUNE_IMPORT_PARAM;
                importParam = SetBaseParam(importParam);
                importParam = importParam.Replace("{file_path}", filePath);

                cmdParamSet.Add(importParam);

                //这里因为dbtune配置参数的导入命令需要用户确认,故在参数列表里传入一个'Y'
                cmdParamSet.Add("Y");

                string cmdInvorkOutput = CmdInvork(cmdParamSet);

                if (RegexCheck.IsExist(cmdInvorkOutput, CMD_ERROR_STATE))
                {
                    LogHelper.Error.Append(cmdInvorkOutput);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error.Append(ex);

                return(false);
            }
        }
Exemple #8
0
        /// <summary>
        /// 选择分区基准列下拉列表的关闭事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmbColumnIdentity_Closed(object sender, DevExpress.XtraEditors.Controls.ClosedEventArgs e)
        {
            this._comboBox = (ComboBoxEdit)sender;

            if (this._comboBox.SelectedIndex != -1)
            {
                //判断分区基准列是否是字符型,若是,关闭分区方式下拉列表的权限,只能使用列表分区
                if (RegexCheck.IsExist(ScreenTemplate.ScreenCharacterType, this._columnInfoSet[this._comboBox.SelectedItem.ToString()]))
                {
                    this.cmbPartitionWay.SelectedIndex = (int)EnumPartitionWay.List;
                    this.cmbPartitionWay.Enabled       = false;

                    PrepareListPartition("所选字段为字符型,只可使用列表分区,正在分析分区数量");
                }
                else
                {
                    this.cmbPartitionWay.Enabled       = true;
                    this.cmbPartitionWay.SelectedIndex = -1;
                    this.txbTips.Text = string.Empty;
                }
                this.btnAssignTablespace.Text = string.Empty;
            }
        }