private void btnList_Click(object sender, EventArgs e) { try { essUser = txtUser.Text.Trim(); essPW = txtPW.Text.Trim(); apsProviderURL = txtAPS.Text.Trim(); if (!(apsProviderURL.Contains("http://") || apsProviderURL.Contains("https://"))) { apsProviderURL = "http://" + txtAPS.Text.Trim(); } if (!apsProviderURL.Substring(apsProviderURL.IndexOf("//")).Contains(":")) { apsProviderURL += ":19000"; } if (!apsProviderURL.Contains("/aps/JAPI")) { apsProviderURL += "/aps/JAPI"; } essServer = txtEssServer.Text.Trim(); ess = IEssbase.Home.create(JAPI_VERSION); svr = ess.signOn(essUser, essPW, false, null, apsProviderURL, essServer); PopulateAppDBList(); lblAppDB.Enabled = true; cboAppDB.Enabled = true; btnConnect.Enabled = true; } catch (Exception ex) { MessageBox.Show(String.Format("Unable to connect: {0}\nURL tried: {1}", ex.Message, apsProviderURL), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadConfig(String filename) { StreamReader cfg = null; EncryptionWrapper dec = null; try { dec = new EncryptionWrapper(); dec.InitializeCipher(key, IV); cfg = new StreamReader(filename); String line = null; String[] values = null; while ((line = cfg.ReadLine()) != null) { values = line.Split('|'); switch (values[0]) { case "essServer": this.essServer = values[1]; break; case "apsServer": this.apsProviderURL = "http://" + values[1] + ":13080/aps/JAPI"; break; case "essUser": this.essUser = values[1]; break; case "essPW": this.essPW = System.Text.Encoding.ASCII.GetString(dec.Decrypt(System.Convert.FromBase64String(values[1]))); break; case "essApp": this.essApp = values[1]; break; case "essDB": this.essDB = values[1]; break; case "query": this.m_qry = values[1] + cfg.ReadToEnd(); break; } } } catch (Exception ex) { MessageBox.Show("Error loading config file: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (cfg != null) { cfg.Close(); } dec = null; } try { if (ess == null || !ess.isSignedOn()) { ess = IEssbase.Home.create(JAPI_VERSION); } if (svr == null || !svr.isConnected()) { svr = ess.signOn(essUser, essPW, false, null, apsProviderURL, essServer); } if (cv != null) { cv.close(); } cv = svr.getApplication(essApp).getCube(essDB).openCubeView("JDH_CubeView"); frmState = ConnectionState.Connected; scintQry.Text = m_qry; UpdateFormState(); } catch (Exception ex) { MessageBox.Show("Error connecting with configuration provided: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; }