Example #1
0
        private void ConfigureItem_Click(object sender, EventArgs e)
        {
            var previous = ClientState;

            ClientState = EClientState.Changing;
            using (var setup = new SetupForm(_client.ClientConfig))
            {
                if (setup.ShowDialog() == DialogResult.OK)
                {
                    ClientState = previous;
                    WaitThenStopClientIfNeeded();
                    try
                    {
                        _client.ClientConfig.SaveToFile(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + _client.ConfigFile);
                        _client.UnLoadConfiguration();
                        _client.LoadConfiguration();
                        StartItem_Click(sender, e);
                    }
                    catch (Exception ex)
                    {
                        _client.Log(ex.Message, ESeverity.ERROR);
                        _client.Log(ex.ToString(), ESeverity.DEBUG);
                    }
                }
                else
                {
                    ClientState = previous;
                }
            }
        }
Example #2
0
 public Client(IPEndPoint _remoteEndPoint, DateTime _connectedAt, EClientState _clientState)
 {
     remoteEndPoint = _remoteEndPoint;
     connectedAt    = _connectedAt;
     clientState    = _clientState;
     commandIssued  = String.Empty;
 }
Example #3
0
 public CClientInfo(Guid clientInfoId, string computerName, string ipAddress, DateTime lastEventDateTime, EClientState state)
 {
     ClientInfoId         = clientInfoId;
     ComputerName         = computerName;
     IpAddress            = ipAddress;
     LastEventDateTimeUtc = lastEventDateTime;
     State = state;
 }
Example #4
0
 public ClientRow(IPEndPoint ipPoint, long time, EClientState state = EClientState.Idle)
 {
     Index         = 0;
     IpPoint       = ipPoint;
     ScanTime      = time;
     State         = state;
     ConnectedTime = DateTime.Now;
     BeginTime     = 0;
 }
Example #5
0
        public Client(IPEndPoint _remoteEndPoint, DateTime _connectedAt, EClientState _clientState)
        {
            remoteEndPoint = _remoteEndPoint;
            connectedAt = _connectedAt;
            clientState = _clientState;
            commandIssued = String.Empty;

            BirthMark = LiveCache.GetUniqueIdentifier(String.Format(cacheKeyFormat, remoteEndPoint.Port));
            Birthdate = DateTime.Now;
        }
Example #6
0
        private void AdminItem_Click(object sender, EventArgs e)
        {
            var previous = ClientState;

            ClientState = EClientState.Changing;

            using (var admin = new AdminForm(_client.Tunnel, _client.Sid))
                admin.ShowDialog();

            ClientState = previous;
        }
Example #7
0
        public void SetClientState(EClientState state)
        {
            lock (client.Udp)
            {
                packet.Clear();
                packet.Command = EClientCommand.SetClientState;
                packet.IArg1   = (int)state;

                client.Udp.Send(packet.Bytes, packet.Bytes.Length, client.IpPoint);
                Log(ESenderLogItem.Send, "Send a Command({0}) - IArg1 : {1}", packet.Command.ToString(), packet.IArg1);
            }

            client.Listener.WaitForAck();
        }
Example #8
0
 private void StopClient(object state)
 {
     try
     {
         _client.StopClient();
         ClientState = EClientState.Stopped;
         NotifyContextMenu.Invoke(new UpdateNotifyIconDelegate(UpdateNotifyIcon), Strings.MAINFORM_CLIENT_STOPPED, false);
     }
     catch (Exception e)
     {
         _client.Log(e.Message, ESeverity.ERROR);
         _client.Log(e.ToString(), ESeverity.DEBUG);
     }
 }
Example #9
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Arrêt effectif du client
 /// </summary>
 /// <param name="state">les parametres</param>
 /// -----------------------------------------------------------------------------
 private void StopClient(Object state)
 {
     try
     {
         _client.StopClient();
         ClientState = EClientState.Stopped;
         // On utilise un Invoke car le thread courant est différent du thread créateur du contrôle (modèle STA)
         NotifyContextMenu.Invoke(new UpdateNotifyIconDelegate(UpdateNotifyIcon), new object[] { Strings.MAINFORM_CLIENT_STOPPED, false });
     }
     catch (Exception e)
     {
         _client.Log(e.Message, ESeverity.ERROR);
         _client.Log(e.ToString(), ESeverity.DEBUG);
     }
 }
Example #10
0
 private void StartClient(Object state)
 {
     try
     {
         _client.StartClient();
         ClientState = EClientState.Started;
         NotifyContextMenu.Invoke(new UpdateNotifyIconDelegate(UpdateNotifyIcon), Strings.MAINFORM_CLIENT_STARTED, true);
     }
     catch (Exception e)
     {
         _client.Log(e.Message, ESeverity.ERROR);
         _client.Log(e.ToString(), ESeverity.DEBUG);
         StopClient(null);
     }
     NotifyContextMenu_Opened(this, EventArgs.Empty);
 }
Example #11
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Configuration du client
        /// </summary>
        /// <param name="sender">l'appelant</param>
        /// <param name="e">les parametres</param>
        /// -----------------------------------------------------------------------------
        private void ConfigureItem_Click(object sender, EventArgs e)
        {
            var previous = ClientState;

            ClientState = EClientState.Changing;
            using (var setup = new SetupForm(_client.ClientConfig))
            {
                if (setup.ShowDialog() == DialogResult.OK)
                {
                    /*
                     * Petite subtilite: a ce moment la configuration m_client contient de faux loggers
                     * utiles uniquement pour sauvegarder le parametrage dans le fichier de configuration.
                     *
                     * Par contre les vrais instances des loggers sont conserves dans l'ancetre BdtClient.
                     * UnLoadConfiguration va fermer ces loggers. LoadConfiguration va recharger le fichier
                     * de configuration prealablement sauvegarde pour remettre a jour les instances ->
                     * rechargement de la section logs uniquement
                     *
                     */
                    ClientState = previous;
                    WaitThenStopClientIfNeeded();
                    try
                    {
                        _client.ClientConfig.SaveToFile(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + _client.ConfigFile);
                        _client.UnLoadConfiguration();
                        _client.LoadConfiguration();
                        StartItem_Click(sender, e);
                    }
                    catch (Exception ex)
                    {
                        _client.Log(ex.Message, ESeverity.ERROR);
                        _client.Log(ex.ToString(), ESeverity.DEBUG);
                    }
                }
                else
                {
                    ClientState = previous;
                }
            }
        }
Example #12
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Configuration du client
 /// </summary>
 /// <param name="sender">l'appelant</param>
 /// <param name="e">les parametres</param>
 /// -----------------------------------------------------------------------------
 private void ConfigureItem_Click(object sender, EventArgs e)
 {
     var previous = ClientState;
     ClientState = EClientState.Changing;
     using (var setup = new SetupForm(_client.ClientConfig))
     {
         if (setup.ShowDialog() == DialogResult.OK)
         {
             /*
              * Petite subtilite: a ce moment la configuration m_client contient de faux loggers
              * utiles uniquement pour sauvegarder le parametrage dans le fichier de configuration.
              * 
              * Par contre les vrais instances des loggers sont conserves dans l'ancetre BdtClient.
              * UnLoadConfiguration va fermer ces loggers. LoadConfiguration va recharger le fichier
              * de configuration prealablement sauvegarde pour remettre a jour les instances ->
              * rechargement de la section logs uniquement
              * 
              */
             ClientState = previous;
             WaitThenStopClientIfNeeded();
             try
             {
                 _client.ClientConfig.SaveToFile(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + _client.ConfigFile);
                 _client.UnLoadConfiguration();
                 _client.LoadConfiguration();
                 StartItem_Click(sender, e);
             }
             catch (Exception ex)
             {
                 _client.Log(ex.Message, ESeverity.ERROR);
                 _client.Log(ex.ToString(), ESeverity.DEBUG);
             }
         }
         else
         {
             ClientState = previous;
         }
     }
 }
        private void SetClientState(IPEndPoint ipPoint)
        {
            lock (server.Clients)
            {
                if (server.Clients.ContainsKey(ipPoint.ToString()) == false)
                {
                    logger.Log((int)EListenerLogItem.Note,
                               "Can't find a client({0}) in Client Dictionary",
                               ipPoint.ToString());
                    return;
                }

                ClientRow    client = server.Clients[ipPoint.ToString()];
                EClientState state  = (EClientState)packet.IArg1;
                client.State = state;

                logger.Log((int)EListenerLogItem.Note,
                           "Changed client({0}) to {1}",
                           ipPoint.ToString(), state.ToString());
            }

            OnChangedClients(this, null);
        }
Example #14
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Administration du serveur
        /// </summary>
        /// <param name="sender">l'appelant</param>
        /// <param name="e">les parametres</param>
        /// -----------------------------------------------------------------------------
        private void AdminItem_Click(object sender, EventArgs e)
        {
            var previous = ClientState;
            ClientState = EClientState.Changing;
	        
			using (var admin = new AdminForm(_client.Tunnel, _client.Sid))
		        admin.ShowDialog();
	        
			ClientState = previous;
        }
Example #15
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Arrêt du client
 /// </summary>
 /// <param name="sender">l'appelant</param>
 /// <param name="e">les parametres</param>
 /// -----------------------------------------------------------------------------
 private void StopItem_Click(object sender, EventArgs e)
 {
     ClientState = EClientState.Changing;
     UpdateNotifyIcon(Strings.MAINFORM_CLIENT_STOPPING, false);
     System.Threading.ThreadPool.QueueUserWorkItem(StopClient);
 }
Example #16
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Arrêt effectif du client
 /// </summary>
 /// <param name="state">les parametres</param>
 /// -----------------------------------------------------------------------------
 private void StopClient(Object state)
 {
     try
     {
         _client.StopClient();
         ClientState = EClientState.Stopped;
         // On utilise un Invoke car le thread courant est différent du thread créateur du contrôle (modèle STA)
         NotifyContextMenu.Invoke(new UpdateNotifyIconDelegate(UpdateNotifyIcon), new object[] { Strings.MAINFORM_CLIENT_STOPPED, false });
     }
     catch (Exception e)
     {
         _client.Log(e.Message, ESeverity.ERROR);
         _client.Log(e.ToString(), ESeverity.DEBUG);
     }
 }
Example #17
0
 private void StopItem_Click(object sender, EventArgs e)
 {
     ClientState = EClientState.Changing;
     UpdateNotifyIcon(Strings.MAINFORM_CLIENT_STOPPING, false);
     System.Threading.ThreadPool.QueueUserWorkItem(StopClient);
 }
Example #18
0
 public Client(IPEndPoint _remoteEndPoint, DateTime _connectedAt, EClientState _clientState)
 {
     remoteEndPoint = _remoteEndPoint;
     connectedAt    = _connectedAt;
     clientState    = _clientState;
 }
Example #19
0
 public TelnetClient(IPEndPoint _remoteEndPoint, DateTime _connectedAt, EClientState _clientState)
 {
     this.remoteEndPoint = _remoteEndPoint;
     this.connectedAt    = _connectedAt;
     this.clientState    = _clientState;
 }