protected override void ProcessItem(Model.WorkQueue item)
{
LoadUids(item);
if (WorkQueueUidList.Count == 0)
{
// No UIDs associated with the WorkQueue item. Set the status back to idle
PostProcessing(item,
WorkQueueProcessorStatus.Idle,
WorkQueueProcessorDatabaseUpdate.ResetQueueState);
return;
}
XmlElement element = item.Data.DocumentElement;
string syntax = element.Attributes["syntax"].Value;
TransferSyntax compressSyntax = TransferSyntax.GetTransferSyntax(syntax);
if (compressSyntax == null)
{
item.FailureDescription =
String.Format("Invalid transfer syntax in compression WorkQueue item: {0}", element.Attributes["syntax"].Value);
Platform.Log(LogLevel.Error, "Error with work queue item {0}: {1}", item.GetKey(), item.FailureDescription);
base.PostProcessingFailure(item, WorkQueueProcessorFailureType.Fatal);
return;
}
if (Study == null)
{
item.FailureDescription =
String.Format("Compression item does not have a linked Study record");
Platform.Log(LogLevel.Error, "Error with work queue item {0}: {1}", item.GetKey(), item.FailureDescription);
base.PostProcessingFailure(item, WorkQueueProcessorFailureType.Fatal);
return;
}
Platform.Log(LogLevel.Info,
"Compressing study {0} for Patient {1} (PatientId:{2} A#:{3}) on partition {4} to {5}",
Study.StudyInstanceUid, Study.PatientsName, Study.PatientId,
Study.AccessionNumber, ServerPartition.Description, compressSyntax.Name);
IDicomCodecFactory[] codecs = DicomCodecRegistry.GetCodecFactories();
IDicomCodecFactory theCodecFactory = null;
foreach (IDicomCodecFactory codec in codecs)
if (codec.CodecTransferSyntax.Equals(compressSyntax))
{
theCodecFactory = codec;
break;
}
if (theCodecFactory == null)
{
item.FailureDescription = String.Format("Unable to find codec for compression: {0}", compressSyntax.Name);
Platform.Log(LogLevel.Error, "Error with work queue item {0}: {1}", item.GetKey(), item.FailureDescription);
base.PostProcessingFailure(item, WorkQueueProcessorFailureType.Fatal);
return;
}
if (!ProcessUidList(item, theCodecFactory))
PostProcessingFailure(item, WorkQueueProcessorFailureType.NonFatal);
else
{
Platform.Log(LogLevel.Info,
"Completed Compressing study {0} for Patient {1} (PatientId:{2} A#:{3}) on partition {4} to {5}",
Study.StudyInstanceUid, Study.PatientsName, Study.PatientId,
Study.AccessionNumber, ServerPartition.Description, compressSyntax.Name);
// Save a StudyHistory Record
SaveStudyHistory(compressSyntax.UidString);
if (compressSyntax.LossyCompressed)
UpdateStudyStatus(StorageLocation, StudyStatusEnum.OnlineLossy, compressSyntax);
else
UpdateStudyStatus(StorageLocation, StudyStatusEnum.OnlineLossless, compressSyntax);
PostProcessing(item,
WorkQueueProcessorStatus.Pending,
WorkQueueProcessorDatabaseUpdate.None); // batch processed, not complete
}
}