Beispiel #1
0
        // Methods
        public static void CheckStatus()
        {
            bool isOpen = SshHelper.IsOpen;

            if (!isOpen)
            {
                if (IntervalChecks > 0)
                {
                    if (ReopenTries >= ReopenLimit)
                    {
                        if (_service != null)
                        {
                            _service.Stop();
                        }
                        else
                        {
                            Stop();
                        }
                    }
                    else
                    {
                        ReopenTries++;
                        NotifyHelper.SshClosedReopening(ReopenTries, ReopenLimit);
                    }
                }
                try
                {
                    isOpen      = SshHelper.OpenConnection();
                    ReopenTries = 0;
                    NotifyHelper.SshOpened();
                }
                catch
                {
                }
            }

            if (isOpen)
            {
                if (!RunAsService)
                {
                    Console.WriteLine("SSH connection open!");
                }
            }
            else
            {
                if (!RunAsService)
                {
                    Console.WriteLine("SSH failed to open.");
                }
            }
        }
Beispiel #2
0
        public static void Pause()
        {
            if (_Timer != null)
            {
                if (_Timer.Enabled)
                {
                    _Timer.Enabled = false;
                }
                _Timer.Stop();
            }

            SshHelper.CloseConnection();
            NotifyHelper.SshClosed();
        }
Beispiel #3
0
        public static void Stop()
        {
            try
            {
                if (_Timer != null)
                {
                    if (_Timer.Enabled)
                    {
                        _Timer.Enabled = false;
                    }
                    _Timer.Stop();
                    _Timer.Dispose();
                }

                if (!RunAsService)
                {
                    Console.WriteLine("Closing SSH connection...");
                }

                SshHelper.CloseConnection();

                if (!RunAsService)
                {
                    Console.WriteLine("SSH connection closed!");
                }

                NotifyHelper.Stopped();
            }
            catch (Exception ex)
            {
                if (!RunAsService)
                {
                    Console.WriteLine(ex);
                }
            }
            finally
            {
                if (!RunAsService)
                {
                    Console.ReadLine();
                }
            }
        }
Beispiel #4
0
        public static void Continue()
        {
            if (_Timer == null)
            {
                _Timer           = new Timer(Properties.Settings.Default.pollIntervalSeconds * 1000);
                _Timer.AutoReset = true;
                _Timer.Elapsed  += new ElapsedEventHandler(timer_Elapsed);
            }

            if (!_Timer.Enabled)
            {
                _Timer.Enabled = false;
            }
            _Timer.Start();

            if (SshHelper.OpenConnection())
            {
                NotifyHelper.SshOpened();
            }
        }