/// <summary> /// 创建数据库实例 /// </summary> /// <returns></returns> public static ClsDBConnection GetConn() { ClsDBConnection Result = (m_Conn == null) ? new ClsDBConnection() : m_Conn; if (Result.ConnState == System.Data.ConnectionState.Closed) { Result.Open(); } return(Result); }
public bool MailConnect(string p_User, string p_Pass) { //判断系统是否注册此用户 ClsDBConnection m_oDb = new ClsDBConnection(); m_oDb.Open(); string strUserCountSql = "SELECT COUNT(*) FROM TBREGUSERINFO WHERE USER_CODE = '" + p_User + "'"; string strCount = m_oDb.GetSqlResultToStr(strUserCountSql); if (strCount == "0" || strCount == "") { return(false); } //注册验证邮件 bool Result = true; //中油信箱 string strMailSql = "SELECT SYS_VALUE FROM SAP_SYSCONFIG WHERE SYS_CODE = 'MailAddress'"; string strPopServer = m_oDb.GetSqlResultToStr(strMailSql); string strUser = p_User; string strPass = p_Pass; try { //用110端口新建POP3服务器连接 Server = new TcpClient(strPopServer, 110); //初始化 NetStrm = Server.GetStream(); RdStrm = new StreamReader(Server.GetStream()); string strMegage = RdStrm.ReadLine(); Result = CheckMailResult(strMegage); //登录服务器过程 Data = "USER " + strUser + CRLF; szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray()); NetStrm.Write(szData, 0, szData.Length); strMegage = RdStrm.ReadLine(); Result = CheckMailResult(strMegage); Data = "PASS " + strPass + CRLF; szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray()); NetStrm.Write(szData, 0, szData.Length); strMegage = RdStrm.ReadLine(); Result = CheckMailResult(strMegage); } catch (InvalidOperationException err) { Result = false; } m_oDb.Dispose(); return(Result); }