public ListWorkQueueItemsResponse ListWorkQueueItems(ListWorkQueueItemsRequest request)
        {
            var criteria = new WorkQueueItemSearchCriteria();

            if (request.Statuses != null && request.Statuses.Count > 0)
            {
                criteria.Status.In(CollectionUtils.Map <EnumValueInfo, WorkQueueStatus>(request.Statuses, status => EnumUtils.GetEnumValue <WorkQueueStatus>(status)));
            }

            if (request.Types != null && request.Types.Count > 0)
            {
                criteria.Type.In(request.Types);
            }

            if (request.ScheduledStartTime.HasValue || request.ScheduledEndTime.HasValue)
            {
                if (request.ScheduledStartTime.HasValue && request.ScheduledEndTime.HasValue)
                {
                    criteria.ScheduledTime.Between(request.ScheduledStartTime.Value, request.ScheduledEndTime.Value);
                }
                else if (request.ScheduledStartTime.HasValue)
                {
                    criteria.ScheduledTime.MoreThanOrEqualTo(request.ScheduledStartTime.Value);
                }
                else if (request.ScheduledEndTime.HasValue)
                {
                    criteria.ScheduledTime.LessThanOrEqualTo(request.ScheduledEndTime.Value);
                }

                criteria.ScheduledTime.SortAsc(0);
            }
            else if (request.ProcessedStartTime.HasValue || request.ProcessedEndTime.HasValue)
            {
                if (request.ProcessedStartTime.HasValue && request.ProcessedEndTime.HasValue)
                {
                    criteria.ProcessedTime.Between(request.ProcessedStartTime.Value, request.ProcessedEndTime.Value);
                }
                else if (request.ProcessedStartTime.HasValue)
                {
                    criteria.CreationTime.MoreThanOrEqualTo(request.ProcessedStartTime.Value);
                }
                else if (request.ProcessedEndTime.HasValue)
                {
                    criteria.ProcessedTime.LessThanOrEqualTo(request.ProcessedEndTime.Value);
                }

                criteria.ProcessedTime.SortAsc(0);
            }
            else
            {
                criteria.CreationTime.SortAsc(0);
            }

            var assembler = new WorkQueueItemAssembler();

            return(new ListWorkQueueItemsResponse(
                       CollectionUtils.Map <WorkQueueItem, WorkQueueItemSummary>(
                           this.PersistenceContext.GetBroker <IWorkQueueItemBroker>().Find(criteria, request.Page),
                           item => assembler.CreateWorkQueueItemSummary(item, this.PersistenceContext))));
        }
Beispiel #2
0
		public ListWorkQueueItemsResponse ListWorkQueueItems(ListWorkQueueItemsRequest request)
		{
			var criteria = new WorkQueueItemSearchCriteria();

			if (request.Statuses != null && request.Statuses.Count > 0)
			{
				criteria.Status.In(CollectionUtils.Map<EnumValueInfo, WorkQueueStatus>(request.Statuses, status => EnumUtils.GetEnumValue<WorkQueueStatus>(status)));
			}

			if (request.Types != null && request.Types.Count > 0)
			{
				criteria.Type.In(request.Types);
			}

			if (request.ScheduledStartTime.HasValue || request.ScheduledEndTime.HasValue)
			{
				if (request.ScheduledStartTime.HasValue && request.ScheduledEndTime.HasValue)
				{
					criteria.ScheduledTime.Between(request.ScheduledStartTime.Value, request.ScheduledEndTime.Value);
				}
				else if (request.ScheduledStartTime.HasValue)
				{
					criteria.ScheduledTime.MoreThanOrEqualTo(request.ScheduledStartTime.Value);
				}
				else if (request.ScheduledEndTime.HasValue)
				{
					criteria.ScheduledTime.LessThanOrEqualTo(request.ScheduledEndTime.Value);
				}

				criteria.ScheduledTime.SortAsc(0);
			}
			else if (request.ProcessedStartTime.HasValue || request.ProcessedEndTime.HasValue)
			{
				if (request.ProcessedStartTime.HasValue && request.ProcessedEndTime.HasValue)
				{
					criteria.ProcessedTime.Between(request.ProcessedStartTime.Value, request.ProcessedEndTime.Value);
				}
				else if (request.ProcessedStartTime.HasValue)
				{
					criteria.CreationTime.MoreThanOrEqualTo(request.ProcessedStartTime.Value);
				}
				else if (request.ProcessedEndTime.HasValue)
				{
					criteria.ProcessedTime.LessThanOrEqualTo(request.ProcessedEndTime.Value);
				}

				criteria.ProcessedTime.SortAsc(0);
			}
			else
			{
				criteria.CreationTime.SortAsc(0);
			}

			var assembler = new WorkQueueItemAssembler();
			return new ListWorkQueueItemsResponse(
				CollectionUtils.Map<WorkQueueItem, WorkQueueItemSummary>(
					this.PersistenceContext.GetBroker<IWorkQueueItemBroker>().Find(criteria, request.Page),
					item => assembler.CreateWorkQueueItemSummary(item, this.PersistenceContext)));
		}