/// <summary>
        /// Forderrt zum Einschläfern des Dienstrechners auf.
        /// </summary>
        /// <param name="controller">Der zu verwendende Dienstrechner.</param>
        internal void TryHibernate(ProcessingItem controller)
        {
            // Fire here after close
            m_forHibernate = controller;

            // Close
            Close();
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="oldState"></param>
        /// <param name="newState"></param>
        /// <param name="mustHibernate"></param>
        /// <param name="pendingExtensions"></param>
        /// <returns>Gesetzt, wenn der Dialog geöffnet wurde und inaktiv, wenn er geschlossen wurde. <i>null</i> zeigt an,
        /// dass die Kontrolle über den Schlafzustand nicht hier erfolgt.</returns>
        private bool? GetHibernationDialogState( ProcessingItem controller, TrayColors oldState, TrayColors newState, bool mustHibernate, bool pendingExtensions )
        {
            // Only if watching local server
            if (!frameLocal.Enabled)
                return null;

            // Only if this is the local server (do not hide hibernation if active)
            var view = controller.View;
            if (!view.Settings.IsLocal)
                return null;

            // Can not hibernate
            if (m_Settings.HibernationDelay < 1)
            {
                // Dialog should not be shown
                HideHibernation();

                // Not responsible
                return null;
            }

            // See if hibernation is temporarily disabled
            if (m_BlockHibernate < DateTime.MaxValue)
                if (DateTime.UtcNow <= m_BlockHibernate)
                    return false;

            // Only if server is now idle
            if (TrayColors.Standard != newState)
                if (TrayColors.Green != newState)
                    return false;

            // See if hibernation dialog has run through
            if (null != m_Hibernation)
                if (m_Hibernation.MustHibernateNow)
                {
                    // See if there are pending extensions
                    if (!pendingExtensions)
                        m_Hibernation.TryHibernate( controller );

                    // No change required
                    return null;
                }
                else if (m_Hibernation.Visible)
                    return null;

            // Only if we come from recording
            if (!mustHibernate)
                return false;

            // Release
            if (null != m_Hibernation)
            {
                // Shutdown
                m_Hibernation.Dispose();

                // Forget
                m_Hibernation = null;
            }

            // Create dialog
            m_Hibernation = new HibernateDialog();

            // Initialize and show up
            m_Hibernation.Owner = this;
            m_Hibernation.Start( m_Settings.HibernationDelay );
            m_Hibernation.Show();

            // Hibernation dialog is running
            return true;
        }
Пример #3
0
        private bool GetHibernationDialogPoppedUp( ProcessingItem controller, TrayColors oldState, TrayColors newState, bool mustHibernate, bool pendingExtensions )
        {
            // Do the check
            bool? dialogState = GetHibernationDialogState( controller, oldState, newState, mustHibernate, pendingExtensions );

            // Just don't mess around with the hibernation dialog
            if (!dialogState.HasValue)
                return false;

            // Dialog should not be shown
            if (!dialogState.Value)
                HideHibernation();

            // Actually we feel responsible but optimize a bit to avoid too many callbacks
            return mustHibernate;
        }
Пример #4
0
        internal bool ProcessStateAndCheckHibernation( ProcessingItem controller, TrayColors state, bool mustHibernate, bool pendingExtensions )
        {
            // Load view
            var view = controller.View;

            // Report
            Log( "{0}:{1} report received for {2}", view.Settings.ServerName, view.Settings.ServerPort, state );

            // May be (normally) on the wrong thread
            if (InvokeRequired)
            {
                // Forward
                return (bool)Invoke( new ReportPattern( ProcessStateAndCheckHibernation ), controller, state, mustHibernate, pendingExtensions );
            }

            // Get the previous state
            TrayColors oldState = TrayColors.Unknown;

            // Find the view
            int index = lstServers.Items.IndexOf( view );
            if (index >= 0)
                if (index < m_Icons.Count)
                {
                    // Attach to the icon
                    var tray = m_Icons[index];

                    // Find
                    foreach (var test in m_TrayIcons)
                        if (ReferenceEquals( test.Value, tray.Icon ))
                        {
                            // Remember
                            oldState = test.Key;

                            // Stop
                            break;
                        }

                    // Set the new state
                    SetNotifyIcon( tray, state );
                }

            // Prepare next loop
            view.EndProcessing();

            // Process transition
            return GetHibernationDialogPoppedUp( controller, oldState, state, mustHibernate, pendingExtensions );
        }
Пример #5
0
        private void tickProcess_Tick( object sender, EventArgs e )
        {
            // Report
            Log( "Timer elapsed" );

            // Check all servers
            foreach (PerServerSettings.PerServerView view in lstServers.Items)
            {
                // Attach to settings
                PerServerSettings settings = view.Settings;

                // Skip
                if (view.IsProcessing)
                {
                    // Report
                    Log( "{0}:{1} is still processing, last processed {2}", settings.ServerName, settings.ServerPort, view.LastProcessed );

                    // Next
                    continue;
                }

                // Calculate next processing time
                DateTime next = view.LastProcessed.AddSeconds( settings.RefreshInterval );

                // Not yet
                if (next >= DateTime.UtcNow)
                {
                    // Report
                    Log( "{0}:{1} will delay until {2}", settings.ServerName, settings.ServerPort, next );

                    // Next
                    continue;
                }

                // Create processing item
                ProcessingItem item = new ProcessingItem( view, this );

                // Run it
                if (ThreadPool.QueueUserWorkItem( item.CheckServer ))
                {
                    // Report
                    Log( "{0}:{1} processing enqueued", settings.ServerName, settings.ServerPort );
                }
                else
                {
                    // Report
                    Log( "{0}:{1} processing started manually", settings.ServerName, settings.ServerPort );

                    // Run manually
                    item.CheckServer( null );
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Forderrt zum Einschläfern des Dienstrechners auf.
        /// </summary>
        /// <param name="controller">Der zu verwendende Dienstrechner.</param>
        internal void TryHibernate( ProcessingItem controller )
        {
            // Fire here after close
            m_forHibernate = controller;

            // Close
            Close();
        }