PrintQueue.MergeAndValidatePrintTicket Metodo

Definizione

Unisce due PrintTicket e fa in modo che l'oggetto PrintTicket risultante abbia una validità e non richieda alcuna funzionalità di stampa non supportata dalla stampante.

Overload

MergeAndValidatePrintTicket(PrintTicket, PrintTicket)

Unisce due PrintTicket e fa in modo che l'oggetto PrintTicket risultante abbia una validità e non richieda alcuna funzionalità di stampa non supportata dalla stampante.

MergeAndValidatePrintTicket(PrintTicket, PrintTicket, PrintTicketScope)

Unisce due PrintTicket e fa in modo che l'oggetto PrintTicket risultante abbia una validità, non richieda alcuna funzionalità di stampa non supportata dalla stampante e sia limitato all'ambito specificato.

MergeAndValidatePrintTicket(PrintTicket, PrintTicket)

Unisce due PrintTicket e fa in modo che l'oggetto PrintTicket risultante abbia una validità e non richieda alcuna funzionalità di stampa non supportata dalla stampante.

public:
 System::Printing::ValidationResult MergeAndValidatePrintTicket(System::Printing::PrintTicket ^ basePrintTicket, System::Printing::PrintTicket ^ deltaPrintTicket);
public System.Printing.ValidationResult MergeAndValidatePrintTicket (System.Printing.PrintTicket basePrintTicket, System.Printing.PrintTicket deltaPrintTicket);
member this.MergeAndValidatePrintTicket : System.Printing.PrintTicket * System.Printing.PrintTicket -> System.Printing.ValidationResult
Public Function MergeAndValidatePrintTicket (basePrintTicket As PrintTicket, deltaPrintTicket As PrintTicket) As ValidationResult

Parametri

basePrintTicket
PrintTicket

Primo Print Ticket.

deltaPrintTicket
PrintTicket

Secondo Print Ticket. Può essere null.

Restituisce

ValidationResult che include l'oggetto PrintTicket unito e specifica se sia stato necessario modificare una qualsiasi delle sue impostazioni per garantire l'affidabilità.

Eccezioni

Almeno uno dei Print Ticket di input non è valido.

L'elemento basePrintTicket è null.

Operazione di convalida, unione e controllo affidabilità non riuscita.

Esempio

Nell'esempio seguente viene illustrato come usare questo metodo per unire due ticket di stampa e rispondere all'oggetto ValidationResult restituito.

/// <summary>
/// Changes the user-default PrintTicket setting of the specified print queue.
/// </summary>
/// <param name="queue">the printer whose user-default PrintTicket setting needs to be changed</param>
static private void ChangePrintTicketSetting(PrintQueue queue)
{
    //
    // Obtain the printer's PrintCapabilities so we can determine whether or not
    // duplexing printing is supported by the printer.
    //
    PrintCapabilities printcap = queue.GetPrintCapabilities();

    //
    // The printer's duplexing capability is returned as a read-only collection of duplexing options
    // that can be supported by the printer. If the collection returned contains the duplexing
    // option we want to set, it means the duplexing option we want to set is supported by the printer,
    // so we can make the user-default PrintTicket setting change.
    //
    if (printcap.DuplexingCapability.Contains(Duplexing.TwoSidedLongEdge))
    {
        //
        // To change the user-default PrintTicket, we can first create a delta PrintTicket with
        // the new duplexing setting.
        //
        PrintTicket deltaTicket = new PrintTicket();
        deltaTicket.Duplexing = Duplexing.TwoSidedLongEdge;

        //
        // Then merge the delta PrintTicket onto the printer's current user-default PrintTicket,
        // and validate the merged PrintTicket to get the new PrintTicket we want to set as the
        // printer's new user-default PrintTicket.
        //
        ValidationResult result = queue.MergeAndValidatePrintTicket(queue.UserPrintTicket, deltaTicket);

        //
        // The duplexing option we want to set could be constrained by other PrintTicket settings
        // or device settings. We can check the validated merged PrintTicket to see whether the
        // the validation process has kept the duplexing option we want to set unchanged.
        //
        if (result.ValidatedPrintTicket.Duplexing == Duplexing.TwoSidedLongEdge)
        {
            //
            // Set the printer's user-default PrintTicket and commit the set operation.
            //
            queue.UserPrintTicket = result.ValidatedPrintTicket;
            queue.Commit();
            Console.WriteLine("PrintTicket new duplexing setting is set on '{0}'.", queue.FullName);
        }
        else
        {
            //
            // The duplexing option we want to set has been changed by the validation process
            // when it was resolving setting constraints.
            //
            Console.WriteLine("PrintTicket new duplexing setting is constrained on '{0}'.", queue.FullName);
        }
    }
    else
    {
        //
        // If the printer doesn't support the duplexing option we want to set, skip it.
        //
        Console.WriteLine("PrintTicket new duplexing setting is not supported on '{0}'.", queue.FullName);
    }
}
''' <summary>
''' Changes the user-default PrintTicket setting of the specified print queue.
''' </summary>
''' <param name="queue">the printer whose user-default PrintTicket setting needs to be changed</param>
Private Shared Sub ChangePrintTicketSetting(ByVal queue As PrintQueue)
    '
    ' Obtain the printer's PrintCapabilities so we can determine whether or not
    ' duplexing printing is supported by the printer.
    '
    Dim printcap As PrintCapabilities = queue.GetPrintCapabilities()

    '
    ' The printer's duplexing capability is returned as a read-only collection of duplexing options
    ' that can be supported by the printer. If the collection returned contains the duplexing
    ' option we want to set, it means the duplexing option we want to set is supported by the printer,
    ' so we can make the user-default PrintTicket setting change.
    '
    If printcap.DuplexingCapability.Contains(Duplexing.TwoSidedLongEdge) Then
        '
        ' To change the user-default PrintTicket, we can first create a delta PrintTicket with
        ' the new duplexing setting.
        '
        Dim deltaTicket As New PrintTicket()
        deltaTicket.Duplexing = Duplexing.TwoSidedLongEdge

        '
        ' Then merge the delta PrintTicket onto the printer's current user-default PrintTicket,
        ' and validate the merged PrintTicket to get the new PrintTicket we want to set as the
        ' printer's new user-default PrintTicket.
        '
        Dim result As ValidationResult = queue.MergeAndValidatePrintTicket(queue.UserPrintTicket, deltaTicket)

        '
        ' The duplexing option we want to set could be constrained by other PrintTicket settings
        ' or device settings. We can check the validated merged PrintTicket to see whether the
        ' the validation process has kept the duplexing option we want to set unchanged.
        '
        If result.ValidatedPrintTicket.Duplexing = Duplexing.TwoSidedLongEdge Then
            '
            ' Set the printer's user-default PrintTicket and commit the set operation.
            '
            queue.UserPrintTicket = result.ValidatedPrintTicket
            queue.Commit()
            Console.WriteLine("PrintTicket new duplexing setting is set on '{0}'.", queue.FullName)
        Else
            '
            ' The duplexing option we want to set has been changed by the validation process
            ' when it was resolving setting constraints.
            '
            Console.WriteLine("PrintTicket new duplexing setting is constrained on '{0}'.", queue.FullName)
        End If
    Else
        '
        ' If the printer doesn't support the duplexing option we want to set, skip it.
        '
        Console.WriteLine("PrintTicket new duplexing setting is not supported on '{0}'.", queue.FullName)
    End If
End Sub

Commenti

Il metodo produce un ticket di stampa valida; ovvero, un ticket che non richiede funzionalità di stampa che la stampante non supporta. Il metodo convalida prima i due ticket di stampa di input sullo schema di stampa. Se entrambi non sono validi, viene generata un'eccezione.

I due ticket vengono quindi uniti. Se hanno valori diversi per una determinata proprietà, il ticket unito risultante usa inizialmente il valore del ticket delta.

Il ticket unito viene quindi controllato sulle funzionalità effettive della stampante. Se le impostazioni nel ticket non sono compatibili con le funzionalità della stampante, il driver della stampante modifica queste impostazioni usando qualsiasi logica desiderata. In genere, sostituisce il valore predefinito dell'utente o della stampante per l'impostazione. L'origine del driver dei valori sostitutivi non è lo stesso ticket di basePrintTicket, quindi il ticket unito potrebbe avere alcune impostazioni diverse da entrambe le ticket di input. Se il driver della stampante deve modificare le impostazioni, questo fatto viene segnalato nella ConflictStatus proprietà di ValidationResult.

Per unire e convalidare in base alle impostazioni predefinite di una coda di stampa, è necessario impostare basePrintTicket su DefaultPrintTicket o su UserPrintTicket.

Il deltaPrintTicket parametro può essere null, nel qual caso viene basePrintTicket convalidato, verificato la redditività e restituito, possibilmente con le modifiche.

Con questo overload di MergeAndValidatePrintTicket, sia l'oggetto deltaPrintTicket che nell'oggetto PrintTicketValidationResult restituito hanno ambito ampio per il processo. Per specificare un ambito diverso, usare l'altro overload di questo metodo.

Si applica a

MergeAndValidatePrintTicket(PrintTicket, PrintTicket, PrintTicketScope)

Unisce due PrintTicket e fa in modo che l'oggetto PrintTicket risultante abbia una validità, non richieda alcuna funzionalità di stampa non supportata dalla stampante e sia limitato all'ambito specificato.

public:
 System::Printing::ValidationResult MergeAndValidatePrintTicket(System::Printing::PrintTicket ^ basePrintTicket, System::Printing::PrintTicket ^ deltaPrintTicket, System::Printing::PrintTicketScope scope);
public System.Printing.ValidationResult MergeAndValidatePrintTicket (System.Printing.PrintTicket basePrintTicket, System.Printing.PrintTicket deltaPrintTicket, System.Printing.PrintTicketScope scope);
member this.MergeAndValidatePrintTicket : System.Printing.PrintTicket * System.Printing.PrintTicket * System.Printing.PrintTicketScope -> System.Printing.ValidationResult
Public Function MergeAndValidatePrintTicket (basePrintTicket As PrintTicket, deltaPrintTicket As PrintTicket, scope As PrintTicketScope) As ValidationResult

Parametri

basePrintTicket
PrintTicket

Primo Print Ticket.

deltaPrintTicket
PrintTicket

Secondo Print Ticket. Può essere null.

scope
PrintTicketScope

Valore che indica se l'ambito dell'oggetto deltaPrintTickete l'ambito del Print Ticket restituito in ValidationResult sono costituiti da una pagina, un documento o l'intero processo.

Restituisce

ValidationResult che include l'oggetto PrintTicket unito e specifica se sia stato necessario modificare una qualsiasi delle sue impostazioni per garantire l'affidabilità.

Eccezioni

Almeno uno dei Print Ticket di input non è valido.

L'elemento basePrintTicket è null.

Il parametro scope non ha un valore PrintTicketScope valido.

Operazione di convalida, unione e controllo affidabilità non riuscita.

Commenti

Il metodo produce un ticket di stampa valida; ovvero, un ticket che non richiede funzionalità di stampa che la stampante non supporta. Il metodo convalida prima i due ticket di stampa di input sullo schema di stampa. Se entrambi non sono validi, viene generata un'eccezione.

I due ticket vengono quindi uniti. Se hanno valori diversi per una determinata proprietà, il ticket unito risultante usa inizialmente il valore del ticket delta.

Il ticket unito viene quindi controllato sulle funzionalità effettive della stampante. Se le impostazioni nel ticket non sono compatibili con le funzionalità della stampante, il driver della stampante modifica queste impostazioni usando qualsiasi logica desiderata. In genere, sostituisce il valore predefinito dell'utente o della stampante per l'impostazione. L'origine del driver dei valori sostitutivi non è lo stesso ticket di basePrintTicket, quindi il ticket unito potrebbe avere alcune impostazioni diverse da entrambe le ticket di input. Se il driver della stampante deve modificare le impostazioni, questo fatto viene segnalato nella ConflictStatus proprietà di ValidationResult.

Per unire e convalidare in base alle impostazioni predefinite di una coda di stampa, è necessario impostare basePrintTicket su DefaultPrintTicket o su UserPrintTicket.

Il deltaPrintTicket parametro può essere null, nel qual caso viene basePrintTicket convalidato, verificato la redditività e restituito, possibilmente con le modifiche.

Se si scope tratta di un processo, il ticket di stampa restituito in ValidationResult può includere parametri dello schema di stampa con prefissi Processo, Documento e Pagina. Se è scope un documento, le impostazioni per processo in deltaPrintTicket vengono ignorate e il ticket restituito può includere parametri con prefissi Documento e Pagina. Se si scope tratta di una pagina, le impostazioni per processo e le impostazioni per documento in deltaPrintTicket vengono ignorate e il ticket restituito può includere parametri con solo il prefisso Page.

Si applica a