Beispiel #1
0
        public void ImportFileList(List <string> fileList, BadFileBehaviourEnum badFileBehaviour, FileImportBehaviourEnum fileImportBehavior)
        {
            var request = new ImportFilesRequest
            {
                FilePaths           = fileList,
                Recursive           = true,
                BadFileBehaviour    = badFileBehaviour,
                FileImportBehaviour = fileImportBehavior
            };

            try
            {
                InsertRequest(request, new ImportFilesProgress());
            }
            catch (Exception ex)
            {
                Exception = ex;
                throw;
            }
        }
		/// <summary>
		/// Imports the specified <see cref="DicomMessageBase"/> object into the system.
		/// The object will be inserted into the <see cref="WorkItem"/> for processing
		/// </summary>
		/// <param name="message">The DICOM object to be imported.</param>
		/// <param name="badFileBehavior"> </param>
		/// <param name="fileImportBehaviour"> </param>
		/// <returns>An instance of <see cref="DicomProcessingResult"/> that describes the result of the processing.</returns>
		/// <exception cref="DicomDataException">Thrown when the DICOM object contains invalid data</exception>
		public DicomProcessingResult Import(DicomMessageBase message, BadFileBehaviourEnum badFileBehavior, FileImportBehaviourEnum fileImportBehaviour)
		{
			Platform.CheckForNullReference(message, "message");
			String studyInstanceUid = message.DataSet[DicomTags.StudyInstanceUid].GetString(0, string.Empty);
			String seriesInstanceUid = message.DataSet[DicomTags.SeriesInstanceUid].GetString(0, string.Empty);
			String sopInstanceUid = message.DataSet[DicomTags.SopInstanceUid].GetString(0, string.Empty);
			String accessionNumber = message.DataSet[DicomTags.AccessionNumber].GetString(0, string.Empty);
			String patientsName = message.DataSet[DicomTags.PatientsName].GetString(0, string.Empty);
			String patientId = message.DataSet[DicomTags.PatientId].GetString(0, string.Empty);

			var result = new DicomProcessingResult
			             {
				             Successful = true,
				             StudyInstanceUid = studyInstanceUid,
				             SeriesInstanceUid = seriesInstanceUid,
				             SopInstanceUid = sopInstanceUid,
				             AccessionNumber = accessionNumber,
				             PatientsName = patientsName,
				             PatientId = patientId,
			             };

			WorkItem workItem;
			lock (_context.StudyWorkItemsSyncLock)
				_context.StudyWorkItems.TryGetValue(studyInstanceUid, out workItem);

			try
			{
				Validate(message);
			}
			catch (DicomDataException e)
			{
				result.SetError(DicomStatuses.ProcessingFailure, e.Message);
				AuditFailure(result);
				return result;
			}

			if (workItem != null)
			{
				if (workItem.Status == WorkItemStatusEnum.Deleted || workItem.Status == WorkItemStatusEnum.DeleteInProgress || workItem.Status == WorkItemStatusEnum.Canceled || workItem.Status == WorkItemStatusEnum.Canceling)
				{
					// TODO Marmot (CR June 2012): not DicomStatuses.Cancel?
					result.SetError(DicomStatuses.StorageStorageOutOfResources, "Canceled by user");
					AuditFailure(result);
					return result;
				}
			}

			if (LocalStorageMonitor.IsMaxUsedSpaceExceeded)
			{
				//The input to this method is a VALID DICOM file, and we know we should have stored it if it weren't for
				//the fact that we're out of disk space. So, we insert the work item UID anyway, knowing that it'll cause
				//the work item to fail. In fact, that's why we're doing it.
				result.SetError(DicomStatuses.StorageStorageOutOfResources, string.Format("Import failed, disk space usage exceeded"));
				InsertFailedWorkItemUid(workItem, message, result);

				_context.FatalError = true;
				AuditFailure(result);
				return result;
			}

			Process(message, fileImportBehaviour, workItem, result);

			if (result.DicomStatus != DicomStatuses.Success)
			{
				if (result.RetrySuggested)
				{
					Platform.Log(LogLevel.Warn,
					             "Failure importing file with retry suggested, retrying Import of file: {0}",
					             sopInstanceUid);

					Process(message, fileImportBehaviour, workItem, result);
				}
			}

			if (result.DicomStatus != DicomStatuses.Success)
			{
				//The input to this method is a VALID DICOM file, and we know we should have stored it if it weren't for
				//the fact that we're out of disk space. So, we insert the work item UID anyway, knowing that it'll cause
				//the work item to fail. In fact, that's why we're doing it.
				InsertFailedWorkItemUid(workItem, message, result);

				AuditFailure(result);
			}

			return result;
		}
Beispiel #3
0
        public void ImportFileList(List<string> fileList,BadFileBehaviourEnum badFileBehaviour, FileImportBehaviourEnum fileImportBehavior )
        {

            var request = new ImportFilesRequest
            {
                FilePaths = fileList,
                Recursive = true,
                BadFileBehaviour = badFileBehaviour,
                FileImportBehaviour = fileImportBehavior
            };

            try
            {
                InsertRequest(request, new ImportFilesProgress());
            }
            catch (Exception ex)
            {
                Exception = ex;
                throw;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Imports the specified <see cref="DicomMessageBase"/> object into the system.
        /// The object will be inserted into the <see cref="WorkItem"/> for processing
        /// </summary>
        /// <param name="message">The DICOM object to be imported.</param>
        /// <param name="badFileBehavior"> </param>
        /// <param name="fileImportBehaviour"> </param>
        /// <returns>An instance of <see cref="DicomProcessingResult"/> that describes the result of the processing.</returns>
        /// <exception cref="DicomDataException">Thrown when the DICOM object contains invalid data</exception>
        public DicomProcessingResult Import(DicomMessageBase message, BadFileBehaviourEnum badFileBehavior, FileImportBehaviourEnum fileImportBehaviour)
        {
            Platform.CheckForNullReference(message, "message");
            String studyInstanceUid = message.DataSet[DicomTags.StudyInstanceUid].GetString(0, string.Empty);
            String seriesInstanceUid = message.DataSet[DicomTags.SeriesInstanceUid].GetString(0, string.Empty);
            String sopInstanceUid = message.DataSet[DicomTags.SopInstanceUid].GetString(0, string.Empty);
            String accessionNumber = message.DataSet[DicomTags.AccessionNumber].GetString(0, string.Empty);
            String patientsName = message.DataSet[DicomTags.PatientsName].GetString(0, string.Empty);
            String patientId = message.DataSet[DicomTags.PatientId].GetString(0, string.Empty);

            var result = new DicomProcessingResult
            {
                Successful = true,
                StudyInstanceUid = studyInstanceUid,
                SeriesInstanceUid = seriesInstanceUid,
                SopInstanceUid = sopInstanceUid,
                AccessionNumber = accessionNumber,
                PatientsName = patientsName,
                PatientId = patientId,
            };

            WorkItem workItem;
            lock (_context.StudyWorkItemsSyncLock)
                _context.StudyWorkItems.TryGetValue(studyInstanceUid, out workItem);
            
        	try
			{
				Validate(message);
			}
			catch (DicomDataException e)
			{
				result.SetError(DicomStatuses.ProcessingFailure, e.Message);
                AuditFailure(result);
                return result;
			}

            if (workItem != null)
            {
                if (workItem.Status == WorkItemStatusEnum.Deleted || workItem.Status == WorkItemStatusEnum.DeleteInProgress || workItem.Status == WorkItemStatusEnum.Canceled || workItem.Status == WorkItemStatusEnum.Canceling)
                {
                    // TODO Marmot (CR June 2012): not DicomStatuses.Cancel?
                    result.SetError(DicomStatuses.StorageStorageOutOfResources, "Canceled by user");
                    AuditFailure(result);
                    return result;                       
                }
            }

            if (LocalStorageMonitor.IsMaxUsedSpaceExceeded)
            {
                //The input to this method is a VALID DICOM file, and we know we should have stored it if it weren't for
                //the fact that we're out of disk space. So, we insert the work item UID anyway, knowing that it'll cause
                //the work item to fail. In fact, that's why we're doing it.
                result.SetError(DicomStatuses.StorageStorageOutOfResources, string.Format("Import failed, disk space usage exceeded"));
                InsertFailedWorkItemUid(workItem, message, result);

                _context.FatalError = true;
                AuditFailure(result);
                return result;
            }

            Process(message, fileImportBehaviour, workItem, result);

            if (result.DicomStatus != DicomStatuses.Success)
            {
                if (result.RetrySuggested)
                {
                    Platform.Log(LogLevel.Warn,
                                 "Failure importing file with retry suggested, retrying Import of file: {0}",
                                 sopInstanceUid);

                    Process(message, fileImportBehaviour, workItem, result);
                }
            }

            if (result.DicomStatus != DicomStatuses.Success)
            {
                //The input to this method is a VALID DICOM file, and we know we should have stored it if it weren't for
                //the fact that we're out of disk space. So, we insert the work item UID anyway, knowing that it'll cause
                //the work item to fail. In fact, that's why we're doing it.
                InsertFailedWorkItemUid(workItem, message, result);

                AuditFailure(result);
            }

            return result;
        }