Procedura: diagnosticare processi di stampa problematiciHow to: Diagnose Problematic Print Job

Gli amministratori di rete fanno spesso fronte ai reclami degli utenti su processi di stampa lenti o che non vengono eseguiti affatto.Network administrators often field complaints from users about print jobs that do not print or print slowly. Il set completo di proprietà di processo di stampa esposte nel APIAPIs di Microsoft .NET Framework forniscono un mezzo per l'esecuzione rapida diagnosi remota dei processi di stampa.The rich set of print job properties exposed in the APIAPIs of Microsoft .NET Framework provide a means for performing a rapid remote diagnosis of print jobs.

EsempioExample

Di seguito sono indicati i passaggi principali per la creazione di questo tipo di utilità.The major steps for creating this kind of utility are as follows.

  1. Identificare il processo di stampa oggetto del reclamo dell'utente.Identify the print job that the user is complaining about. Gli utenti spesso non sono in grado di eseguire questa verifica con precisione.Users often cannot do this precisely. Non conoscono i nomi dei server di stampa o delle stampanti.They may not know the names of the print servers or printers. Descrivono il percorso della stampante in una terminologia diversa da quella utilizzata nell'impostazione relativo Location proprietà.They may describe the location of the printer in different terminology than was used in setting its Location property. È consigliabile quindi generare un elenco dei processi inviati dall'utente.Accordingly, it is a good idea to generate a list of the user's currently submitted jobs. Nel caso ci siano più processi, la comunicazione tra l'utente e l'amministratore del sistema di stampa può essere quindi usata per individuare il processo problematico.If there is more than one, then communication between the user and the print system administrator can be used to pinpoint the job that is having problems. Di seguito sono indicati i passaggi secondari.The substeps are as follows.

    1. Ottenere un elenco di tutti i server di stampa.Obtain a list of all print servers.

    2. Riprodurre il ciclo dei server per eseguire una query sulle code di stampa.Loop through the servers to query their print queues.

    3. In ogni passaggio del ciclo del server, riprodurre il ciclo di tutte le code del server per eseguire query sui processi.Within each pass of the server loop, loop through all the server's queues to query their jobs

    4. In ogni passaggio del ciclo di code, eseguire il ciclo dei processi e raccogliere informazioni di identificazione su quelli che sono stati inviati dall'utente del reclamo.Within each pass of the queue loop, loop through its jobs and gather identifying information about those that were submitted by the complaining user.

  2. Quando viene individuato il processo di stampa problematico, esaminare le proprietà rilevanti per vedere quale potrebbe essere la causa del problema.When the problematic print job has been identified, examine relevant properties to see what might be the problem. Ad esempio, se si tratta di un errore di stato del processo oppure la stampante che gestisce la coda è passata alla modalità offline prima della stampa.For example, is job in an error state or did the printer servicing the queue go offline before the job could print?

Il codice riportato di seguito include una serie di esempi di codice.The code below is series of code examples. Il primo esempio di codice contiene il ciclo tra le code di stampa.The first code example contains the loop through the print queues. Vedere il passaggio 1c precedente. La variabile myPrintQueues è il PrintQueueCollection oggetto per il server di stampato corrente.(Step 1c above.) The variable myPrintQueues is the PrintQueueCollection object for the current print server.

L'esempio di codice inizia con l'aggiornamento dell'oggetto corrente della coda di stampa con PrintQueue.Refresh.The code example begins by refreshing the current print queue object with PrintQueue.Refresh. Ciò garantisce che le proprietà dell'oggetto rappresentano accuratamente lo stato della stampante fisica rappresentata.This ensures that the object's properties accurately represent the state of the physical printer that it represents. Quindi l'applicazione ottiene la raccolta di processi di stampa attualmente nella coda di stampa tramite GetPrintJobInfoCollection.Then the application gets the collection of print jobs currently in the print queue by using GetPrintJobInfoCollection.

Successivamente l'applicazione esegue il ciclo di PrintSystemJobInfo raccolta e confronta Submitter proprietà con l'alias dell'utente reclamo.Next the application loops through the PrintSystemJobInfo collection and compares each Submitter property with the alias of the complaining user. Se ci sono corrispondenze, l'applicazione aggiunge le informazioni di identificazione sul processo alla stringa che verrà visualizzata.If they match, the application adds identifying information about the job to the string that will be presented. Le variabili userName e jobList vengono inizializzate prima nell'applicazione.(The userName and jobList variables are initialized earlier in the application.)

for each (PrintQueue^ pq in myPrintQueues)
{
   pq->Refresh();
   PrintJobInfoCollection^ jobs = pq->GetPrintJobInfoCollection();
   for each (PrintSystemJobInfo^ job in jobs)
   {
      // Since the user may not be able to articulate which job is problematic,
      // present information about each job the user has submitted.
      if (job->Submitter == userName)
      {
         atLeastOne = true;
         jobList = jobList + "\nServer:" + line;
         jobList = jobList + "\n\tQueue:" + pq->Name;
         jobList = jobList + "\n\tLocation:" + pq->Location;
         jobList = jobList + "\n\t\tJob: " + job->JobName + " ID: " + job->JobIdentifier;
      }
   }
}
foreach (PrintQueue pq in myPrintQueues)
{
    pq.Refresh();
    PrintJobInfoCollection jobs = pq.GetPrintJobInfoCollection();
    foreach (PrintSystemJobInfo job in jobs)
    {
        // Since the user may not be able to articulate which job is problematic,
        // present information about each job the user has submitted.
        if (job.Submitter == userName)
        {
            atLeastOne = true;
            jobList = jobList + "\nServer:" + line;
            jobList = jobList + "\n\tQueue:" + pq.Name;
            jobList = jobList + "\n\tLocation:" + pq.Location;
            jobList = jobList + "\n\t\tJob: " + job.JobName + " ID: " + job.JobIdentifier;
        }
    }// end for each print job    

}// end for each print queue
For Each pq As PrintQueue In myPrintQueues
	pq.Refresh()
	Dim jobs As PrintJobInfoCollection = pq.GetPrintJobInfoCollection()
	For Each job As PrintSystemJobInfo In jobs
		' Since the user may not be able to articulate which job is problematic,
		' present information about each job the user has submitted.
		If job.Submitter = userName Then
			atLeastOne = True
			jobList = jobList & vbLf & "Server:" & line
			jobList = jobList & vbLf & vbTab & "Queue:" & pq.Name
			jobList = jobList & vbLf & vbTab & "Location:" & pq.Location
			jobList = jobList & vbLf & vbTab & vbTab & "Job: " & job.JobName & " ID: " & job.JobIdentifier
		End If
	Next job ' end for each print job

Next pq ' end for each print queue

L'esempio di codice successivo preleva l'applicazione al passaggio 2.The next code example picks up the application at Step 2. Vedere sopra. Il processo problematico è stato identificato e l'applicazione richiede le informazioni che lo identificheranno.(See above.) The problematic job has been identified and the application prompts for the information that will identify it. Queste informazioni vengono utilizzate per creare PrintServer, PrintQueue, e PrintSystemJobInfo oggetti.From this information it creates PrintServer, PrintQueue, and PrintSystemJobInfo objects.

A questo punto l'applicazione contiene una struttura ramificata corrispondente ai due modi di controllo dello stato del processo di stampa:At this point the application contains a branching structure corresponding to the two ways of checking a print job's status:

Questo esempio illustra entrambi i metodi, in modo che l'utente in precedenza è stato richiesto il metodo da usare e ha risposto con "Y" se desidera utilizzare i flag del JobStatus proprietà.This example demonstrates both methods, so the user was previously prompted as to which method to use and responded with "Y" if he or she wanted to use the flags of the JobStatus property. Per i dettagli dei due metodi, vedere di seguito.See below for the details of the two methods. Infine, l'applicazione usa un metodo denominato ReportQueueAndJobAvailability per segnalare se il processo può essere stampato all'ora indicata.Finally, the application uses a method called ReportQueueAndJobAvailability to report on whether the job can be printed at this time of day. Questo metodo viene illustrato in Individuare se è possibile eseguire o meno un processo di stampa all'orario indicato.This method is discussed in Discover Whether a Print Job Can Be Printed At This Time of Day.

// When the problematic print job has been identified, enter information about it.
Console::Write("\nEnter the print server hosting the job (including leading slashes \\\\): " + "\n(press Return for the current computer \\\\{0}): ", Environment::MachineName);
String^ pServer = Console::ReadLine();
if (pServer == "")
{
   pServer = "\\\\" + Environment::MachineName;
}
Console::Write("\nEnter the print queue hosting the job: ");
String^ pQueue = Console::ReadLine();
Console::Write("\nEnter the job ID: ");
Int16 jobID = Convert::ToInt16(Console::ReadLine());

// Create objects to represent the server, queue, and print job.
PrintServer^ hostingServer = gcnew PrintServer(pServer, PrintSystemDesiredAccess::AdministrateServer);
PrintQueue^ hostingQueue = gcnew PrintQueue(hostingServer, pQueue, PrintSystemDesiredAccess::AdministratePrinter);
PrintSystemJobInfo^ theJob = hostingQueue->GetJob(jobID);

if (useAttributesResponse == "Y")
{
   TroubleSpotter::SpotTroubleUsingJobAttributes(theJob);
   // TroubleSpotter class is defined in the complete example.
} else
{
   TroubleSpotter::SpotTroubleUsingProperties(theJob);
}

TroubleSpotter::ReportQueueAndJobAvailability(theJob);
// When the problematic print job has been identified, enter information about it.
Console.Write("\nEnter the print server hosting the job (including leading slashes \\\\): " +
"\n(press Return for the current computer \\\\{0}): ", Environment.MachineName);
String pServer = Console.ReadLine();
if (pServer == "")
{
    pServer = "\\\\" +Environment.MachineName;
}
Console.Write("\nEnter the print queue hosting the job: ");
String pQueue = Console.ReadLine(); 
Console.Write("\nEnter the job ID: ");
Int16 jobID = Convert.ToInt16(Console.ReadLine());

// Create objects to represent the server, queue, and print job.
PrintServer hostingServer = new PrintServer(pServer, PrintSystemDesiredAccess.AdministrateServer);
PrintQueue hostingQueue = new PrintQueue(hostingServer, pQueue, PrintSystemDesiredAccess.AdministratePrinter);
PrintSystemJobInfo theJob = hostingQueue.GetJob(jobID);

if (useAttributesResponse == "Y")
{
    TroubleSpotter.SpotTroubleUsingJobAttributes(theJob);
    // TroubleSpotter class is defined in the complete example.
}
else
{
    TroubleSpotter.SpotTroubleUsingProperties(theJob);
}

TroubleSpotter.ReportQueueAndJobAvailability(theJob);
' When the problematic print job has been identified, enter information about it.
Console.Write(vbLf & "Enter the print server hosting the job (including leading slashes \\): " & vbLf & "(press Return for the current computer \\{0}): ", Environment.MachineName)
Dim pServer As String = Console.ReadLine()
If pServer = "" Then
	pServer = "\\" & Environment.MachineName
End If
Console.Write(vbLf & "Enter the print queue hosting the job: ")
Dim pQueue As String = Console.ReadLine()
Console.Write(vbLf & "Enter the job ID: ")
Dim jobID As Int16 = Convert.ToInt16(Console.ReadLine())

' Create objects to represent the server, queue, and print job.
Dim hostingServer As New PrintServer(pServer, PrintSystemDesiredAccess.AdministrateServer)
Dim hostingQueue As New PrintQueue(hostingServer, pQueue, PrintSystemDesiredAccess.AdministratePrinter)
Dim theJob As PrintSystemJobInfo = hostingQueue.GetJob(jobID)

If useAttributesResponse = "Y" Then
	TroubleSpotter.SpotTroubleUsingJobAttributes(theJob)
	' TroubleSpotter class is defined in the complete example.
Else
	TroubleSpotter.SpotTroubleUsingProperties(theJob)
End If

TroubleSpotter.ReportQueueAndJobAvailability(theJob)

Per controllare lo stato del processo di stampa utilizzando il flag della JobStatus proprietà, si verifica ogni flag pertinente per verificare se è impostato.To check print job status using the flags of the JobStatus property, you check each relevant flag to see if it is set. Il metodo standard per verificare se un bit è impostato in un set di flag di bit consiste nell'eseguire un'operazione di AND logico con il set di flag come uno degli operandi e il flag stesso come altro operando.The standard way to see if one bit is set in a set of bit flags is to perform a logical AND operation with the set of flags as one operand and the flag itself as the other. Poiché il flag stesso ha un solo bit impostato, il risultato dell'AND logico è che, al massimo, è impostato quello stesso bit.Since the flag itself has only one bit set, the result of the logical AND is that, at most, that same bit is set. Per verificare se lo è o meno, confrontare il risultato dell’AND logico con il flag stesso.To find out whether it is or not, just compare the result of the logical AND with the flag itself. Per ulteriori informazioni, vedere PrintJobStatus, & (operatore) (riferimenti per c#), e FlagsAttribute.For more information, see PrintJobStatus, the & Operator (C# Reference), and FlagsAttribute.

Per ogni attributo il cui bit è impostato, il codice lo riporta allo schermo della console e talvolta suggerisce un modo per rispondere.For each attribute whose bit is set, the code reports this to the console screen and sometimes suggests a way to respond. Il metodo HandlePausedJob che viene chiamato se il processo o la coda è in pausa è illustrato di seguito.(The HandlePausedJob method that is called if the job or queue is paused is discussed below.)

// Check for possible trouble states of a print job using the flags of the JobStatus property
static void SpotTroubleUsingJobAttributes (PrintSystemJobInfo^ theJob) 
{
   if ((theJob->JobStatus & PrintJobStatus::Blocked) == PrintJobStatus::Blocked)
   {
      Console::WriteLine("The job is blocked.");
   }
   if (((theJob->JobStatus & PrintJobStatus::Completed) == PrintJobStatus::Completed)
      || 
      ((theJob->JobStatus & PrintJobStatus::Printed) == PrintJobStatus::Printed))
   {
      Console::WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
   }
   if (((theJob->JobStatus & PrintJobStatus::Deleted) == PrintJobStatus::Deleted)
      || 
      ((theJob->JobStatus & PrintJobStatus::Deleting) == PrintJobStatus::Deleting))
   {
      Console::WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
   }
   if ((theJob->JobStatus & PrintJobStatus::Error) == PrintJobStatus::Error)
   {
      Console::WriteLine("The job has errored.");
   }
   if ((theJob->JobStatus & PrintJobStatus::Offline) == PrintJobStatus::Offline)
   {
      Console::WriteLine("The printer is offline. Have user put it online with printer front panel.");
   }
   if ((theJob->JobStatus & PrintJobStatus::PaperOut) == PrintJobStatus::PaperOut)
   {
      Console::WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
   }
   if (((theJob->JobStatus & PrintJobStatus::Paused) == PrintJobStatus::Paused)
      || 
      ((theJob->HostingPrintQueue->QueueStatus & PrintQueueStatus::Paused) == PrintQueueStatus::Paused))
   {
      HandlePausedJob(theJob);
      //HandlePausedJob is defined in the complete example.
   }

   if ((theJob->JobStatus & PrintJobStatus::Printing) == PrintJobStatus::Printing)
   {
      Console::WriteLine("The job is printing now.");
   }
   if ((theJob->JobStatus & PrintJobStatus::Spooling) == PrintJobStatus::Spooling)
   {
      Console::WriteLine("The job is spooling now.");
   }
   if ((theJob->JobStatus & PrintJobStatus::UserIntervention) == PrintJobStatus::UserIntervention)
   {
      Console::WriteLine("The printer needs human intervention.");
   }
};
// Check for possible trouble states of a print job using the flags of the JobStatus property
internal static void SpotTroubleUsingJobAttributes(PrintSystemJobInfo theJob)
{
    if ((theJob.JobStatus & PrintJobStatus.Blocked) == PrintJobStatus.Blocked)
    {
        Console.WriteLine("The job is blocked.");
    }
    if (((theJob.JobStatus & PrintJobStatus.Completed) == PrintJobStatus.Completed)
        || 
        ((theJob.JobStatus & PrintJobStatus.Printed) == PrintJobStatus.Printed))
    {
        Console.WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
    }
    if (((theJob.JobStatus & PrintJobStatus.Deleted) == PrintJobStatus.Deleted)
        || 
        ((theJob.JobStatus & PrintJobStatus.Deleting) == PrintJobStatus.Deleting))
    {
        Console.WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
    }
    if ((theJob.JobStatus & PrintJobStatus.Error) == PrintJobStatus.Error)
    {
        Console.WriteLine("The job has errored.");
    }
    if ((theJob.JobStatus & PrintJobStatus.Offline) == PrintJobStatus.Offline)
    {
        Console.WriteLine("The printer is offline. Have user put it online with printer front panel.");
    }
    if ((theJob.JobStatus & PrintJobStatus.PaperOut) == PrintJobStatus.PaperOut)
    {
        Console.WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
    }

    if (((theJob.JobStatus & PrintJobStatus.Paused) == PrintJobStatus.Paused)
        || 
        ((theJob.HostingPrintQueue.QueueStatus & PrintQueueStatus.Paused) == PrintQueueStatus.Paused))
    {
        HandlePausedJob(theJob);
        //HandlePausedJob is defined in the complete example.
    }

    if ((theJob.JobStatus & PrintJobStatus.Printing) == PrintJobStatus.Printing)
    {
        Console.WriteLine("The job is printing now.");
    }
    if ((theJob.JobStatus & PrintJobStatus.Spooling) == PrintJobStatus.Spooling)
    {
        Console.WriteLine("The job is spooling now.");
    }
    if ((theJob.JobStatus & PrintJobStatus.UserIntervention) == PrintJobStatus.UserIntervention)
    {
        Console.WriteLine("The printer needs human intervention.");
    }
  
}//end SpotTroubleUsingJobAttributes
' Check for possible trouble states of a print job using the flags of the JobStatus property
Friend Shared Sub SpotTroubleUsingJobAttributes(ByVal theJob As PrintSystemJobInfo)
	If (theJob.JobStatus And PrintJobStatus.Blocked) = PrintJobStatus.Blocked Then
		Console.WriteLine("The job is blocked.")
	End If
	If ((theJob.JobStatus And PrintJobStatus.Completed) = PrintJobStatus.Completed) OrElse ((theJob.JobStatus And PrintJobStatus.Printed) = PrintJobStatus.Printed) Then
		Console.WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.")
	End If
	If ((theJob.JobStatus And PrintJobStatus.Deleted) = PrintJobStatus.Deleted) OrElse ((theJob.JobStatus And PrintJobStatus.Deleting) = PrintJobStatus.Deleting) Then
		Console.WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.")
	End If
	If (theJob.JobStatus And PrintJobStatus.Error) = PrintJobStatus.Error Then
		Console.WriteLine("The job has errored.")
	End If
	If (theJob.JobStatus And PrintJobStatus.Offline) = PrintJobStatus.Offline Then
		Console.WriteLine("The printer is offline. Have user put it online with printer front panel.")
	End If
	If (theJob.JobStatus And PrintJobStatus.PaperOut) = PrintJobStatus.PaperOut Then
		Console.WriteLine("The printer is out of paper of the size required by the job. Have user add paper.")
	End If

	If ((theJob.JobStatus And PrintJobStatus.Paused) = PrintJobStatus.Paused) OrElse ((theJob.HostingPrintQueue.QueueStatus And PrintQueueStatus.Paused) = PrintQueueStatus.Paused) Then
		HandlePausedJob(theJob)
		'HandlePausedJob is defined in the complete example.
	End If

	If (theJob.JobStatus And PrintJobStatus.Printing) = PrintJobStatus.Printing Then
		Console.WriteLine("The job is printing now.")
	End If
	If (theJob.JobStatus And PrintJobStatus.Spooling) = PrintJobStatus.Spooling Then
		Console.WriteLine("The job is spooling now.")
	End If
	If (theJob.JobStatus And PrintJobStatus.UserIntervention) = PrintJobStatus.UserIntervention Then
		Console.WriteLine("The printer needs human intervention.")
	End If

End Sub 'end SpotTroubleUsingJobAttributes

Per controllare lo stato del processo di stampa usando proprietà separate, è sufficiente leggere tutte le proprietà e, se la proprietà è true, visualizzarla nello schermo della console e suggerire possibilmente una modalità di risposta.To check print job status using separate properties, you simply read each property and, if the property is true, report to the console screen and possibly suggest a way to respond. Il metodo HandlePausedJob che viene chiamato se il processo o la coda è in pausa è illustrato di seguito.(The HandlePausedJob method that is called if the job or queue is paused is discussed below.)

// Check for possible trouble states of a print job using its properties
static void SpotTroubleUsingProperties (PrintSystemJobInfo^ theJob) 
{
   if (theJob->IsBlocked)
   {
      Console::WriteLine("The job is blocked.");
   }
   if (theJob->IsCompleted || theJob->IsPrinted)
   {
      Console::WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
   }
   if (theJob->IsDeleted || theJob->IsDeleting)
   {
      Console::WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
   }
   if (theJob->IsInError)
   {
      Console::WriteLine("The job has errored.");
   }
   if (theJob->IsOffline)
   {
      Console::WriteLine("The printer is offline. Have user put it online with printer front panel.");
   }
   if (theJob->IsPaperOut)
   {
      Console::WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
   }

   if (theJob->IsPaused || theJob->HostingPrintQueue->IsPaused)
   {
      HandlePausedJob(theJob);
      //HandlePausedJob is defined in the complete example.
   }

   if (theJob->IsPrinting)
   {
      Console::WriteLine("The job is printing now.");
   }
   if (theJob->IsSpooling)
   {
      Console::WriteLine("The job is spooling now.");
   }
   if (theJob->IsUserInterventionRequired)
   {
      Console::WriteLine("The printer needs human intervention.");
   }
};
// Check for possible trouble states of a print job using its properties
internal static void SpotTroubleUsingProperties(PrintSystemJobInfo theJob)
{
    if (theJob.IsBlocked)
    {
        Console.WriteLine("The job is blocked.");
    }
    if (theJob.IsCompleted || theJob.IsPrinted)
    {
        Console.WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
    }
    if (theJob.IsDeleted || theJob.IsDeleting)
    {
        Console.WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
    }
    if (theJob.IsInError)
    {
        Console.WriteLine("The job has errored.");
    }
    if (theJob.IsOffline)
    {
        Console.WriteLine("The printer is offline. Have user put it online with printer front panel.");
    }
    if (theJob.IsPaperOut)
    {
        Console.WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
    }

    if (theJob.IsPaused || theJob.HostingPrintQueue.IsPaused)
    {
        HandlePausedJob(theJob);
        //HandlePausedJob is defined in the complete example.
    }

    if (theJob.IsPrinting)
    {
        Console.WriteLine("The job is printing now.");
    }
    if (theJob.IsSpooling)
    {
        Console.WriteLine("The job is spooling now.");
    }
    if (theJob.IsUserInterventionRequired)
    {
        Console.WriteLine("The printer needs human intervention.");
    }

}//end SpotTroubleUsingProperties
' Check for possible trouble states of a print job using its properties
Friend Shared Sub SpotTroubleUsingProperties(ByVal theJob As PrintSystemJobInfo)
	If theJob.IsBlocked Then
		Console.WriteLine("The job is blocked.")
	End If
	If theJob.IsCompleted OrElse theJob.IsPrinted Then
		Console.WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.")
	End If
	If theJob.IsDeleted OrElse theJob.IsDeleting Then
		Console.WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.")
	End If
	If theJob.IsInError Then
		Console.WriteLine("The job has errored.")
	End If
	If theJob.IsOffline Then
		Console.WriteLine("The printer is offline. Have user put it online with printer front panel.")
	End If
	If theJob.IsPaperOut Then
		Console.WriteLine("The printer is out of paper of the size required by the job. Have user add paper.")
	End If

	If theJob.IsPaused OrElse theJob.HostingPrintQueue.IsPaused Then
		HandlePausedJob(theJob)
		'HandlePausedJob is defined in the complete example.
	End If

	If theJob.IsPrinting Then
		Console.WriteLine("The job is printing now.")
	End If
	If theJob.IsSpooling Then
		Console.WriteLine("The job is spooling now.")
	End If
	If theJob.IsUserInterventionRequired Then
		Console.WriteLine("The printer needs human intervention.")
	End If

End Sub 'end SpotTroubleUsingProperties

Il metodo HandlePausedJob consente all'utente dell'applicazione di riprendere i processi sospesi in modalità remota.The HandlePausedJob method enables the application's user to remotely resume paused jobs. Poiché potrebbe esserci un motivo valido per cui è stata sospesa la coda di stampa, il metodo inizia richiedendo all'utente conferma sul riavvio.Because there might be a good reason why the print queue was paused, the method begins by prompting for a user decision about whether to resume it. Se la risposta è "Y", quindi il PrintQueue.Resume metodo viene chiamato.If the answer is "Y", then the PrintQueue.Resume method is called.

Successivamente, verrà richiesto all'utente di decidere se deve essere ripreso il processo stesso, nel caso sia stato sospeso indipendentemente dalla coda di stampa.Next the user is prompted to decide if the job itself should be resumed, just in case it is paused independently of the print queue. (Confrontare PrintQueue.IsPaused e PrintSystemJobInfo.IsPaused.) Se la risposta è "Y", quindi PrintSystemJobInfo.Resume chiamato; in caso contrario Cancel viene chiamato.(Compare PrintQueue.IsPaused and PrintSystemJobInfo.IsPaused.) If the answer is "Y", then PrintSystemJobInfo.Resume is called; otherwise Cancel is called.

static void HandlePausedJob (PrintSystemJobInfo^ theJob) 
{
   // If there's no good reason for the queue to be paused, resume it and 
   // give user choice to resume or cancel the job.
   Console::WriteLine("The user or someone with administrative rights to the queue" + "\nhas paused the job or queue." + "\nResume the queue? (Has no effect if queue is not paused.)" + "\nEnter \"Y\" to resume, otherwise press return: ");
   String^ resume = Console::ReadLine();
   if (resume == "Y")
   {
      theJob->HostingPrintQueue->Resume();

      // It is possible the job is also paused. Find out how the user wants to handle that.
      Console::WriteLine("Does user want to resume print job or cancel it?" + "\nEnter \"Y\" to resume (any other key cancels the print job): ");
      String^ userDecision = Console::ReadLine();
      if (userDecision == "Y")
      {
         theJob->Resume();
      } else
      {
         theJob->Cancel();
      }
   }
};
internal static void HandlePausedJob(PrintSystemJobInfo theJob)
{
    // If there's no good reason for the queue to be paused, resume it and 
    // give user choice to resume or cancel the job.
    Console.WriteLine("The user or someone with administrative rights to the queue" +
         "\nhas paused the job or queue." +
         "\nResume the queue? (Has no effect if queue is not paused.)" +
         "\nEnter \"Y\" to resume, otherwise press return: ");
    String resume = Console.ReadLine();
    if (resume == "Y")
    {
        theJob.HostingPrintQueue.Resume();
        
        // It is possible the job is also paused. Find out how the user wants to handle that.
        Console.WriteLine("Does user want to resume print job or cancel it?" +
            "\nEnter \"Y\" to resume (any other key cancels the print job): ");
        String userDecision = Console.ReadLine();
        if (userDecision == "Y")
        {
            theJob.Resume();
        }
        else
        {
            theJob.Cancel();
        }
    }//end if the queue should be resumed

}//end HandlePausedJob
Friend Shared Sub HandlePausedJob(ByVal theJob As PrintSystemJobInfo)
	' If there's no good reason for the queue to be paused, resume it and 
	' give user choice to resume or cancel the job.
	Console.WriteLine("The user or someone with administrative rights to the queue" & vbLf & "has paused the job or queue." & vbLf & "Resume the queue? (Has no effect if queue is not paused.)" & vbLf & "Enter ""Y"" to resume, otherwise press return: ")
	Dim [resume] As String = Console.ReadLine()
	If [resume] = "Y" Then
		theJob.HostingPrintQueue.Resume()

		' It is possible the job is also paused. Find out how the user wants to handle that.
		Console.WriteLine("Does user want to resume print job or cancel it?" & vbLf & "Enter ""Y"" to resume (any other key cancels the print job): ")
		Dim userDecision As String = Console.ReadLine()
		If userDecision = "Y" Then
			theJob.Resume()
		Else
			theJob.Cancel()
		End If
	End If 'end if the queue should be resumed

End Sub 'end HandlePausedJob

Vedere ancheSee Also

PrintJobStatus
PrintSystemJobInfo
FlagsAttribute
PrintQueue
& (Operatore) (riferimenti per c#)& Operator (C# Reference)
Documenti in WPFDocuments in WPF
Panoramica della stampaPrinting Overview