Esempio n. 1
0
 private void RemoveSendOperationInfo(SendOperationInfo info)
 {
     lock (_syncLock)
     {
         _sendOperations.Remove(info);
     }
 }
Esempio n. 2
0
        private DicomSendProgress GetProgressByMessageId(int dicomMessageId)
        {
            var list = GetSendOperationInfo(dicomMessageId);

            if (list.Count == 1)
            {
                SendOperationInfo sendOperation = CollectionUtils.FirstElement(list);
                var progress = sendOperation.WorkItemData.Progress as DicomSendProgress ?? new DicomSendProgress
                {
                    TotalImagesToSend = sendOperation.SubOperations
                };
                if (progress.TotalImagesToSend == 0)
                {
                    progress.TotalImagesToSend = sendOperation.SubOperations;
                }

                return(progress);
            }

            // TODO (CR Jun 2012): this actually happen?
            // (SW) - It won't actually happen with our client, but it could happen by other DICOM clients that have a list of UIDs to move.
            var aggregateProgress = new DicomSendProgress();

            foreach (var sendOperation in list)
            {
                var currentProgress = sendOperation.WorkItemData.Progress as DicomSendProgress;
                if (currentProgress == null)
                {
                    aggregateProgress.TotalImagesToSend += sendOperation.SubOperations;
                }
                else
                {
                    aggregateProgress.TotalImagesToSend    += currentProgress.TotalImagesToSend;
                    aggregateProgress.FailureSubOperations += currentProgress.FailureSubOperations;
                    aggregateProgress.SuccessSubOperations += currentProgress.SuccessSubOperations;
                    aggregateProgress.WarningSubOperations += currentProgress.WarningSubOperations;
                }
            }
            return(aggregateProgress);
        }
Esempio n. 3
0
	    private void RemoveSendOperationInfo(SendOperationInfo info)
		{
			lock(_syncLock)
			{
				_sendOperations.Remove(info);
			}
		}
Esempio n. 4
0
        private void UpdateProgress(WorkItemData workItem)
        {
            try
            {
                SendOperationInfo sendOperationInfo = GetSendOperationInfo(workItem);
                if (sendOperationInfo == null)
                {
                    return;
                }

                sendOperationInfo.WorkItemData = workItem;

                var progress = GetProgressByMessageId(sendOperationInfo.MessageId);

                var         msg = new DicomMessage();
                DicomStatus status;

                if (workItem.Status == WorkItemStatusEnum.Failed)
                {
                    sendOperationInfo.Complete = true;
                }
                else if (progress.RemainingSubOperations == 0 && workItem.Status != WorkItemStatusEnum.Pending)
                {
                    sendOperationInfo.Complete = true;
                }

                if (SendOperationsComplete(sendOperationInfo.MessageId))
                {
                    status = DicomStatuses.Success;

                    foreach (SendOperationInfo info in GetSendOperationInfo(sendOperationInfo.MessageId))
                    {
                        foreach (string sopInstanceUid in info.FailedSopInstanceUids)
                        {
                            msg.DataSet[DicomTags.FailedSopInstanceUidList].AppendString(sopInstanceUid);
                        }
                        if (workItem.Status == WorkItemStatusEnum.Canceled)
                        {
                            status = DicomStatuses.Cancel;
                        }
                        else if (workItem.Status == WorkItemStatusEnum.Failed)
                        {
                            status = DicomStatuses.QueryRetrieveUnableToProcess;
                        }
                        else if (progress.FailureSubOperations > 0 && status == DicomStatuses.Success)
                        {
                            status = DicomStatuses.QueryRetrieveSubOpsOneOrMoreFailures;
                        }
                    }
                }
                else
                {
                    status = DicomStatuses.Pending;
                    if ((progress.RemainingSubOperations % 5) != 0)
                    {
                        return;
                    }

                    // Only send a RSP every 5 to reduce network load
                }

                if (sendOperationInfo.Server.NetworkActive)
                {
                    sendOperationInfo.Server.SendCMoveResponse(sendOperationInfo.PresentationId,
                                                               sendOperationInfo.MessageId,
                                                               msg, status,
                                                               (ushort)progress.SuccessSubOperations,
                                                               (ushort)progress.RemainingSubOperations,
                                                               (ushort)progress.FailureSubOperations,
                                                               (ushort)progress.WarningSubOperations);
                }

                if (status != DicomStatuses.Pending || !sendOperationInfo.Server.NetworkActive)
                {
                    foreach (SendOperationInfo info in GetSendOperationInfo(sendOperationInfo.MessageId))
                    {
                        RemoveSendOperationInfo(info);
                    }
                }
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e, "Unexpected error processing C-MOVE Responses");
            }
        }