コード例 #1
0
        } // end InstallAsync()


        private void _DoInstall( IInstallCallback installCallback )
        {
            installCallback.WriteVerbose( String.Format( CultureInfo.CurrentCulture,
                                                         "Attempting to run this command on {0}: {1}",
                                                         m_machine,
                                                         m_command ) );
            Exception e = null;
            int errorCode = 0;
            UpdateInstallResult uir = null;
            try
            {
                errorCode = _RunCommand( m_command, false, installCallback );
            }
            catch( Win32Exception w32e ) { e = w32e; }
            catch( ManagementException me ) { e = me; }
            catch( OperationCanceledException )
            {
                uir = new UpdateInstallResult( m_update,
                                               ResultCode.Canceled,
                                               0,                 // error code
                                               false,             // reboot required
                                               false,             // long reboot hint
                                               DateTime.UtcNow ); // All timestamps should be UTC.
                installCallback.ReportInstallResult( uir );
                throw;
            }

            if( null != e )
            {
                throw new FabrikamException( String.Format( CultureInfo.CurrentCulture,
                                                            "Failed to run command: {0}: {1}",
                                                            e.GetType().Name,
                                                            e.Message ),
                                             e );
            }

            bool rebootRequired = false;
            bool succeeded = false;
            const int ERROR_SUCCESS_REBOOT_REQUIRED  = 3010;
            const int ERROR_SUCCESS_RESTART_REQUIRED = 3011;
            const int ERROR_FAIL_REBOOT_REQUIRED     = 3017;

            if( 0 == errorCode )
            {
                succeeded = true;
            }
            else if( (ERROR_SUCCESS_REBOOT_REQUIRED == errorCode) ||
                     (ERROR_SUCCESS_RESTART_REQUIRED == errorCode) )
            {
                succeeded = true;
                rebootRequired = true;
            }
            else if( 0 != errorCode )
            {
                succeeded = false;
                if( ERROR_FAIL_REBOOT_REQUIRED == errorCode )
                {
                    rebootRequired = true;
                }
            }

            uir = new UpdateInstallResult( m_update,
                                           succeeded ? ResultCode.Succeeded : ResultCode.Failed,
                                           errorCode,
                                           rebootRequired,
                                           false,
                                           DateTime.UtcNow ); // All timestamps should be UTC.
            installCallback.ReportInstallResult( uir );
        } // end _DoInstall()
コード例 #2
0
        } // end InstallAsync()

        private void _DoInstall(IInstallCallback installCallback)
        {
            installCallback.WriteVerbose(String.Format(CultureInfo.CurrentCulture,
                                                       "Attempting to run this command on {0}: {1}",
                                                       m_machine,
                                                       m_command));
            Exception           e         = null;
            int                 errorCode = 0;
            UpdateInstallResult uir       = null;

            try
            {
                errorCode = _RunCommand(m_command, false, installCallback);
            }
            catch (Win32Exception w32e) { e = w32e; }
            catch (ManagementException me) { e = me; }
            catch (OperationCanceledException)
            {
                uir = new UpdateInstallResult(m_update,
                                              ResultCode.Canceled,
                                              0,                  // error code
                                              false,              // reboot required
                                              false,              // long reboot hint
                                              DateTime.UtcNow);   // All timestamps should be UTC.
                installCallback.ReportInstallResult(uir);
                throw;
            }

            if (null != e)
            {
                throw new FabrikamException(String.Format(CultureInfo.CurrentCulture,
                                                          "Failed to run command: {0}: {1}",
                                                          e.GetType().Name,
                                                          e.Message),
                                            e);
            }

            bool      rebootRequired = false;
            bool      succeeded      = false;
            const int ERROR_SUCCESS_REBOOT_REQUIRED  = 3010;
            const int ERROR_SUCCESS_RESTART_REQUIRED = 3011;
            const int ERROR_FAIL_REBOOT_REQUIRED     = 3017;

            if (0 == errorCode)
            {
                succeeded = true;
            }
            else if ((ERROR_SUCCESS_REBOOT_REQUIRED == errorCode) ||
                     (ERROR_SUCCESS_RESTART_REQUIRED == errorCode))
            {
                succeeded      = true;
                rebootRequired = true;
            }
            else if (0 != errorCode)
            {
                succeeded = false;
                if (ERROR_FAIL_REBOOT_REQUIRED == errorCode)
                {
                    rebootRequired = true;
                }
            }

            uir = new UpdateInstallResult(m_update,
                                          succeeded ? ResultCode.Succeeded : ResultCode.Failed,
                                          errorCode,
                                          rebootRequired,
                                          false,
                                          DateTime.UtcNow);   // All timestamps should be UTC.
            installCallback.ReportInstallResult(uir);
        } // end _DoInstall()