/// <summary> /// Determines whether the specified media object undergoing the specified <paramref name="conversionType" /> /// is currently waiting to be processed in the media queue. /// </summary> /// <param name="mediaObjectId">The media object ID.</param> /// <param name="conversionType">Type of the conversion. If the parameter omitted, then a matching /// media object having any conversion type will cause the method to return <c>true</c>.</param> /// <returns>Returns <c>true</c> if the media object is currently being processed by the media queue; /// otherwise, <c>false</c>.</returns> private bool IsWaitingInQueue(int mediaObjectId, MediaQueueItemConversionType conversionType = MediaQueueItemConversionType.Unknown) { return(MediaQueueItemDictionary.Any(mq => mq.Value.MediaObjectId == mediaObjectId && mq.Value.Status == MediaQueueItemStatus.Waiting && (mq.Value.ConversionType == conversionType || conversionType == MediaQueueItemConversionType.Unknown) )); }
/// <summary> /// Determines whether the specified media object undergoing the specified <paramref name="conversionType" /> /// is currently being processed by the media queue or is waiting in the queue. /// </summary> /// <param name="mediaObjectId">The ID of the media object.</param> /// <param name="conversionType">Type of the conversion. If the parameter is omitted, then a matching /// media object having any conversion type will cause the method to return <c>true</c>.</param> /// <returns>Returns <c>true</c> if the media object is currently being processed by the media queue /// or is waiting in the queue; otherwise, <c>false</c>.</returns> public bool IsWaitingInQueueOrProcessing(int mediaObjectId, MediaQueueItemConversionType conversionType = MediaQueueItemConversionType.Unknown) { MediaQueueItem item = GetCurrentMediaQueueItem(); if ((item != null) && item.MediaObjectId == mediaObjectId && (item.ConversionType == conversionType || conversionType == MediaQueueItemConversionType.Unknown)) { return(true); } else { return(IsWaitingInQueue(mediaObjectId, conversionType)); } }
/// <summary> /// Adds the specified <paramref name="mediaObject" /> to the queue. It will be processed in a first-in, first-out /// order. If the media object is already waiting in the queue, no action is taken. /// </summary> /// <param name="mediaObject">The media object to be processed.</param> /// <param name="conversionType">Type of the conversion.</param> public void Add(IGalleryObject mediaObject, MediaQueueItemConversionType conversionType) { lock (_sharedLock) { var mqItem = new MediaQueueItem { MediaQueueId = int.MinValue, MediaObjectId = mediaObject.Id, Status = MediaQueueItemStatus.Waiting, ConversionType = conversionType, RotationAmount = mediaObject.CalculateNeededRotation(), StatusDetail = String.Empty, DateAdded = DateTime.Now, DateConversionStarted = null, DateConversionCompleted = null }; mqItem.Save(); //Factory.GetDataProvider().MediaQueue_Save(mediaQueueDto); MediaQueueItemDictionary.TryAdd(mqItem.MediaQueueId, mqItem); } }
/// <summary> /// Determines whether the specified media object undergoing the specified <paramref name="conversionType" /> /// is currently waiting to be processed in the media queue. /// </summary> /// <param name="mediaObjectId">The media object ID.</param> /// <param name="conversionType">Type of the conversion. If the parameter omitted, then a matching /// media object having any conversion type will cause the method to return <c>true</c>.</param> /// <returns>Returns <c>true</c> if the media object is currently being processed by the media queue; /// otherwise, <c>false</c>.</returns> private bool IsWaitingInQueue(int mediaObjectId, MediaQueueItemConversionType conversionType = MediaQueueItemConversionType.Unknown) { return MediaQueueItemDictionary.Any(mq => mq.Value.MediaObjectId == mediaObjectId && mq.Value.Status == MediaQueueItemStatus.Waiting && (mq.Value.ConversionType == conversionType || conversionType == MediaQueueItemConversionType.Unknown) ); }
/// <summary> /// Determines whether the specified media object undergoing the specified <paramref name="conversionType" /> /// is currently being processed by the media queue or is waiting in the queue. /// </summary> /// <param name="mediaObjectId">The ID of the media object.</param> /// <param name="conversionType">Type of the conversion. If the parameter is omitted, then a matching /// media object having any conversion type will cause the method to return <c>true</c>.</param> /// <returns>Returns <c>true</c> if the media object is currently being processed by the media queue /// or is waiting in the queue; otherwise, <c>false</c>.</returns> public bool IsWaitingInQueueOrProcessing(int mediaObjectId, MediaQueueItemConversionType conversionType = MediaQueueItemConversionType.Unknown) { MediaQueueItem item = GetCurrentMediaQueueItem(); if ((item != null) && item.MediaObjectId == mediaObjectId && (item.ConversionType == conversionType || conversionType == MediaQueueItemConversionType.Unknown)) return true; else return IsWaitingInQueue(mediaObjectId, conversionType); }