Beispiel #1
0
        /// <summary>
        /// 初始化数据库连接
        /// </summary>
        private void InitDbConnect()
        {
            this._dbHelper = DBHelper.Create(DBHelper.enumDBType.DB_Oracle);

            this._dbConnectParam = new DbConnectParam();
            this._dbConnectParam.Clear();

            //this.txbDBServer.Text = string.Empty;
            //this.txbDbPort.Text = string.Empty;
            //this.txbDbSid.Text = string.Empty;
            //this.txbDbUser.Text = string.Empty;
            //this.txbDbPwd.Text = string.Empty;
        }
Beispiel #2
0
        /// <summary>
        /// 初始化数据库连接帮助类
        /// 尝试连接
        /// </summary>
        /// <param name="txbBlog"></param>
        /// <param name="dbHelper"></param>
        /// <param name="dbConnectParam"></param>
        /// <param name="workflow"></param>
        /// <returns></returns>
        internal static bool TryConnect(MemoEdit txbBlog, ref IDBHelper dbHelper, DbConnectParam dbConnectParam, EnumWorkFlow workflow)
        {
            dbHelper.DBServiceName = string.Format("{0}/{1}", dbConnectParam.DBServer, dbConnectParam.DbSid);
            dbHelper.DBPort        = dbConnectParam.DbPort;
            dbHelper.DBUser        = dbConnectParam.DbUser;
            dbHelper.DBPwd         = dbConnectParam.DbPwd;

            try
            {
                if (workflow == EnumWorkFlow.TablePartition)
                {
                    if (dbHelper.TryConnect())
                    {
                        WriteBlog(txbBlog, "---  数据库连接成功");
                        return(true);
                    }
                    else
                    {
                        WriteBlog(txbBlog, "---  数据库连接异常, 请查看错误日志");
                        return(false);
                    }
                }
                else
                {
                    DbtuneHelper dbtuneHelper = new DbtuneHelper(Environment.CurrentDirectory, dbConnectParam.DBServer, dbConnectParam.DbPort, dbConnectParam.DbUser, dbConnectParam.DbPwd);

                    if (dbtuneHelper.TryConnect())
                    {
                        WriteBlog(txbBlog, "---  SDE服务连接成功");
                        return(true);
                    }
                    else
                    {
                        WriteBlog(txbBlog, "---  SDE服务连接异常, 请查看错误日志");
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #3
0
 /// <summary>
 /// 检查数据库连接参数
 /// </summary>
 /// <returns></returns>
 internal static bool CheckConnectParam(MemoEdit txbBlog, DbConnectParam dbConnectParam)
 {
     if (RegexCheck.IsEmpty(dbConnectParam.DBServer))
     {
         WriteBlog(txbBlog, "---  未指定IP地址");
         return(false);
     }
     else if (!RegexCheck.IsIPv4(dbConnectParam.DBServer))
     {
         WriteBlog(txbBlog, "---  指定的IP地址格式不正确");
         return(false);
     }
     else if (RegexCheck.IsEmpty(dbConnectParam.DbPort))
     {
         WriteBlog(txbBlog, "---  未指定端口号");
         return(false);
     }
     else if (!RegexCheck.IsUint(dbConnectParam.DbPort))
     {
         WriteBlog(txbBlog, "---  指定的端口号格式不正确");
         return(false);
     }
     else if (RegexCheck.IsEmpty(dbConnectParam.DbSid))
     {
         WriteBlog(txbBlog, "---  未指定实例名");
         return(false);
     }
     else if (RegexCheck.IsEmpty(dbConnectParam.DbUser))
     {
         WriteBlog(txbBlog, "---  未指定登陆名");
         return(false);
     }
     else if (RegexCheck.IsEmpty(dbConnectParam.DbPwd))
     {
         WriteBlog(txbBlog, "---  未指定口令");
         return(false);
     }
     else
     {
         return(true);
     }
 }