本文整理汇总了C#中ClearCanvas.ImageServer.Model.WorkQueueUid类的典型用法代码示例。如果您正苦于以下问题:C# WorkQueueUid类的具体用法?C# WorkQueueUid怎么用?C# WorkQueueUid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkQueueUid类属于ClearCanvas.ImageServer.Model命名空间,在下文中一共展示了WorkQueueUid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessWorkQueueUid
private bool ProcessWorkQueueUid(Model.WorkQueue item, WorkQueueUid sop, StudyXml studyXml, IDicomCodecFactory theCodecFactory)
{
Platform.CheckForNullReference(item, "item");
Platform.CheckForNullReference(sop, "sop");
Platform.CheckForNullReference(studyXml, "studyXml");
if (!studyXml.Contains(sop.SeriesInstanceUid, sop.SopInstanceUid))
{
// Uid was inserted but not in the study xml.
// Auto-recovery might have detect problem with that file and remove it from the study.
// Assume the study xml has been corrected and ignore the uid.
Platform.Log(LogLevel.Warn, "Skipping SOP {0} in series {1}. It is no longer part of the study.", sop.SopInstanceUid, sop.SeriesInstanceUid);
// Delete it out of the queue
DeleteWorkQueueUid(sop);
return true;
}
string basePath = Path.Combine(StorageLocation.GetStudyPath(), sop.SeriesInstanceUid);
basePath = Path.Combine(basePath, sop.SopInstanceUid);
string path;
if (sop.Extension != null)
path = basePath + "." + sop.Extension;
else
path = basePath + ServerPlatform.DicomFileExtension;
try
{
ProcessFile(item, sop, path, studyXml, theCodecFactory);
// WorkQueueUid has been deleted out by the processor
return true;
}
catch (Exception e)
{
if (e.InnerException != null && e.InnerException is DicomCodecUnsupportedSopException)
{
Platform.Log(LogLevel.Warn, e, "Instance not supported for compressor: {0}. Deleting WorkQueue entry for SOP {1}", e.Message, sop.SopInstanceUid);
item.FailureDescription = e.InnerException != null ? e.InnerException.Message : e.Message;
// Delete it out of the queue
DeleteWorkQueueUid(sop);
return false;
}
Platform.Log(LogLevel.Error, e, "Unexpected exception when compressing file: {0} SOP Instance: {1}", path, sop.SopInstanceUid);
item.FailureDescription = e.InnerException != null ? e.InnerException.Message : e.Message;
sop.FailureCount++;
UpdateWorkQueueUid(sop);
return false;
}
}
示例2: Insert
static public WorkQueueUid Insert(IUpdateContext update, WorkQueueUid entity)
{
var broker = update.GetBroker<IWorkQueueUidEntityBroker>();
var updateColumns = new WorkQueueUidUpdateColumns();
updateColumns.WorkQueueKey = entity.WorkQueueKey;
updateColumns.Failed = entity.Failed;
updateColumns.Duplicate = entity.Duplicate;
updateColumns.FailureCount = entity.FailureCount;
updateColumns.GroupID = entity.GroupID;
updateColumns.RelativePath = entity.RelativePath;
updateColumns.Extension = entity.Extension;
updateColumns.SeriesInstanceUid = entity.SeriesInstanceUid;
updateColumns.SopInstanceUid = entity.SopInstanceUid;
WorkQueueUid newEntity = broker.Insert(updateColumns);
return newEntity;
}
示例3: ScheduleReconcile
/// <summary>
/// Schedules a reconciliation for the specified <see cref="DicomFile"/>
/// </summary>
/// <param name="context"></param>
/// <param name="file"></param>
/// <param name="uid"></param>
private static void ScheduleReconcile(SopInstanceProcessorContext context, DicomFile file, WorkQueueUid uid)
{
ImageReconciler reconciler = new ImageReconciler(context);
reconciler.ScheduleReconcile(file, StudyIntegrityReasonEnum.InconsistentData, uid);
}
示例4: ProcessFile
/// <summary>
/// Process a specific DICOM file related to a <see cref="WorkQueue"/> request.
/// </summary>
/// <remarks>
/// <para>
/// On success and if <see cref="uid"/> is set, the <see cref="WorkQueueUid"/> field is deleted.
/// </para>
/// </remarks>
/// <param name="stream">The <see cref="StudyXml"/> file to update with information from the file.</param>
/// <param name="group">A group the sop is associated with.</param>
/// <param name="file">The file to process.</param>
/// <param name="compare">Flag to compare the demographics of <see cref="file"/> with the demographics in the database</param>
/// <param name="retry">Flag telling if the item should be retried on failure. Note that if the item is a duplicate, the WorkQueueUid item is not failed. </param>
/// <param name="uid">An optional WorkQueueUid associated with the entry, that will be deleted upon success or failed on failure.</param>
/// <param name="deleteFile">An option file to delete as part of the process</param>
/// <param name="sopType">Flag telling if the SOP is a new or updated SOP</param>
/// <exception cref="Exception"/>
/// <exception cref="DicomDataException"/>
public ProcessingResult ProcessFile(string group, DicomFile file, StudyXml stream, bool compare, bool retry, WorkQueueUid uid, string deleteFile, SopInstanceProcessorSopType sopType)
{
Platform.CheckForNullReference(file, "file");
try
{
CheckDataLength(file);
_instanceStats.ProcessTime.Start();
ProcessingResult result = new ProcessingResult
{
Status = ProcessingStatus.Success
};
using (ServerCommandProcessor processor = new ServerCommandProcessor("Process File"))
{
SopInstanceProcessorContext processingContext = new SopInstanceProcessorContext(processor,
_context.StorageLocation, group);
if (EnforceNameRules)
{
_patientNameRules.Apply(file);
}
if (compare && ShouldReconcile(_context.StorageLocation, file))
{
ScheduleReconcile(processingContext, file, uid);
result.Status = ProcessingStatus.Reconciled;
}
else
{
InsertInstance(file, stream, uid, deleteFile,sopType);
result.Status = ProcessingStatus.Success;
}
}
_instanceStats.ProcessTime.End();
if (_context.SopProcessedRulesEngine.Statistics.LoadTime.IsSet)
_instanceStats.SopRulesLoadTime.Add(_context.SopProcessedRulesEngine.Statistics.LoadTime);
if (_context.SopProcessedRulesEngine.Statistics.ExecutionTime.IsSet)
_instanceStats.SopEngineExecutionTime.Add(_context.SopProcessedRulesEngine.Statistics.ExecutionTime);
_context.SopProcessedRulesEngine.Statistics.Reset();
//TODO: Should throw exception if result is failed?
return result;
}
catch (Exception e)
{
// If its a duplicate, ignore the exception, and just throw it
if (deleteFile != null && (e is InstanceAlreadyExistsException
|| e.InnerException is InstanceAlreadyExistsException))
throw;
if (uid != null)
FailUid(uid, retry);
throw;
}
}
示例5: OnProcessUidEnd
/// <summary>
/// Called after the specified <see cref="WorkQueueUid"/> has been processed
/// </summary>
/// <param name="item">The <see cref="WorkQueue"/> item being processed</param>
/// <param name="uid">The <see cref="WorkQueueUid"/> being processed</param>
protected virtual void OnProcessUidEnd(Model.WorkQueue item, WorkQueueUid uid)
{
Platform.CheckForNullReference(item, "item");
Platform.CheckForNullReference(uid, "uid");
if (uid.Duplicate)
{
String dupPath = ServerHelper.GetDuplicateUidPath(StorageLocation, uid);
// Delete the container if it's empty
var f = new FileInfo(dupPath);
if (f.Directory!=null && DirectoryUtility.DeleteIfEmpty(f.Directory.FullName))
{
DirectoryUtility.DeleteIfEmpty(ServerHelper.GetDuplicateGroupPath(StorageLocation, uid));
}
}
}
示例6: RemoveWorkQueueUid
private static void RemoveWorkQueueUid(WorkQueueUid uid, string fileToDelete)
{
using (var processor = new ServerCommandProcessor("Remove Work Queue Uid"))
{
processor.AddCommand(new DeleteWorkQueueUidCommand(uid));
if (String.IsNullOrEmpty(fileToDelete) == false)
{
processor.AddCommand(new FileDeleteCommand(fileToDelete, true));
}
if (!processor.Execute())
{
String error = String.Format("Unable to delete Work Queue Uid {0}: {1}", uid.Key, processor.FailureReason);
Platform.Log(LogLevel.Error, error);
throw new ApplicationException(error, processor.FailureException);
}
}
}
示例7: ProcessWorkQueueUid
/// <summary>
/// ProcessSavedFile a specified <see cref="WorkQueueUid"/>
/// </summary>
/// <param name="item">The <see cref="WorkQueue"/> item being processed</param>
/// <param name="sop">The <see cref="WorkQueueUid"/> being processed</param>
/// <param name="studyXml">The <see cref="StudyXml"/> object for the study being processed</param>
/// <returns>true if the <see cref="WorkQueueUid"/> is successfully processed. false otherwise</returns>
protected virtual bool ProcessWorkQueueUid(Model.WorkQueue item, WorkQueueUid sop, StudyXml studyXml)
{
Platform.CheckForNullReference(item, "item");
Platform.CheckForNullReference(sop, "sop");
Platform.CheckForNullReference(studyXml, "studyXml");
OnProcessUidBegin(item, sop);
string path = null;
try
{
if (sop.Duplicate && sop.Extension != null)
{
path = ServerHelper.GetDuplicateUidPath(StorageLocation, sop);
var file = new DicomFile(path);
file.Load();
InstancePreProcessingResult result = PreProcessFile(sop, file);
if (false ==file.DataSet[DicomTags.StudyInstanceUid].ToString().Equals(StorageLocation.StudyInstanceUid)
|| result.DiscardImage)
{
RemoveWorkQueueUid(sop, null);
}
else
{
var duplicateResult = ProcessDuplicate(file, sop, studyXml);
if (duplicateResult.ActionTaken == DuplicateProcessResultAction.Delete || duplicateResult.ActionTaken == DuplicateProcessResultAction.Accept)
{
// make sure the folder is also deleted if it's empty
string folder = Path.GetDirectoryName(path);
String reconcileRootFolder = ServerHelper.GetDuplicateFolderRootPath(StorageLocation);
DirectoryUtility.DeleteIfEmpty(folder, reconcileRootFolder);
}
}
}
else
{
try
{
path = StorageLocation.GetSopInstancePath(sop.SeriesInstanceUid, sop.SopInstanceUid);
var file = new DicomFile(path);
file.Load();
InstancePreProcessingResult result = PreProcessFile(sop, file);
if (false == file.DataSet[DicomTags.StudyInstanceUid].ToString().Equals(StorageLocation.StudyInstanceUid)
|| result.DiscardImage)
{
RemoveWorkQueueUid(sop, path);
}
else
{
ProcessFile(sop, file, studyXml, !result.AutoReconciled);
}
}
catch (DicomException ex)
{
// bad file. Remove it from the filesystem and the queue
RemoveBadDicomFile(path, ex.Message);
DeleteWorkQueueUid(sop);
return false;
}
}
return true;
}
catch (StudyIsNearlineException)
{
// handled by caller
throw;
}
catch (Exception e)
{
Platform.Log(LogLevel.Error, e, "Unexpected exception when processing file: {0} SOP Instance: {1}", path, sop.SopInstanceUid);
item.FailureDescription = e.InnerException != null ?
String.Format("{0}:{1}", e.GetType().Name, e.InnerException.Message) : String.Format("{0}:{1}", e.GetType().Name, e.Message);
//No longer needed. Update was moved into the SopInstanceProcessor
//sop.FailureCount++;
//UpdateWorkQueueUid(sop);
return false;
}
finally
{
OnProcessUidEnd(item, sop);
}
}
示例8: CreateDuplicateSIQEntry
void CreateDuplicateSIQEntry(WorkQueueUid uid, DicomFile file, List<DicomAttributeComparisonResult> differences)
{
Platform.Log(LogLevel.Info, "Duplicate SOP is different from existing copy. Creating duplicate SIQ entry. SOP: {0}", uid.SopInstanceUid);
using (var processor = new ServerCommandProcessor("Create Duplicate SIQ Entry"))
{
var insertCommand = new InsertOrUpdateEntryCommand(
uid.GroupID, StorageLocation, file,
ServerHelper.GetDuplicateGroupPath(StorageLocation, uid),
string.IsNullOrEmpty(uid.RelativePath)
? Path.Combine(StorageLocation.StudyInstanceUid, uid.SopInstanceUid + "." + uid.Extension)
: uid.RelativePath,
differences);
processor.AddCommand(insertCommand);
processor.AddCommand(new DeleteWorkQueueUidCommand(uid));
processor.Execute();
}
}
示例9: RemoveExistingImage
private void RemoveExistingImage(WorkQueueUid uid)
{
string path = StorageLocation.GetSopInstancePath(uid.SeriesInstanceUid, uid.SopInstanceUid);
if (!File.Exists(path))
return;
StudyXml studyXml = StorageLocation.LoadStudyXml();
var file = new DicomFile(path);
file.Load(DicomReadOptions.DoNotStorePixelDataInDataSet | DicomReadOptions.Default); // don't need to load pixel data cause we will delete it
#if DEBUG
int originalInstanceCountInXml = studyXml.NumberOfStudyRelatedInstances;
int originalStudyInstanceCount = Study.NumberOfStudyRelatedInstances;
int originalSeriesInstanceCount = Study.Series[uid.SeriesInstanceUid].NumberOfSeriesRelatedInstances;
#endif
using (var processor = new ServerCommandProcessor("Delete Existing Image"))
{
var seriesInstanceUid = file.DataSet[DicomTags.SeriesInstanceUid].ToString();
var sopInstanceUid = file.DataSet[DicomTags.SopInstanceUid].ToString();
processor.AddCommand(new FileDeleteCommand(path,true));
processor.AddCommand(new RemoveInstanceFromStudyXmlCommand(StorageLocation, studyXml, seriesInstanceUid, sopInstanceUid));
processor.AddCommand(new UpdateInstanceCountCommand(StorageLocation, seriesInstanceUid,sopInstanceUid));
if (!processor.Execute())
{
throw new ApplicationException(String.Format("Unable to remove existing image {0}", file.Filename), processor.FailureException);
}
}
#if DEBUG
Debug.Assert(!File.Exists(path));
Debug.Assert(studyXml.NumberOfStudyRelatedInstances == originalInstanceCountInXml - 1);
Debug.Assert(Study.Load(Study.Key).NumberOfStudyRelatedInstances == originalStudyInstanceCount - 1);
Debug.Assert(Study.Load(Study.Key).Series[uid.SeriesInstanceUid].NumberOfSeriesRelatedInstances == originalSeriesInstanceCount - 1);
#endif
}
示例10: AddDuplicateToStudy
private void AddDuplicateToStudy(DicomFile duplicateDicomFile, WorkQueueUid uid, ProcessDuplicateAction action)
{
var context = new StudyProcessorContext(StorageLocation, WorkQueueItem);
var sopInstanceProcessor = new SopInstanceProcessor(context) { EnforceNameRules = true };
string group = uid.GroupID ?? ServerHelper.GetUidGroup(duplicateDicomFile, ServerPartition, WorkQueueItem.InsertTime);
StudyXml studyXml = StorageLocation.LoadStudyXml();
int originalInstanceCount = studyXml.NumberOfStudyRelatedInstances;
bool compare = action != ProcessDuplicateAction.OverwriteAsIs;
// NOTE: "compare" has no effect for OverwriteUseExisting or OverwriteUseDuplicate
// because in both cases, the study and the duplicates are modified to be the same.
ProcessingResult result = sopInstanceProcessor.ProcessFile(group, duplicateDicomFile, studyXml, compare, true, uid, duplicateDicomFile.Filename, SopInstanceProcessorSopType.UpdatedSop);
if (result.Status == ProcessingStatus.Reconciled)
{
throw new ApplicationException("Unexpected status of Reconciled image in duplicate handling!");
}
Debug.Assert(studyXml.NumberOfStudyRelatedInstances == originalInstanceCount + 1);
Debug.Assert(File.Exists(StorageLocation.GetSopInstancePath(uid.SeriesInstanceUid, uid.SopInstanceUid)));
}
示例11: OverwriteExistingInstance
private void OverwriteExistingInstance(WorkQueueUid uid, ProcessDuplicateAction action)
{
if (ExistsInStudy(uid))
{
// remove the existing image and update the count
RemoveExistingImage(uid);
}
DicomFile duplicateDicomFile = LoadDuplicateDicomFile(uid, false);
PreprocessDuplicate(duplicateDicomFile, action);
AddDuplicateToStudy(duplicateDicomFile, uid, action);
}
示例12: ExistsInStudy
private bool ExistsInStudy(WorkQueueUid uid)
{
String path = StorageLocation.GetSopInstancePath(uid.SeriesInstanceUid, uid.SopInstanceUid);
if (File.Exists(path))
return true;
// check the study xml
StudyXml studyXml = StorageLocation.LoadStudyXml();
return studyXml[uid.SeriesInstanceUid] != null &&
studyXml[uid.SeriesInstanceUid][uid.SopInstanceUid] != null;
}
示例13: DeleteDuplicate
private void DeleteDuplicate(WorkQueueUid uid)
{
using (ServerCommandProcessor processor = new ServerCommandProcessor("Delete Received Duplicate"))
{
FileInfo duplicateFile = GetDuplicateSopFile(uid);
processor.AddCommand(new FileDeleteCommand(duplicateFile.FullName,true));
processor.AddCommand(new DeleteWorkQueueUidCommand(uid));
if (!processor.Execute())
{
throw new ApplicationException(processor.FailureReason, processor.FailureException);
}
Platform.Log(ServerPlatform.InstanceLogLevel, "Discard duplicate SOP {0} in {1}", uid.SopInstanceUid, duplicateFile.FullName);
}
}
示例14: ProcessUid
private void ProcessUid(WorkQueueUid uid)
{
switch(_processDuplicateEntry.QueueData.Action)
{
case ProcessDuplicateAction.Delete:
DeleteDuplicate(uid);
break;
case ProcessDuplicateAction.OverwriteUseDuplicates:
OverwriteExistingInstance(uid, ProcessDuplicateAction.OverwriteUseDuplicates);
break;
case ProcessDuplicateAction.OverwriteUseExisting:
OverwriteExistingInstance(uid, ProcessDuplicateAction.OverwriteUseExisting);
break;
case ProcessDuplicateAction.OverwriteAsIs:
OverwriteExistingInstance(uid, ProcessDuplicateAction.OverwriteAsIs);
break;
default:
throw new NotSupportedException(
String.Format("Not supported action: {0}", _processDuplicateEntry.QueueData.Action));
}
}
示例15: OverwriteAndUpdateDuplicate
private ProcessDuplicateResult OverwriteAndUpdateDuplicate(DicomFile dupFile, WorkQueueUid uid, StudyXml studyXml)
{
Platform.Log(LogLevel.Info, "Overwriting duplicate SOP {0}", uid.SopInstanceUid);
var result = new ProcessDuplicateResult();
result.ActionTaken = DuplicateProcessResultAction.Accept;
using (var processor = new ServerCommandProcessor("Overwrite duplicate instance"))
{
var destination = Context.StorageLocation.GetSopInstancePath(uid.SeriesInstanceUid, uid.SopInstanceUid);
processor.AddCommand(new RenameFileCommand(dupFile.Filename, destination, false));
// Do so that the FileSize calculation inInsertStudyXmlCommand works
dupFile.Filename = destination;
// Update the StudyStream object
var insertStudyXmlCommand = new InsertStudyXmlCommand(dupFile, studyXml, Context.StorageLocation);
processor.AddCommand(insertStudyXmlCommand);
// Ideally we don't need to insert the instance into the database since it's a duplicate.
// However, we need to do so to ensure the Study record is recreated if we are dealing with an orphan study.
// For other cases, this will cause the instance count in the DB to be out of sync with the filesystem.
// But it will be corrected at the end of the processing when the study verification is executed.
processor.AddCommand(new UpdateInstanceCommand(Context.StorageLocation.ServerPartition,Context.StorageLocation,dupFile));
processor.AddCommand(new DeleteWorkQueueUidCommand(uid));
if (!processor.Execute())
{
EventManager.FireEvent(this, new FailedUpdateSopEventArgs { File = dupFile, ServerPartitionEntry = Context.StorageLocation.ServerPartition, WorkQueueUidEntry = uid, WorkQueueEntry = WorkQueueItem, FileLength = (ulong)insertStudyXmlCommand.FileSize, FailureMessage = processor.FailureReason });
// cause the item to fail
throw new Exception(string.Format("Error occurred when trying to overwrite duplicate in the filesystem."), processor.FailureException);
}
EventManager.FireEvent(this, new UpdateSopEventArgs { File = dupFile, ServerPartitionEntry = Context.StorageLocation.ServerPartition, WorkQueueUidEntry = uid, WorkQueueEntry = WorkQueueItem, FileLength = (ulong)insertStudyXmlCommand.FileSize });
}
return result;
}