/// <summary> /// Finds all <see cref="WorkQueueUids"/> this item. /// </summary> /// <param name="item"></param> /// <returns></returns> public static IList<WorkQueueUid> LoadAllWorkQueueUid(this WorkQueue item) { using (var readctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IWorkQueueUidEntityBroker broker = readctx.GetBroker<IWorkQueueUidEntityBroker>(); var criteria = new WorkQueueUidSelectCriteria(); criteria.WorkQueueKey.EqualTo(item.Key); return broker.Find(criteria); } }
/// <summary> /// Delete the Work Queue record from the system. /// </summary> /// <param name="context"></param> /// <returns></returns> public bool Delete(IPersistenceContext context) { IWorkQueueUidEntityBroker workQueueUidBroker = context.GetBroker<IWorkQueueUidEntityBroker>(); WorkQueueUidSelectCriteria criteria = new WorkQueueUidSelectCriteria(); criteria.WorkQueueKey.EqualTo(GetKey()); workQueueUidBroker.Delete(criteria); IWorkQueueEntityBroker workQueueBroker = context.GetBroker<IWorkQueueEntityBroker>(); return workQueueBroker.Delete(GetKey()); }
private static WorkQueueDetails CreateGeneralWorkQueueItemDetails(Model.WorkQueue item) { var detail = new WorkQueueDetails(); detail.Key = item.Key; detail.ScheduledDateTime = item.ScheduledTime; detail.ExpirationTime = item.ExpirationTime; detail.InsertTime = item.InsertTime; detail.FailureCount = item.FailureCount; detail.Type = item.WorkQueueTypeEnum; detail.Status = item.WorkQueueStatusEnum; detail.Priority = item.WorkQueuePriorityEnum; detail.FailureDescription = item.FailureDescription; detail.ServerDescription = item.ProcessorID; StudyStorageLocation storage = WorkQueueController.GetLoadStorageLocation(item); detail.StorageLocationPath = storage.GetStudyPath(); // Fetch UIDs var wqUidsAdaptor = new WorkQueueUidAdaptor(); var uidCriteria = new WorkQueueUidSelectCriteria(); uidCriteria.WorkQueueKey.EqualTo(item.GetKey()); IList<WorkQueueUid> uids = wqUidsAdaptor.Get(uidCriteria); var mapSeries = new Hashtable(); foreach (WorkQueueUid uid in uids) { if (mapSeries.ContainsKey(uid.SeriesInstanceUid) == false) mapSeries.Add(uid.SeriesInstanceUid, uid.SopInstanceUid); } detail.NumInstancesPending = uids.Count; detail.NumSeriesPending = mapSeries.Count; // Fetch the study and patient info var ssAdaptor = new StudyStorageAdaptor(); StudyStorage storages = ssAdaptor.Get(item.StudyStorageKey); var studyAdaptor = new StudyAdaptor(); var studycriteria = new StudySelectCriteria(); studycriteria.StudyInstanceUid.EqualTo(storages.StudyInstanceUid); studycriteria.ServerPartitionKey.EqualTo(item.ServerPartitionKey); Study study = studyAdaptor.GetFirst(studycriteria); // Study may not be available until the images are processed. if (study != null) { var studyAssembler = new StudyDetailsAssembler(); detail.Study = studyAssembler.CreateStudyDetail(study); } return detail; }
/// <summary> /// Checks for the existinance of a SOP for a given Study in the <see cref="WorkQueue"/> for a <see cref="WorkQueueTypeEnum.ReconcileStudy"/>. /// </summary> /// <param name="studyStorageKey">The StudyStorage primary key</param> /// <param name="seriesInstanceUid">The Series Instance Uid of the Sop</param> /// <param name="sopInstanceUid">The Sop Instance to look for</param> /// <returns>true if an entry exists, false if it doesn't</returns> static public bool WorkQueueUidExists(ServerEntityKey studyStorageKey, string seriesInstanceUid, string sopInstanceUid) { Platform.CheckForNullReference(studyStorageKey, "studyStorageKey"); using (var scope = new ServerExecutionContext()) { var broker = scope.PersistenceContext.GetBroker<IWorkQueueEntityBroker>(); var uidSelectCriteria = new WorkQueueUidSelectCriteria(); uidSelectCriteria.SeriesInstanceUid.EqualTo(seriesInstanceUid); uidSelectCriteria.SopInstanceUid.EqualTo(sopInstanceUid); var selectCriteria = new WorkQueueSelectCriteria(); selectCriteria.StudyStorageKey.EqualTo(studyStorageKey); selectCriteria.WorkQueueTypeEnum.EqualTo(WorkQueueTypeEnum.ReconcileStudy); selectCriteria.WorkQueueUidRelatedEntityCondition.Exists(uidSelectCriteria); return broker.Count(selectCriteria) > 0; } }
public bool ReprocessWorkQueueItem(WorkQueue item) { // #10620: Get a list of remaining WorkQueueUids which need to be reprocess // Note: currently only WorkQueueUIDs in failed StudyProcess will be reprocessed var remainingWorkQueueUidPaths = item.GetAllWorkQueueUidPaths(); IPersistentStore store = PersistentStoreRegistry.GetDefaultStore(); using (IUpdateContext ctx = store.OpenUpdateContext(UpdateContextSyncMode.Flush)) { // delete current workqueue IWorkQueueUidEntityBroker uidBroker = ctx.GetBroker<IWorkQueueUidEntityBroker>(); WorkQueueUidSelectCriteria criteria = new WorkQueueUidSelectCriteria(); criteria.WorkQueueKey.EqualTo(item.GetKey()); if (uidBroker.Delete(criteria) >= 0) { IWorkQueueEntityBroker workQueueBroker = ctx.GetBroker<IWorkQueueEntityBroker>(); if (workQueueBroker.Delete(item.GetKey())) { IList<StudyStorageLocation> locations = item.LoadStudyLocations(ctx); if (locations!=null && locations.Count>0) { StudyReprocessor reprocessor = new StudyReprocessor(); String reason = String.Format("User reprocesses failed {0}", item.WorkQueueTypeEnum); WorkQueue reprocessEntry = reprocessor.ReprocessStudy(ctx, reason, locations[0], remainingWorkQueueUidPaths, Platform.Time); if (reprocessEntry!=null) ctx.Commit(); return reprocessEntry!=null; } } } } return false; }
/// <summary> /// Load the specific SOP Instance Uids in the database for the WorkQueue item. /// </summary> /// <param name="item">The WorkQueue item.</param> protected void LoadUids(Model.WorkQueue item) { if (_uidList==null) { UidsLoadTime.Add(delegate { using (ServerExecutionContext context = new ServerExecutionContext()) { IWorkQueueUidEntityBroker select = context.ReadContext.GetBroker<IWorkQueueUidEntityBroker>(); WorkQueueUidSelectCriteria parms = new WorkQueueUidSelectCriteria(); parms.WorkQueueKey.EqualTo(item.GetKey()); _uidList = select.Find(parms); _uidList = TruncateList(item, _uidList); } } ); } }
private IList<WorkQueueUid> LoadAllWorkQueueUids() { using(IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IWorkQueueUidEntityBroker broker = context.GetBroker<IWorkQueueUidEntityBroker>(); WorkQueueUidSelectCriteria criteria = new WorkQueueUidSelectCriteria(); criteria.WorkQueueKey.EqualTo(WorkQueueItem.Key); return broker.Find(criteria); } }
private void ReinsertFilesystemQueue() { using (IUpdateContext updateContext = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { IWorkQueueUidEntityBroker broker = updateContext.GetBroker<IWorkQueueUidEntityBroker>(); WorkQueueUidSelectCriteria workQueueUidCriteria = new WorkQueueUidSelectCriteria(); workQueueUidCriteria.WorkQueueKey.EqualTo(WorkQueueItem.Key); broker.Delete(workQueueUidCriteria); FilesystemQueueInsertParameters parms = new FilesystemQueueInsertParameters { FilesystemQueueTypeEnum = FilesystemQueueTypeEnum.TierMigrate, ScheduledTime = Platform.Time.AddMinutes(10), StudyStorageKey = WorkQueueItem.StudyStorageKey, FilesystemKey = StorageLocation.FilesystemKey }; IInsertFilesystemQueue insertQueue = updateContext.GetBroker<IInsertFilesystemQueue>(); if (false == insertQueue.Execute(parms)) { Platform.Log(LogLevel.Error, "Unexpected failure inserting FilesystemQueue entry"); } else updateContext.Commit(); } }
public WorkQueueUidSelectCriteria(WorkQueueUidSelectCriteria other) : base(other) {}
private void ReinsertFilesystemQueue(TimeSpan delay) { using (IUpdateContext updateContext = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { IWorkQueueUidEntityBroker broker = updateContext.GetBroker<IWorkQueueUidEntityBroker>(); WorkQueueUidSelectCriteria workQueueUidCriteria = new WorkQueueUidSelectCriteria(); workQueueUidCriteria.WorkQueueKey.EqualTo(WorkQueueItem.Key); broker.Delete(workQueueUidCriteria); FilesystemQueueInsertParameters parms = new FilesystemQueueInsertParameters(); parms.FilesystemQueueTypeEnum = CompressTransferSyntax.LosslessCompressed ? FilesystemQueueTypeEnum.LosslessCompress : FilesystemQueueTypeEnum.LossyCompress; parms.ScheduledTime = Platform.Time + delay; parms.StudyStorageKey = WorkQueueItem.StudyStorageKey; parms.FilesystemKey = StorageLocation.FilesystemKey; parms.QueueXml = WorkQueueItem.Data; IInsertFilesystemQueue insertQueue = updateContext.GetBroker<IInsertFilesystemQueue>(); if (false == insertQueue.Execute(parms)) { Platform.Log(LogLevel.Error, "Unexpected failure inserting FilesystemQueue entry"); } else updateContext.Commit(); } }
private static WorkQueueDetails CreateEditWorkQueueItemDetails(Model.WorkQueue item) { string studyPath; try { StudyStorageLocation storage = WorkQueueController.GetLoadStorageLocation(item); studyPath = storage.GetStudyPath(); } catch(Exception) { studyPath = string.Empty; } var detail = new WorkQueueDetails { Key = item.Key, ScheduledDateTime = item.ScheduledTime, ExpirationTime = item.ExpirationTime, InsertTime = item.InsertTime, FailureCount = item.FailureCount, Type = item.WorkQueueTypeEnum, Status = item.WorkQueueStatusEnum, Priority = item.WorkQueuePriorityEnum, FailureDescription = item.FailureDescription, ServerDescription = item.ProcessorID, StorageLocationPath = studyPath }; // Fetch UIDs var wqUidsAdaptor = new WorkQueueUidAdaptor(); var uidCriteria = new WorkQueueUidSelectCriteria(); uidCriteria.WorkQueueKey.EqualTo(item.GetKey()); IList<WorkQueueUid> uids = wqUidsAdaptor.Get(uidCriteria); var mapSeries = new Hashtable(); foreach (WorkQueueUid uid in uids) { if (mapSeries.ContainsKey(uid.SeriesInstanceUid) == false) mapSeries.Add(uid.SeriesInstanceUid, uid.SopInstanceUid); } detail.NumInstancesPending = uids.Count; detail.NumSeriesPending = mapSeries.Count; // Fetch the study and patient info var ssAdaptor = new StudyStorageAdaptor(); StudyStorage storages = ssAdaptor.Get(item.StudyStorageKey); var studyAdaptor = new StudyAdaptor(); var studycriteria = new StudySelectCriteria(); studycriteria.StudyInstanceUid.EqualTo(storages.StudyInstanceUid); studycriteria.ServerPartitionKey.EqualTo(item.ServerPartitionKey); Study study = studyAdaptor.GetFirst(studycriteria); // Study may not be available until the images are processed. if (study != null) { var studyAssembler = new StudyDetailsAssembler(); detail.Study = studyAssembler.CreateStudyDetail(study); } var parser = new EditStudyWorkQueueDataParser(); EditStudyWorkQueueData data = parser.Parse(item.Data.DocumentElement); detail.EditUpdateItems = data.EditRequest.UpdateEntries.ToArray(); return detail; }
public WorkQueueUidSelectCriteria(WorkQueueUidSelectCriteria other) : base(other) { }