/// <summary> /// Check if a study is nearline and restore if requested. /// </summary> /// <param name="context"></param> /// <param name="partitionKey"></param> /// <param name="studyInstanceUid"></param> /// <param name="restore"></param> private static void CheckForStudyRestore(IPersistenceContext context, ServerEntityKey partitionKey, string studyInstanceUid, StudyRestore restore) { IStudyStorageEntityBroker selectBroker = context.GetBroker <IStudyStorageEntityBroker>(); StudyStorageSelectCriteria criteria = new StudyStorageSelectCriteria(); criteria.ServerPartitionKey.EqualTo(partitionKey); criteria.StudyInstanceUid.EqualTo(studyInstanceUid); StudyStorage storage = selectBroker.FindOne(criteria); if (storage != null) { if (restore == StudyRestore.True) { RestoreQueue restoreRq = storage.InsertRestoreRequest(); if (restoreRq != null) { throw new StudyIsNearlineException(true); } } throw new StudyIsNearlineException(false); } throw new StudyNotFoundException(studyInstanceUid); }
private static StudyStorage FindStudyStorage(ScanResultEntry result) { using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IStudyStorageEntityBroker broker = ctx.GetBroker <IStudyStorageEntityBroker>(); StudyStorageSelectCriteria criteria = new StudyStorageSelectCriteria(); criteria.StudyInstanceUid.EqualTo(result.StudyInstanceUid); criteria.ServerPartitionKey.EqualTo(result.ServerPartitionKey); return(broker.FindOne(criteria)); } }