Exemplo n.º 1
0
        private void Connect(object obj)
        {
            ConnectionSettingsContainer settings = obj as ConnectionSettingsContainer;

            if (settings != null)
            {
                AuthenticationType authentication = AuthenticationType.Windows;
                if (settings.IsSimple)
                {
                    authentication = AuthenticationType.SQLServer;
                }
                Invoke(new eventInvoker(OnConnecting));
                string message;
                if (ConnectionManager.Connect(settings.ServerName, settings.Username,
                                              settings.Password, authentication, out message))
                {
                    Invoke(new eventInvoker(OnConnected));
                }
                else
                {
                    Invoke(new failureEventInvoker(OnFailed), new object[1] {
                        message
                    });
                }
            }
            else
            {
                Invoke(new failureEventInvoker(OnFailed), new object[1] {
                    "Wrong connection parameters"
                });
            }
        }
Exemplo n.º 2
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            ConnectionSettingsContainer settings =
                new ConnectionSettingsContainer(comboBoxServerName.Text, textBoxLogin.Text, textBoxPassword.Text,
                                                isSimple);

            connectionThread = new Thread(Connect);
            connectionThread.Start(settings);
        }
Exemplo n.º 3
0
        private void StartConnection()
        {
            ConnectionSettingsContainer settings =
                new ConnectionSettingsContainer(comboBoxServerName.Text, textBoxLogin.Text, textBoxPassword.Text,
                                                isSimple);

            connectionThread = new Thread(Connect);
            connectionThread.Start(settings);
        }
Exemplo n.º 4
0
        private void StartConnection()
        {
            var serverName = comboBoxServerName.Text;

            Init(_settings.ConnectionStrings[serverName]);

            var settings = new ConnectionSettingsContainer(_settings.ConnectionStrings[serverName].Connection, textBoxLogin.Text, textBoxPassword.Text, _isSimple);

            ConnectionAction(settings, serverName);
        }
Exemplo n.º 5
0
        private void StartConnection()
        {
            string serverName;

#if DemoDebug
            serverName = "91.213.233.139,1433\\MSSQLSERVER@CASDBTest";
#else
            serverName = comboBoxServerName.Text;
#endif

            var settings = new ConnectionSettingsContainer(_settings.ConnectionStrings[serverName], textBoxLogin.Text, textBoxPassword.Text, _isSimple);
            Connect(settings);
            //connectionThread = new Thread(Connect);
            //connectionThread.Start(settings);
        }
Exemplo n.º 6
0
        private void ConnectionAction(ConnectionSettingsContainer settings, string serverName)
        {
            if (settings != null)
            {
                OnConnecting();

                try
                {
                    if (_isCAA)
                    {
                        GlobalObjects.CaaEnvironment.Connect(settings.ServerName, settings.Username, settings.Password, "");
                    }
                    else
                    {
                        GlobalObjects.CasEnvironment.Connect(settings.ServerName, settings.Username, settings.Password, "");
                    }


                    SaveJsonSetting(settings.Username, serverName);
                }
                catch (ConnectionFailureException ex)
                {
                    if (ex.InnerException != null)
                    {
                        var sqlException = ex.InnerException as SqlException;
                        if (sqlException != null)
                        {
                            MessageBox.Show(sqlException.Message, "Failed to connect server", MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show("Server was not found or is not available", "Failed to connect server",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Server was not found or is not available", "Failed to connect server",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Failed to connect server", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    SetEnabled(true, _isSimple);
                    _connectionStatus = ConnectionState.Closed;
                    buttonExit.Text   = "Exit";
                    return;
                }



                //нажатие клавиши Enter
                buttonExit.Enabled = false;

                _loadForm.Show();
                backgroundWorker.RunWorkerAsync();
            }
            else
            {
                OnFailed("Wrong connection parameters");
                //Invoke(new failureEventInvoker(OnFailed), new object[] { "Wrong connection parameters" });
            }
        }
Exemplo n.º 7
0
        private void ConnectionAction(Object obj)
        {
            ConnectionSettingsContainer settings = obj as ConnectionSettingsContainer;

            if (settings != null)
            {
                AuthenticationType authentication = AuthenticationType.Windows;
                if (settings.IsSimple)
                {
                    authentication = AuthenticationType.SqlServer;
                }
                OnConnecting();
                string message;
                //if (settings.ServerName.Split('@').Length >= 2)
                //{
                //    string serverName = settings.ServerName.Split('@')[0];
                //    string baseName = settings.ServerName.Split('@')[1];

                try
                {
                    //GlobalObjects.CasEnvironment.Connect(serverName, settings.Username, settings.Password, baseName);
                    GlobalObjects.CasEnvironment.Connect(settings.ServerName, settings.Username, settings.Password, "");
                    SaveJsonSetting(settings.Username);
                }
                catch (ConnectionFailureException ex)
                {
                    if (ex.InnerException != null)
                    {
                        SqlException sqlException = ex.InnerException as SqlException;
                        if (sqlException != null)
                        {
                            MessageBox.Show(sqlException.Message, "Failed to connect server", MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show("Server was not found or is not available", "Failed to connect server",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Server was not found or is not available", "Failed to connect server",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    return;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Failed to connect server", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }



                //нажатие клавиши Enter
                buttonExit.Enabled = false;

                _loadForm.Show();
                backgroundWorker.RunWorkerAsync();
            }
            else
            {
                OnFailed("Wrong connection parameters");
                //Invoke(new failureEventInvoker(OnFailed), new object[] { "Wrong connection parameters" });
            }
        }