예제 #1
0
        /// <summary>
        ///     Get the first WorkItem where the request type matches <paramref name="request" /> and if its a
        ///     <see cref="WorkItemStudyRequest" />, the
        ///     Study Instance UID also matches.  The WorkItem must be Idle/Pending/InProgress status.
        /// </summary>
        /// <param name="request">The request to match </param>
        /// <returns>The matching WorkItem or null if none found.</returns>
        protected WorkItemData GetMatchingActiveWorkItem(WorkItemRequest request)
        {
            WorkItemData returnedItem = null;

            Platform.GetService(delegate(IWorkItemService s)
            {
                var response = s.Query(new WorkItemQueryRequest
                {
                    Type = request.WorkItemType,
                    //StudyInstanceUid =
                    //    request is WorkItemStudyRequest
                    //        ? (request as WorkItemStudyRequest).Study.StudyInstanceUid
                    //        : null
                });

                foreach (var relatedItem in response.Items)
                {
                    if (relatedItem.Status == WorkItemStatusEnum.Idle ||
                        relatedItem.Status == WorkItemStatusEnum.Pending ||
                        relatedItem.Status == WorkItemStatusEnum.InProgress)
                    {
                        returnedItem = relatedItem;
                        break;
                    }
                }
            });

            return(returnedItem);
        }
예제 #2
0
        protected void InsertRequest(WorkItemRequest request, WorkItemProgress progress)
        {
            WorkItemInsertResponse response = null;

            // Used for auditing purposes in the ShredHostService.
            if (string.IsNullOrEmpty(request.UserName))
            {
                request.UserName = GetUserName();
            }

            Request = request;

            Platform.GetService <IWorkItemService>(
                s => response = s.Insert(new WorkItemInsertRequest {
                Request = request, Progress = progress
            }));

            // TODO (CR Jun 2012): The passed-in WorkItem contract should not be updated;
            // it should be done by the service and a new instance returned, or something should be returned by this
            // method to let the caller decide what to do.

            if (response.Item == null)
            {
                WorkItem.Status = WorkItemStatusEnum.Deleted;
            }
            else
            {
                WorkItem = response.Item;
            }
        }