public static OracleConnection RetornaConexao(OracleCon acesso, bool mensagem) { OracleConnection conexao = new OracleConnection(); try { var conString = "Data Source=" + "(DESCRIPTION=(ADDRESS=(PROTOCOL=" + Cripto.Decrypt(acesso.Protocol) + ")" + "(HOST=" + Cripto.Decrypt(acesso.Host) + ")(PORT=" + Cripto.Decrypt(acesso.Port) + "))" + "(CONNECT_DATA=(SERVICE_NAME=" + Cripto.Decrypt(acesso.ServiceName) + ")));" + "User Id = " + Cripto.Decrypt(acesso.User) + "; Password = "******"; "; conexao.ConnectionString = conString; conexao.Open(); //var retorno = conexao.State.ToString() == "Open" ? conexao : null; } catch (Exception e) { XtraMessageBox.Show("Não foi possível abrir a conexão com o Banco de Dados " + Cripto.Decrypt(acesso.SystemName) + "! \n" + e.Message, "Sem conexão", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (mensagem && conexao.State.ToString() == "Open") { XtraMessageBox.Show("Conexão com o Banco de Dados " + Cripto.Decrypt(acesso.SystemName) + " efetuada com sucesso! \n", "Conexão", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(conexao); }
private void M_DealTitle(string title, string id, WosSearcher tmpSearcher) { bool b = true; start: try { WosData wosData = tmpSearcher.SearchNoInit(title, randomTime); if (wosData != null) { double matchTmp = 0; string[] rdatas = wosData.getDataArray(); double.TryParse(rdatas[rdatas.Length - 1], out matchTmp); if (matchTmp >= matchOk) { try { DBConnector.OracleCon.SaveWosDataLong(wosData); } catch (Exception e) { OracleCon.SaveMatchDataError(title, id, e.Message); } try { DBConnector.OracleCon.SaveMatchData(wosData, title, id); } catch (Exception e) { OracleCon.SaveMatchDataError(title, id, e.Message); } } else { OracleCon.SaveMatchDataError(title, id, "no data match"); } } b = true; } catch (Exception e) { if (e.Message == "wos数据下载超时") { b = false; Logs.WriteLog(string.Format("{0}\r\n{1}\r\n{2}", title, e.Message, "请检查网络连接是否正常")); goto start; } b = true; OracleCon.SaveMatchDataError(title, id, e.Message); } finally { if (b) { tmpSearcher.isbusy = false; } } SetTitleIndex(id); }
/// <summary> /// 检索数据并保存到oracle库中 /// </summary> /// <param name="start"></param> /// <param name="end"></param> public void SearchDataToOracle(int start, int end) { DataTable dt_articles = OracleCon.SelectArticles(start, end); if (dt_articles.Rows.Count < 1) { SetTitleIndex(end.ToString()); return; } try { foreach (DataRow row in dt_articles.Rows) { string title = row["CITATION_TITLE"].ToString(); string id = row["INTERNAL_ID"].ToString(); int.TryParse(id, out nowIndex); if (string.IsNullOrEmpty(title)) { SetTitleIndex(id); OracleCon.SaveMatchDataError(title, id, "title is null"); continue; } if (dbSearcher.SearchOracle(title, id)) { SetTitleIndex(id); continue; } bool GetSearcher = false; WosSearcher tmpSearcher = null; while (!GetSearcher) { for (int i = 0; i < searchers.Count; i++) { if (!searchers[i].isbusy) { tmpSearcher = searchers[i]; GetSearcher = true; tmpSearcher.isbusy = true; break; } } } new DealTitle(M_DealTitle).BeginInvoke(title, id, tmpSearcher, null, null); } } catch (Exception e) { Logs.WriteLog(string.Format("{0}\r\n{1}", "SearchDataToOracle:" + nowIndex, e.Message)); return; } }
// GET: SteelGage public ActionResult SheetGage() { var ora = new OracleCon(); ViewBag.Test = ora.OracleQury("Select datetime from test where datetime IS NOT null", 1); ora.OracleCloseCon(); //oracleCon:OracleDataReader=Convert.ToDateTime() //var dt = Convert.ToDateTime(dr.GetDateTime(0)); return(View()); }
private void GetDados() { using (var contexto = new ContextSqlite()) { var systemName = "PIMS"; pims_Acesso = contexto.OracleCon.Find(Cripto.Encrypt(systemName)); edtServiceNamePims.Text = Cripto.Decrypt(pims_Acesso.ServiceName); edtHostPims.Text = Cripto.Decrypt(pims_Acesso.Host); edtPortPims.Text = Cripto.Decrypt(pims_Acesso.Port); edtUserPims.Text = Cripto.Decrypt(pims_Acesso.User); edtPasswordPims.Text = Cripto.Decrypt(pims_Acesso.Password); cboProtocolPims.Text = Cripto.Decrypt(pims_Acesso.Protocol); systemName = "SISMA"; sisma_Acesso = contexto.OracleCon.Find(Cripto.Encrypt(systemName)); edtServiceNameSisma.Text = Cripto.Decrypt(sisma_Acesso.ServiceName); edtHostSisma.Text = Cripto.Decrypt(sisma_Acesso.Host); edtPortSisma.Text = Cripto.Decrypt(sisma_Acesso.Port); edtUserSisma.Text = Cripto.Decrypt(sisma_Acesso.User); edtPasswordSisma.Text = Cripto.Decrypt(sisma_Acesso.Password); cboProtocolSisma.Text = Cripto.Decrypt(sisma_Acesso.Protocol); systemName = "MEGA"; mega_Acesso = contexto.OracleCon.Find(Cripto.Encrypt(systemName)); edtServiceNameMega.Text = Cripto.Decrypt(mega_Acesso.ServiceName); edtHostMega.Text = Cripto.Decrypt(mega_Acesso.Host); edtPortMega.Text = Cripto.Decrypt(mega_Acesso.Port); edtUserMega.Text = Cripto.Decrypt(mega_Acesso.User); edtPasswordMega.Text = Cripto.Decrypt(mega_Acesso.Password); cboProtocolMega.Text = Cripto.Decrypt(mega_Acesso.Protocol); systemName = "SENIOR"; senior_Acesso = contexto.OracleCon.Find(Cripto.Encrypt(systemName)); edtServiceNameSenior.Text = Cripto.Decrypt(senior_Acesso.ServiceName); edtHostSenior.Text = Cripto.Decrypt(senior_Acesso.Host); edtPortSenior.Text = Cripto.Decrypt(senior_Acesso.Port); edtUserSenior.Text = Cripto.Decrypt(senior_Acesso.User); edtPasswordSenior.Text = Cripto.Decrypt(senior_Acesso.Password); cboProtocolSenior.Text = Cripto.Decrypt(senior_Acesso.Protocol); } }