Exemple #1
0
        /// <summary>
        /// Data Source=*;Initial Catalog=*;Connect Timeout=0;Persist Security Info=True;User ID=*;Password=*      
        /// </summary>
        /// <param name="connectionString">connectionString</param>
        public DBConnectParams(string connectionString)
        {
            if (string.IsNullOrEmpty(connectionString))
                throw new Exception("Fail to get ConnectionString,Please check config file! ");
            else
            {
                MatchCollection matches = Regex.Matches(connectionString, @"(([^;=]+)=([^;=#]*))", RegexOptions.Compiled);
                if (!connectionString.ToLower().Contains("integrated security"))
                {
                    foreach (Match m in matches)
                    {
                        switch (m.Groups[2].Value.ToLower().Trim())
                        {
                            case "data source":
                            case "server":
                                this._server = m.Groups[3].Value;
                                break;
                            case "initial catalog":
                            case "database":
                                this._database = m.Groups[3].Value;
                                break;
                            case "user id":
                            case "uid":
                                this._userId = m.Groups[3].Value;
                                break;
                            case "password":
                                this._password = m.Groups[3].Value;
                                break;
                            case "pwd":
                                this._password = m.Groups[3].Value;
                                break;
                        }
                    }

                    if (string.IsNullOrEmpty(this._server) || string.IsNullOrEmpty(this._database)
                        || string.IsNullOrEmpty(this._userId))
                        throw new Exception("Fail to get ConnectionString,Please check! ");
                    this._verifyType = VerifyTypeEnum.Database;
                }
                else
                {
                    foreach (Match m in matches)
                    {
                        switch (m.Groups[2].Value.ToLower().Trim())
                        {
                            case "data source":
                            case "server":
                                this._server = m.Groups[3].Value;
                                break;
                            case "initial catalog":
                            case "database":
                                this._database = m.Groups[3].Value;
                                break;
                        }
                    }

                    if (string.IsNullOrEmpty(this._server) || string.IsNullOrEmpty(this._database))
                        throw new Exception("Fail to get ConnectionString,Please check! ");
                    this._verifyType = VerifyTypeEnum.Windows;
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// New with VerifyTypeEnum.Database
 /// </summary>
 /// <param name="strServer">servername</param>
 /// <param name="strDB">DataBase</param>
 /// <param name="strUserID">UserID</param>
 /// <param name="strPwd">UserPassword</param>
 public DBConnectParams(string strServer, string strDB, string strUserID, string strPwd)
 {
     this._verifyType = VerifyTypeEnum.Database;
     this._server = strServer;
     this._database = strDB;
     this._userId = strUserID;
     this._password = strPwd;
 }
Exemple #3
0
 /// <summary>
 /// New with VerifyTypeEnum.Windows
 /// </summary>
 /// <param name="strServer">serverName</param>
 /// <param name="strDB">database</param>
 public DBConnectParams(string strServer, string strDB)
 {
     this._verifyType = VerifyTypeEnum.Windows;
     this._server = strServer;
     this._database = strDB;
 }
Exemple #4
0
 /// <summary>
 /// New with Empty
 /// </summary>
 public DBConnectParams()
 {
     this._verifyType = VerifyTypeEnum.Windows;
     this._server = string.Empty;
 }
Exemple #5
0
 /// <summary>
 /// 获取验证信息
 /// </summary>
 /// <param name="token"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public VerifyEntity GetVerifyInfo(string token, VerifyTypeEnum type)
 {
     return(_content.Verifies.Where(x => x.Token == token && x.Status == (int)VerifyStatusEnum.Normal && x.Type == (int)type).FirstOrDefault());
 }
 /// <summary>
 /// 获取验证信息
 /// </summary>
 /// <param name="token"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public VerifyEntity GetVerifyInfo(string token, VerifyTypeEnum type)
 {
     return(_data.GetVerifyInfo(token, type));
 }