/// <summary> /// Notice: /// Because OleDB Suppor many db types . /// So the UsingOleDbType property in LoginInfo should be specifed. otherwise will use default db type -->Here is Oracle /// </summary> /// <param name="pInfo"></param> public override void Open(BaseLoginInfo pInfo) { //Record to base class (Vital) baseLoginInfo = pInfo; LoginInfo_Oracle myInfo = pInfo as LoginInfo_Oracle; LoginInfo_ForAllDbTypes allInfo = pInfo as LoginInfo_ForAllDbTypes; if ((myInfo == null) && (allInfo == null)) { throw new ArgumentException("Only Support Oledb login info and AllDBTypes Info"); } if (IsOpened) { return; } string myConnString = string.Empty; try { if (allInfo != null) { myInfo = new LoginInfo_Oracle(); //Acctually the SID is the global db name in Oracle //It is different from other db types myInfo.SID = allInfo.Database; myInfo.Username = allInfo.Username; myInfo.Password = allInfo.Pwd; myInfo.Port = allInfo.Port; //The hostname can be ip address of server or machine name myInfo.HostName = allInfo.Server; } myConnString = DbConnectionString.Oracle.ConnectionStringWithoutClient(myInfo.HostName, myInfo.Port.ToString(), myInfo.SID, myInfo.Username, myInfo.Password); //Here just use the dll in odp.net //but we need confirm the right version of current client baseConn = new OracleConnection(myConnString); baseConn.Open(); invalidator = new Invalidation.InvalidationBase(); CurDatabase = myInfo.SID; CurPwd = myInfo.Password; } catch (Exception e) { throw e; } }
public void ConnectCmd_Execute(object sender, ExecutedRoutedEventArgs e) { LoginInfo_Oracle info = new LoginInfo_Oracle() { SID = txtServerName.Text, Username = txtUsername.Text, Password = passwordBox1.Password, HostName = txtHostName.Text, Port = int.Parse(txtPort.Text), }; try { App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.Oracle).X_Handler; App.MainEngineer.Open(info); if (App.MainEngineer.IsOpened) { #region Save to Opened History Info OracleObjects oracleItem = new OracleObjects(); oracleItem.HostName = info.HostName; oracleItem.Username = info.Username; oracleItem.SID = info.SID; if (!SerializeClass.DatabaseHistoryInfo.OracleHistory.IsContainSubValue(oracleItem.HostName)) { HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo; oldObject.OracleHistory.Add(oracleItem); SerializeClass.DatabaseHistoryInfo = oldObject; } #endregion App.MainEngineer.CurPwd = passwordBox1.Password; RibbionIDE ide = new RibbionIDE(); ide.Title = info.SID; ide.ShowDialog(); } } catch (Exception ee) { //ee._获取我的异常详细信息().Show(); App.ResetMainEngineer(); ee.HandleMyException(); } }