Exemplo n.º 1
0
        public bool Connect()
        {
            frmConnect frm = new frmConnect();

            if (essServer != null)
            {
                frm.essServer = this.essServer;
            }
            if (essUser != null)
            {
                frm.essUser = this.essUser;
            }
            if (essPW != null)
            {
                frm.essPW = this.essPW;
            }
            if (essApp != null)
            {
                frm.essApp = this.essApp;
            }
            if (essDB != null)
            {
                frm.essDB = this.essDB;
            }
            if (apsProviderURL != null)
            {
                frm.apsProviderURL = this.apsProviderURL.Substring(apsProviderURL.IndexOf("//") + 2, apsProviderURL.LastIndexOf(":") - apsProviderURL.IndexOf("//") - 2);
            }
            frm.ShowDialog();
            if (frm.connected)
            {
                this.cv             = frm.cv;
                this.ess            = frm.ess;
                this.svr            = frm.svr;
                this.essServer      = frm.essServer;
                this.essUser        = frm.essUser;
                this.essPW          = frm.essPW;
                this.apsProviderURL = frm.apsProviderURL;
                this.essApp         = frm.essApp;
                this.essDB          = frm.essDB;
                frm = null;
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     try
     {
         essApp = ((String)((String[])(cboAppDB.SelectedItem.ToString().Split('|')))[0]).Trim();
         essDB  = ((String)((String[])(cboAppDB.SelectedItem.ToString().Split('|')))[1]).Trim();
         if (cv != null)
         {
             cv.close();
         }
         cv        = svr.getApplication(essApp).getCube(essDB).openCubeView("JDH_CubeView");
         connected = true;
         this.Dispose();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error connecting: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 3
0
        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;
        }