Exemplo n.º 1
0
        //Déconnecter
        private void Disconnect_button_Click(object sender, EventArgs e)
        {
            bool retry = true;

            while (retry)
            {
                try
                {
                    ConnectToIED.Close();
                    Disconnect_button.Enabled = false;
                    Connect_button.Enabled    = true;
                    Exit_button.Enabled       = true;
                    retry           = false;
                    toolStatus.Text = "Disconnected";
                    IEDConnected    = false;
                }
                catch (IedConnectionException ex)
                {
                    IEDConnected    = true;
                    toolStatus.Text = "Failed to Disconnect";
                    if (MessageBox.Show(ex.Message + "for the following reason" + ex.GetIedClientError(), "Erreur", MessageBoxButtons.RetryCancel) == DialogResult.Cancel)
                    {
                        retry = false;
                    }
                    else
                    {
                        retry = true;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public bool StopConnection()
 {
     try
     {
         _connection.Close();
         //_connection.Abort();
         _runConnect = false;
         //_connection.Dispose();
         return(true);
     }
     catch (Exception e)
     {
         Log.Write(e, Log.Code.ERROR);
         return(false);
     }
 }