protected override void ProcessItem(Model.WorkQueue item)
		{
			Platform.CheckForNullReference(item, "item");
			Platform.CheckForNullReference(item.Data, "item.Data");

		    _reconcileQueueData = XmlUtils.Deserialize<ReconcileStudyWorkQueueData>(WorkQueueItem.Data);

			LoadUids(item);

            InitializeContext();

            SetupProcessor();
				
			if (WorkQueueUidList.Count == 0)
			{
                Platform.Log(LogLevel.Info,
                             "Completing study reconciliation for Study {0}, Patient {1} (PatientId:{2} A#:{3}) on Partition {4}, {5} objects",
                             Study.StudyInstanceUid, Study.PatientsName, Study.PatientId,
                             Study.AccessionNumber, ServerPartition.Description, WorkQueueUidList.Count);
                ExecuteCommands(true);
			}
			else
			{
				Platform.Log(LogLevel.Info,
				             "Reconciling study {0} for Patient {1} (PatientId:{2} A#:{3}) on Partition {4}, {5} objects",
				             Study.StudyInstanceUid, Study.PatientsName, Study.PatientId,
				             Study.AccessionNumber, ServerPartition.Description, WorkQueueUidList.Count);

				ExecuteCommands(false);
			}
		}
		protected override void ProcessItem(Model.WorkQueue item)
		{
			Platform.CheckForNullReference(item, "item");
			Platform.CheckForNullReference(item.Data, "item.Data");

			_reconcileQueueData = XmlUtils.Deserialize<ReconcileStudyWorkQueueData>(WorkQueueItem.Data);

			LoadUids(item);


			if (WorkQueueUidList.Count == 0)
			{
				DirectoryUtility.DeleteIfEmpty(_reconcileQueueData.StoragePath);

				Platform.Log(LogLevel.Info, "Reconcile Cleanup is completed. GUID={0}.", WorkQueueItem.GetKey());
				PostProcessing(WorkQueueItem,
					WorkQueueProcessorStatus.Complete,
					WorkQueueProcessorDatabaseUpdate.ResetQueueState);
			}
			else
			{
				Platform.Log(LogLevel.Info,
				             "Starting Cleanup of Reconcile Queue item for study {0} for Patient {1} (PatientId:{2} A#:{3}) on Partition {4}, {5} objects",
				             Study.StudyInstanceUid, Study.PatientsName, Study.PatientId,
				             Study.AccessionNumber, ServerPartition.Description,
				             WorkQueueUidList.Count);

				ProcessUidList();

				Platform.Log(LogLevel.Info, "Successfully complete Reconcile Cleanup. GUID={0}. {0} uids processed.", WorkQueueItem.GetKey(), WorkQueueUidList.Count);
				PostProcessing(WorkQueueItem,
					WorkQueueProcessorStatus.Pending,
					WorkQueueProcessorDatabaseUpdate.None);
			}
		}
示例#3
0
        protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
        {
            string seriesUid = _file.DataSet[DicomTags.SeriesInstanceUid].GetString(0, String.Empty);
            string sopUid = _file.DataSet[DicomTags.SopInstanceUid].GetString(0, String.Empty);
            ImageSetDescriptor imageSet = new ImageSetDescriptor(_file.DataSet);
            ReconcileStudyQueueDescription queueDesc = GetQueueEntryDescription(_storageLocation, _file);
			ReconcileStudyWorkQueueData detailsData = new ReconcileStudyWorkQueueData
			{
				StoragePath = _reconcileImageStorage.GetFolderPath(),
				Details = new ImageSetDetails(_file.DataSet)
			};
			detailsData.Details.InsertFile(_file);
			
            IInsertStudyIntegrityQueue broker = updateContext.GetBroker<IInsertStudyIntegrityQueue>();
            InsertStudyIntegrityQueueParameters parameters = new InsertStudyIntegrityQueueParameters
                         	{
                         		Description = queueDesc.ToString(),
                         		StudyInstanceUid = _storageLocation.StudyInstanceUid,
                         		ServerPartitionKey = _storageLocation.ServerPartition.Key,
                         		StudyStorageKey = _storageLocation.Key,
                         		StudyIntegrityReasonEnum = _reason,
                         		SeriesInstanceUid = seriesUid,
                         		SeriesDescription = sopUid,
                         		SopInstanceUid =
                         			_file.DataSet[DicomTags.SopInstanceUid].GetString(0,
                         			                                                  String
                         			                                                  	.
                         			                                                  	Empty),
                         		StudyData = XmlUtils.SerializeAsXmlDoc(imageSet),
                         		Details = XmlUtils.SerializeAsXmlDoc(detailsData),
                         		GroupID = _uidGroup,
                         		UidRelativePath =
                         			_reconcileImageStorage.GetSopRelativePath(
                         			_file.DataSet[DicomTags.SopInstanceUid].ToString())
                         	};

        	StudyIntegrityQueue item = broker.FindOne(parameters);
            if (item == null)
            {
                throw new ApplicationException("Unable to update reconcile queue");
            }

            _siqItem = item;
            if (!parameters.Inserted)
            {
                // Need to re-use the path that's already assigned for this entry
                ReconcileStudyWorkQueueData data = XmlUtils.Deserialize<ReconcileStudyWorkQueueData>(item.Details);
                data.Details.InsertFile(_file);

                XmlDocument updatedQueueDataXml = XmlUtils.SerializeAsXmlDoc(data);
                IStudyIntegrityQueueEntityBroker updateBroker = updateContext.GetBroker<IStudyIntegrityQueueEntityBroker>();
                StudyIntegrityQueueUpdateColumns columns = new StudyIntegrityQueueUpdateColumns
                                                           	{Details = updatedQueueDataXml};
            	updateBroker.Update(item.GetKey(), columns);
            }
        }