/// <summary> /// Adds the thread with the ID specified to the support queue with the ID specified /// </summary> /// <param name="threadID">The thread ID.</param> /// <param name="queueID">The queue ID.</param> /// <param name="userID">The user ID of the user causing this thread to be placed in the queue specified.</param> /// <param name="transactionToUse">The transaction to use. Is not null if there's a transaction in progress.</param> /// <remarks>first removes the thread from a queue if it's in a queue</remarks> public static void AddThreadToQueue(int threadID, int queueID, int userID, Transaction transactionToUse) { // first remove the thread from any queue it's in. RemoveThreadFromQueue(threadID, transactionToUse); // then add it to the queue specified. SupportQueueThreadEntity supportQueueThread = new SupportQueueThreadEntity(); supportQueueThread.ThreadID = threadID; supportQueueThread.QueueID = queueID; supportQueueThread.PlacedInQueueByUserID = userID; supportQueueThread.PlacedInQueueOn = DateTime.Now; if(transactionToUse != null) { // transaction in progress, add the entity to the transaction transactionToUse.Add(supportQueueThread); } supportQueueThread.Save(); }
/// <summary> /// Claims the thread specified for the user specified. As the thread can be in one queue at a time, it simply has to update the SupportQueueThread entity. /// </summary> /// <param name="userID">The user ID.</param> /// <param name="threadID">The thread ID.</param> public static void ClaimThread(int userID, int threadID) { SupportQueueThreadEntity supportQueueThread = new SupportQueueThreadEntity(); supportQueueThread.FetchUsingUCThreadID(threadID); if(supportQueueThread.IsNew) { // not found, return return; } // simply overwrite an existing claim if any. supportQueueThread.ClaimedByUserID = userID; supportQueueThread.ClaimedOn = DateTime.Now; // done, save it supportQueueThread.Save(); }
/// <summary> /// Releases the claim on the thread specified. As the thread can be in one queue at a time, it simply has to update the SupportQueueThread entity. /// </summary> /// <param name="threadID">The thread ID.</param> public static void ReleaseClaimOnThread(int threadID) { SupportQueueThreadEntity supportQueueThread = new SupportQueueThreadEntity(); supportQueueThread.FetchUsingUCThreadID(threadID); if(supportQueueThread.IsNew) { // not found, return return; } // simply reset an existing claim supportQueueThread.ClaimedByUserID = null; // nullable type, so set to null. supportQueueThread.ClaimedOn = null; // nullable type, so set to null. // done, save it supportQueueThread.Save(); }