public OraclePocoHelper(DBInfo dbInfo)
        {
            #region 資料驗證

            if (dbInfo == null)
                throw new ArgumentNullException("DBInfo", "參數遺失");

            if (string.IsNullOrWhiteSpace(dbInfo.HostIP))
                throw new ArgumentNullException("主機名稱", "必填");

            if (string.IsNullOrWhiteSpace(dbInfo.DBName))
                throw new ArgumentNullException("Service Name", "必填");

            if (string.IsNullOrWhiteSpace(dbInfo.DBOwner))
                throw new ArgumentNullException("DB Owner Name", "必填");

            if (string.IsNullOrWhiteSpace(dbInfo.UserID))
                throw new ArgumentNullException("使用者名稱", "必填");

            if (string.IsNullOrWhiteSpace(dbInfo.UserPwd))
                throw new ArgumentNullException("密碼", "必填");

            #endregion 資料驗證

            _HostIP = dbInfo.HostIP;
            _Port = dbInfo.Port;
            _UserID = dbInfo.UserID;
            _UserPwd = dbInfo.UserPwd;
            _ServiceName = dbInfo.DBName;
            _OwnerName = dbInfo.DBOwner;
            connStr = string.Format(connstrFormat, _HostIP, _ServiceName, _UserID, _UserPwd, _Port);
        }
        public MSSQLPocoHelper(DBInfo dbInfo)
        {
            #region 資料驗證

            if (dbInfo == null)
                throw new ArgumentNullException("DBInfo", "參數遺失");

            if (string.IsNullOrWhiteSpace(dbInfo.HostIP))
                throw new ArgumentNullException("主機名稱", "必填");

            if (string.IsNullOrWhiteSpace(dbInfo.DBName))
                throw new ArgumentNullException("資料庫名稱名稱", "必填");

            if (!dbInfo.ValidateByWindow)
            {
                if (string.IsNullOrWhiteSpace(dbInfo.UserID))
                    throw new ArgumentNullException("使用者名稱", "必填");
                if (string.IsNullOrWhiteSpace(dbInfo.UserPwd))
                    throw new ArgumentNullException("密碼", "必填");
            }

            #endregion 資料驗證

            _HostIP = dbInfo.HostIP;
            _UserID = dbInfo.UserID;
            _UserPwd = dbInfo.UserPwd;
            _DBName = dbInfo.DBName;
            _IsValidateWindow = dbInfo.ValidateByWindow;

            connStr = string.Format(connstrFormat, _HostIP, _DBName, _UserID, _UserPwd);
            if (_IsValidateWindow)
                this.connStr += "Integrated Security=True;";
        }
Beispiel #3
0
        /// <summary>
        /// 更新DBInf設定設定App.Config 中AppSetting 
        /// </summary>
        /// <param name="dbInfo"> <see cref="DBInfo" /> </param>
        public static void UpdateDbInfo(DBInfo dbInfo)
        {
            foreach (var prop in dbInfo.GetType().GetProperties())
            {
                var val = prop.GetValue(dbInfo);
                var key = prop.Name;

                UpdateSetting(key, val.ToString());
            }
        }
        public IPocoHelper GetPocoHelper(string dbType, DBInfo dbinfo)
        {
            IPocoHelper helper = null;

            switch (dbType)
            {
                case "MSSQL":
                    helper = new MSSQLPocoHelper(dbinfo);
                    break;
                case "Oracle":
                    helper = new OraclePocoHelper(dbinfo);
                    break;
                default:
                    throw new NotSupportedException("Not Support" + dbType);
            }
            return helper;
        }
Beispiel #5
0
 public IPocoHelper GetPocoHelper(string dbType, DBInfo dbInfo)
 {
     IPocoHelper helper;
     helper = _factory.GetPocoHelper(dbType, dbInfo);
     return helper;
 }
Beispiel #6
0
        private DBInfo GetDBInfo()
        {
            var dbInfo = new DBInfo()
                         {
                             DBType = ddlDbType.SelectedIndex,
                             HostIP = tbxHost.Text.Trim(),
                             Port = tbxPort.Text.Trim(),
                             UserID = tbxUserName.Text.Trim(),
                             UserPwd = tbxPwd.Text.Trim(),
                             DBName = tbxDBName.Text.Trim(),
                             ValidateByWindow = cbxValidateByWindow.Checked,
                             DBOwner = tbxDBOwner.Text.Trim()
                         };

            return dbInfo;
        }