private void RemoveDatabase(Model.WorkQueue item) { using (IUpdateContext updateContext = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { // Setup the delete parameters DeleteFilesystemStudyStorageParameters parms = new DeleteFilesystemStudyStorageParameters(); parms.ServerPartitionKey = item.ServerPartitionKey; parms.StudyStorageKey = item.StudyStorageKey; parms.StudyStatusEnum = StudyStatusEnum.Nearline; // TODO: Don't we set Nearline only if all the storage location are purged? // Get the Insert Instance broker and do the insert IDeleteFilesystemStudyStorage delete = updateContext.GetBroker<IDeleteFilesystemStudyStorage>(); if (false == delete.Execute(parms)) { Platform.Log(LogLevel.Error, "Unexpected error when trying to delete study: {0} on partition {1}", StorageLocation.StudyInstanceUid, ServerPartition.Description); } else { // Unlock the study, too ILockStudy studyLock = updateContext.GetBroker<ILockStudy>(); LockStudyParameters lockParms = new LockStudyParameters(); lockParms.QueueStudyStateEnum = QueueStudyStateEnum.Idle; lockParms.StudyStorageKey = item.StudyStorageKey; studyLock.Execute(lockParms); updateContext.Commit(); } } }
protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext) { // Setup the delete parameters var parms = new DeleteFilesystemStudyStorageParameters(); parms.ServerPartitionKey = _storage.ServerPartitionKey; parms.StudyStorageKey = _storage.GetKey(); parms.StudyStatusEnum = StudyStatusEnum.Nearline; // TODO: Don't we set Nearline only if all the storage location are purged? // Get the Insert Instance broker and do the insert var delete = updateContext.GetBroker<IDeleteFilesystemStudyStorage>(); if (false == delete.Execute(parms)) { Platform.Log(LogLevel.Error, "Unexpected error when trying to delete study: {0} on partition {1}", _storage.StudyInstanceUid, _storage.ServerPartition.Description); } else { // Unlock the study, too var studyLock = updateContext.GetBroker<ILockStudy>(); var lockParms = new LockStudyParameters(); lockParms.QueueStudyStateEnum = QueueStudyStateEnum.Idle; lockParms.StudyStorageKey = _storage.GetKey(); studyLock.Execute(lockParms); } }