PrintQueue.UntilTimeOfDay Proprietà

Definizione

Ottiene o imposta l'ultimo orario possibile, espresso come numero di minuti dopo la mezzanotte ora UTC (Coordinated Universal Time), nota anche come ora GMT (Greenwich Mean Time), per la stampa di un processo.

public:
 virtual property int UntilTimeOfDay { int get(); void set(int value); };
public virtual int UntilTimeOfDay { get; set; }
member this.UntilTimeOfDay : int with get, set
Public Overridable Property UntilTimeOfDay As Integer

Valore della proprietà

Int32

Orario in cui la stampante non è più disponibile, espresso come numero di minuti dopo la mezzanotte (ora UTC). Il valore massimo è 1439. Quando una stampante viene installata per la prima volta usando Microsoft Windows Aggiungi guidata stampante, la stampante viene predefinita per essere disponibile tutto il tempo e questa proprietà restituisce 0 in tutti i fusi orari.

Esempio

Nell'esempio seguente viene illustrato come usare questa proprietà per determinare se una stampante è disponibile in questo momento.

private: 
   static void ReportAvailabilityAtThisTime (System::String^% statusReport, System::Printing::PrintQueue^ pq) 
   {
      if (pq->StartTimeOfDay != pq->UntilTimeOfDay)
      {
         System::DateTime utcNow = DateTime::UtcNow;
         System::Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;

         // If now is not within the range of available times . . .
         if (!((pq->StartTimeOfDay < utcNowAsMinutesAfterMidnight) && (utcNowAsMinutesAfterMidnight < pq->UntilTimeOfDay)))
         {
            statusReport = statusReport + " Is not available at this time of day. ";
         }
      }
   };
private static void ReportAvailabilityAtThisTime(ref String statusReport, PrintQueue pq)
{
    if (pq.StartTimeOfDay != pq.UntilTimeOfDay) // If the printer is not available 24 hours a day
    {
DateTime utcNow = DateTime.UtcNow;
Int32 utcNowAsMinutesAfterMidnight = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes;
        
        // If now is not within the range of available times . . .
        if (!((pq.StartTimeOfDay < utcNowAsMinutesAfterMidnight) 
           &&
           (utcNowAsMinutesAfterMidnight < pq.UntilTimeOfDay)))
        {
            statusReport = statusReport + " Is not available at this time of day. ";
        }
    }
}
Private Shared Sub ReportAvailabilityAtThisTime(ByRef statusReport As String, ByVal pq As PrintQueue)
    If pq.StartTimeOfDay <> pq.UntilTimeOfDay Then ' If the printer is not available 24 hours a day
Dim utcNow As Date = Date.UtcNow
Dim utcNowAsMinutesAfterMidnight As Int32 = (utcNow.TimeOfDay.Hours * 60) + utcNow.TimeOfDay.Minutes

        ' If now is not within the range of available times . . .
        If Not((pq.StartTimeOfDay < utcNowAsMinutesAfterMidnight) AndAlso (utcNowAsMinutesAfterMidnight < pq.UntilTimeOfDay)) Then
            statusReport = statusReport & " Is not available at this time of day. "
        End If
    End If
End Sub

Commenti

Se non si è nel fuso orario UTC, è necessario aggiungere o sottrarre più di 60 per impostare o ottenere l'ora corretta per il fuso orario. Ad esempio, se si è nel fuso orario Pacifico di America del Nord e l'ora legale non è effettiva, l'ora locale è di 8 ore prima dell'ORA UTC. Per impostare UntilTimeOfDay su 12 AM nel fuso orario, impostarlo su 8 AM UTC, ovvero 480 (= 8 * 60). È anche necessario ricordare che il tempo passa a zero dopo il 24° ora (il 1439° minuto). Per impostarlo su 6 PM nel fuso orario, impostarlo su 2 AM UTC, ovvero 120 (= 2 * 60). Vedere TimeZone, TimeSpane DateTime classi per metodi utili per la modifica del fuso orario.

Se la stampante è sempre disponibile, questa proprietà restituisce 0 in tutti i fusi orari.

Si applica a

Vedi anche