示例#1
0
        /// <summary>
        /// Erzeugt ein neues Steuerfenster.
        /// </summary>
        /// <param name="service">Der zugehörige Dienst.</param>
        /// <exception cref="ArgumentNullException">Es wurde kein Dienst angegeben.</exception>
        public DebuggerForm( Service service )
        {
            // Validate
            if (service == null)
                throw new ArgumentNullException( "service" );

            // Remember
            m_service = service;

            // Load designer stuff
            InitializeComponent();

            // Configure
            cmdAutomatic.Tag = (Action) (() => m_service.SendPowerCommand( PowerBroadcastStatus.ResumeAutomatic ));
            cmdResume.Tag = (Action) (() => m_service.SendPowerCommand( PowerBroadcastStatus.ResumeSuspend ));
            cmdHibernate.Tag = (Action) (() => m_service.VCRServer.TryHibernateIgnoringInteractiveUsers());
            cmdSuspend.Tag = (Action) (() => m_service.SendPowerCommand( PowerBroadcastStatus.Suspend ));
            
            // Remember old sleep method
            s_initialSleepMethod = Tools.SendSystemToSleep;

            // Overwrite
            Tools.SendSystemToSleep = SendToSleep;
        }
示例#2
0
        /// <summary>
        /// Diese Methode wird beim Starten der VCR.NET Recording Service
        /// Anwendung aufgerufen.
        /// </summary>
        /// <param name="args">Befehlszeilenargumente für den Aufruf der Anwendung.</param>
        public static void Startup( string[] args )
        {
            // Report
            Tools.ExtendedLogging( "Parsing Command Line '{0}'", string.Join( " ", args ) );

            // Error handling
            try
            {
                // First index to check
                int index = 0;

                // Check for debug mode
                if (args.Length > index)
                    if (string.Equals( args[index], "Console" ))
                    {
                        // Report
                        Tools.ExtendedLogging( "Stand-Alone Mode activated" );

                        // Enable debug mode
                        Tools.DebugMode = true;

                        // Skip argument
                        ++index;
                    }

                // Check special mode
                if ((args.Length > index) && string.Equals( args[index], "Restart" ))
                {
                    // Report
                    Tools.ExtendedLogging( "Restart Request detected" );

                    // Call debugger or delay to allow web response send to client
                    if (Tools.DebugMode)
                        Debugger.Break();
                    else
                        Thread.Sleep( 1000 );

                    // Attach to controller
                    using (var service = new ServiceController( "VCR.NET Service" ))
                        if (service.Status == ServiceControllerStatus.Running)
                        {
                            // Stop
                            service.Stop();

                            // Wait for finish
                            service.WaitForStatus( ServiceControllerStatus.Stopped );

                            // Restart
                            service.Start();
                        }
                }
                else if (Tools.DebugMode)
                {
                    // Create
                    using (var vcrnet = new Service())
                    {
                        // Start
                        vcrnet.OnStart( new string[0] );

                        // Wait
                        Application.Run( new DebuggerForm( vcrnet ) );

                        // Stop
                        vcrnet.OnStop();
                    }
                }
                else
                {
                    // Start SCM processings
                    Run( new Service() );
                }
            }
            catch (Exception e)
            {
                // Report
                using (var log = new EventLog( "Application", ".", "VCR.NET Recording Service" ))
                    log.WriteEntry( e.ToString(), EventLogEntryType.Error );
            }
        }