Imports System.Environment ''' ''' Values indicating the status of a batch queue entry. ''' Public Enum BatchEntryStatus Pending Holding Active End Enum ''' ''' Contains information about a batch queue entry. ''' ''' ''' This object contains information about batch entry including ''' when it was submitted, the user that submitted the job and ''' which machine the user was using at the time. It also contains ''' the job's priority, status and the optional date/time until ''' which the job should be held until it is run. ''' _ Public Class BatchEntryInfo Private mID As Guid = Guid.NewGuid Private mSubmitted As Date = Now Private mUser As String = System.Environment.UserName Private mMachine As String = System.Environment.MachineName Private mPriority As Messaging.MessagePriority = Messaging.MessagePriority.Normal Private mMsgID As String Private mHoldUntil As Date = Date.MinValue Private mStatus As BatchEntryStatus = BatchEntryStatus.Pending ''' ''' Returns the unique ID value for this batch entry. ''' Public ReadOnly Property ID() As Guid Get Return mID End Get End Property ''' ''' Returns the date and time that the batch entry ''' was submitted. ''' Public ReadOnly Property Submitted() As Date Get Return mSubmitted End Get End Property ''' ''' Returns the Windows user id of the user that ''' was logged into the workstation when the job ''' was submitted. ''' Public ReadOnly Property User() As String Get Return mUser End Get End Property ''' ''' Returns the name of the workstation from ''' which this job was submitted. ''' Public ReadOnly Property Machine() As String Get Return mMachine End Get End Property ''' ''' Returns the priority of this batch entry. ''' ''' ''' The priority values flow from System.Messaging and ''' the priority is used by MSMQ to order the entries ''' in the queue. ''' Public Property Priority() As Messaging.MessagePriority Get Return mPriority End Get Set(ByVal Value As Messaging.MessagePriority) mPriority = Value End Set End Property ''' ''' Returns the MSMQ message ID of the batch entry. ''' ''' ''' This value is only valid after the batch entry ''' has been submitted to the queue. ''' Public ReadOnly Property MessageID() As String Get Return mMsgID End Get End Property Friend Sub SetMessageID(ByVal ID As String) mMsgID = ID End Sub ''' ''' Returns the date and time until which the ''' batch entry will be held before it can be run. ''' ''' ''' This value is optional. If it was provided, the batch ''' entry will be held until this date/time. At this date/time, ''' the entry will switch from Holding status to Pending ''' status and will be queued based on its priority along ''' with all other Pending entries. ''' Public Property HoldUntil() As Date Get Return mHoldUntil End Get Set(ByVal Value As Date) mHoldUntil = Value End Set End Property ''' ''' Returns the status of the batch entry. ''' ''' ''' ''' If the job is Holding, it means that the job ''' won't run until the data/time specified by ''' . ''' ''' If the job is Pending, it means that the job ''' will run as soon as possible, but that the queue ''' is busy. Pending entries are run in priority order based ''' on . ''' ''' If the job is Active, it means that the job is ''' currently being executed on the server. ''' ''' Public ReadOnly Property Status() As BatchEntryStatus Get If mHoldUntil > Now AndAlso mStatus = BatchEntryStatus.Pending Then Return BatchEntryStatus.Holding Else Return mStatus End If End Get End Property Friend Sub SetStatus(ByVal Status As BatchEntryStatus) mStatus = Status End Sub #Region " System.Object overrides " Public Overrides Function ToString() As String Return mUser & "@" & mMachine & ":" & mID.ToString End Function Public Overloads Function Equals(ByVal Info As BatchEntryInfo) As Boolean Return mID.Equals(Info.ID) End Function Public Overrides Function GetHashCode() As Integer Return mID.GetHashCode End Function #End Region End Class