Esempio n. 1
0
        public static void Start(string[] args)
        {
            NotifyHelper.Started();

            // Check status at configured time interval.
            _Timer           = new Timer(Properties.Settings.Default.pollIntervalSeconds * 1000);
            _Timer.AutoReset = true;
            _Timer.Elapsed  += new ElapsedEventHandler(timer_Elapsed);
            _Timer.Enabled   = true;
            _Timer.Start();
        }
Esempio n. 2
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.");
                }
            }
        }
Esempio n. 3
0
        public static void Pause()
        {
            if (_Timer != null)
            {
                if (_Timer.Enabled)
                {
                    _Timer.Enabled = false;
                }
                _Timer.Stop();
            }

            SshHelper.CloseConnection();
            NotifyHelper.SshClosed();
        }
Esempio n. 4
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();
                }
            }
        }
Esempio n. 5
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();
            }
        }