Ejemplo n.º 1
0
        private void Logout()
        {
            if (_serverStatus)
                if (_clientService != null && _clientService.ServiceProxy != null )
                    try
                    {
                        _clientService.ServiceProxy.Logout("e", _client.UserName);
                    }
                    catch
                    {
                    }

            if (_logonThread != null) _logonThread.Abort();

            Invoke((Action)delegate
            {
                ClearAllQueryUi();
                ui_ExportTab_metroTabItem.Visible = false;
                metroShell1.SelectedTab = ui_HomeTab_metroTabItem;
                DataExportClientDataManager.CloseConnectionToDb();
                ProfilesManager.ClearAll();
                _client = null;
                _startControl.Dispose();
                _startControl = new StartControl(_commands);
                Controls.Add(_startControl);
                _startControl.BringToFront();
                _startControl.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Right;
                UpdateControlsSizeAndLocation();
                _startControl.ui_textBox_ip.Text = Settings.Default.connectionHost;
                _pingTimer.Enabled = true;
            });
        }
Ejemplo n.º 2
0
        private void LoginToServer(string username, string password, string host)
        {
            _pingTimer.Enabled = false;
            _client = new DataClientClass(username);
            _logClient = new DataNetLogService();
            _logClientService = ScsServiceClientBuilder.CreateClient<IDataNetLogService>(new ScsTcpEndPoint(host, 443), _logClient);
            _clientService = ScsServiceClientBuilder.CreateClient<IDataAdminService>(new ScsTcpEndPoint(host, 443), _client);
            _clientService.Connected += ScsClient_Connected;
            try
            {
                _clientService.Connect();
                _logClientService.Connect();

                _client.login += LoggedIn;
                _client.block += BlockedByAdmin;
                _client.loginFailed += LoginFailed;
                _client.changePrivilages += ChangedPrivileges;
                _client.logout += DeletedClient;
                _client.symbolListChanged += RefreshSymbols;
                //_client.groupChanged += RefreshGroups;
                _client.logoutServer += ServerStatusChanged;
                _clientService.Disconnected += OnServerCrashed;
                var logmsg = new DataAdminMessageFactory.LogMessage
                    {
                        Symbol = username,
                        LogType = DataAdminMessageFactory.LogMessage.Log.Login,
                        Group = ""
                    };

                _logClientService.ServiceProxy.SendSimpleLog(logmsg);
                Settings.Default.connectionHost = _startControl.ui_textBox_ip.Text;

            }
            catch (Exception)
            {
                if (_startControl!=null)
                _startControl.Invoke((Action)(() =>
                                                  {
                                                      ToastNotification.Show(_startControl, "Can't connect. IP is incorrect");
                                                      _startControl.ui_buttonX_logon.Enabled = true;
                                                  }
                    ));

                return;
            }
            var loginMsg = new DataAdminMessageFactory.LoginMessage(username, password, 'e');
            try
            {
                _clientService.ServiceProxy.Login(loginMsg);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }