Exemplo n.º 1
0
        /// <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();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the support queue thread info entity and if specified, prefetches the user entity which claimed the related thread. 
        /// </summary>
        /// <param name="threadID">The thread ID.</param>
        /// <param name="prefetchClaimUser">if set to true it will </param>
        /// <returns>fetched entity if found, otherwise null</returns>
        public static SupportQueueThreadEntity GetSupportQueueThreadInfo(int threadID, bool prefetchClaimUser)
        {
            SupportQueueThreadEntity toReturn = new SupportQueueThreadEntity();
            PrefetchPath path = null;
            if(prefetchClaimUser)
            {
                // prefetch the user who claimed this thread (if any)
                path = new PrefetchPath((int)EntityType.SupportQueueThreadEntity);
                path.Add(SupportQueueThreadEntity.PrefetchPathClaimedByUser);
            }

            // now fetch the entity using the unique constraint on Thread by specifying the threadID passed in. Also specify the prefetch path (if any)
            toReturn.FetchUsingUCThreadID(threadID, path);
            if(toReturn.IsNew)
            {
                // not found
                return null;
            }
            return toReturn;
        }
Exemplo n.º 3
0
        /// <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();
        }
Exemplo n.º 4
0
 /// <summary> Retrieves the related entity of type 'SupportQueueThreadEntity', using a relation of type '1:1'</summary>
 /// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
 /// <returns>A fetched entity of type 'SupportQueueThreadEntity' which is related to this entity.</returns>
 public virtual SupportQueueThreadEntity GetSingleSupportQueueThread(bool forceFetch)
 {
     if( ( !_alreadyFetchedSupportQueueThread || forceFetch || _alwaysFetchSupportQueueThread) && !this.IsSerializing && !this.IsDeserializing && !this.InDesignMode )
     {
         bool performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.SupportQueueThreadEntityUsingThreadID);
         SupportQueueThreadEntity newEntity = new SupportQueueThreadEntity();
         bool fetchResult = false;
         if(performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingUCThreadID(this.ThreadID);
         }
         if(fetchResult)
         {
             newEntity = (SupportQueueThreadEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if(!_supportQueueThreadReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.SupportQueueThread = newEntity;
         _alreadyFetchedSupportQueueThread = fetchResult;
     }
     return _supportQueueThread;
 }