private static void RemoveStudyStorage(StudyStorageLocation location) { // NOTE: This was an IUpdateContext, however, it was modified to be an IReadContext // after having problems w/ locks on asystem with a fair amount of load. The // updates are just automatically committed within the stored procedure when it // runs... using (IReadContext updateContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { // Setup the delete parameters DeleteStudyStorageParameters parms = new DeleteStudyStorageParameters { ServerPartitionKey = location.ServerPartitionKey, StudyStorageKey = location.Key }; // Get the Insert Instance broker and do the insert IDeleteStudyStorage delete = updateContext.GetBroker <IDeleteStudyStorage>(); if (false == delete.Execute(parms)) { Platform.Log(LogLevel.Error, "Unexpected error when trying to delete study: {0}", location.StudyInstanceUid); } } }
protected override IList <Worklist> GetItemsForExport(IReadContext context, int firstRow, int maxRows) { var where = new WorklistSearchCriteria(); where.Name.SortAsc(0); where.FullClassName.SortAsc(1); return(context.GetBroker <IWorklistBroker>().Find(where, new SearchResultPage(firstRow, maxRows))); }
/// <summary> /// Returns a list of the services supported by this plugin. /// </summary> /// <returns></returns> public override IList <SupportedSop> GetSupportedSopClasses() { if (_list == null) { _list = new List <SupportedSop>(); // Get the SOP Classes using (IReadContext read = _store.OpenReadContext()) { // Set the input parameters for query PartitionSopClassQueryParameters inputParms = new PartitionSopClassQueryParameters(); inputParms.ServerPartitionKey = Partition.GetKey(); IQueryServerPartitionSopClasses broker = read.GetBroker <IQueryServerPartitionSopClasses>(); IList <PartitionSopClass> sopClasses = broker.Find(inputParms); // Now process the SOP Class List foreach (PartitionSopClass partitionSopClass in sopClasses) { if (partitionSopClass.Enabled && !partitionSopClass.NonImage) { SupportedSop sop = new SupportedSop(); sop.SopClass = SopClass.GetSopClass(partitionSopClass.SopClassUid); sop.SyntaxList.Add(TransferSyntax.ExplicitVrLittleEndian); sop.SyntaxList.Add(TransferSyntax.ImplicitVrLittleEndian); _list.Add(sop); } } } } return(_list); }
protected override IList <ProtocolGroup> GetItemsForExport(IReadContext context, int firstRow, int maxRows) { ProtocolGroupSearchCriteria where = new ProtocolGroupSearchCriteria(); where.Name.SortAsc(0); return(context.GetBroker <IProtocolGroupBroker>().Find(where, new SearchResultPage(firstRow, maxRows))); }
protected override IList <CannedText> GetItemsForExport(IReadContext context, int firstRow, int maxRows) { CannedTextSearchCriteria where = new CannedTextSearchCriteria(); where.Name.SortAsc(0); return(context.GetBroker <ICannedTextBroker>().Find(where, new SearchResultPage(firstRow, maxRows))); }
protected override IList <PatientNoteCategory> GetItemsForExport(IReadContext context, int firstRow, int maxRows) { PatientNoteCategorySearchCriteria where = new PatientNoteCategorySearchCriteria(); where.Name.SortAsc(0); return(context.GetBroker <IPatientNoteCategoryBroker>().Find(where, new SearchResultPage(firstRow, maxRows))); }
private bool CheckMultipleInstances() { TimeSpan cacheDuration = TimeSpan.FromMinutes(2); lock (_dbCheckSync) { if (!_multipleInstanceDetected.HasValue || Math.Abs(Environment.TickCount - _lastDbCheck) > cacheDuration.TotalMilliseconds) { _lastDbCheck = Environment.TickCount; using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { var broker = context.GetBroker <IServiceLockEntityBroker>(); var criteria = new ServiceLockSelectCriteria(); criteria.ServiceLockTypeEnum.EqualTo(ServiceLockTypeEnum.ImportFiles); criteria.Enabled.EqualTo(true); var list = broker.Find(criteria); _multipleInstanceDetected = list.Count > 1; } } } return(_multipleInstanceDetected.Value); }
/// <summary> /// Load from the database the configured transfer syntaxes /// </summary> /// <param name="read">a Read context</param> /// <param name="partitionKey">The partition to retrieve the transfer syntaxes for</param> /// <param name="encapsulated">true if searching for encapsulated syntaxes only</param> /// <returns>The list of syntaxes</returns> protected static IList <PartitionTransferSyntax> LoadTransferSyntaxes(IReadContext read, ServerEntityKey partitionKey, bool encapsulated) { var broker = read.GetBroker <IQueryServerPartitionTransferSyntaxes>(); var criteria = new PartitionTransferSyntaxQueryParameters { ServerPartitionKey = partitionKey }; IList <PartitionTransferSyntax> list = broker.Find(criteria); var returnList = new List <PartitionTransferSyntax>(); foreach (PartitionTransferSyntax syntax in list) { if (!syntax.Enabled) { continue; } TransferSyntax dicomSyntax = TransferSyntax.GetTransferSyntax(syntax.Uid); if (dicomSyntax.Encapsulated == encapsulated) { returnList.Add(syntax); } } return(returnList); }
protected override IList <Modality> GetItemsForExport(IReadContext context, int firstRow, int maxRows) { var where = new ModalitySearchCriteria(); where.Id.SortAsc(0); return(context.GetBroker <IModalityBroker>().Find(where, new SearchResultPage(firstRow, maxRows))); }
/// <summary> /// Resets a list of <see cref="WorkQueue"/> items. /// </summary> /// <param name="items">List of <see cref="WorkQueue"/> to be reset</param> /// <param name="newScheduledTime">The new scheduled start date/time for the entries</param> /// <param name="expirationTime">The new expiration start date/time for the entries</param> public void ResetWorkQueueItems(IList <WorkQueue> items, DateTime newScheduledTime, DateTime expirationTime) { if (items == null || items.Count == 0) { return; } IPersistentStore store = PersistentStoreRegistry.GetDefaultStore(); using (IReadContext ctx = store.OpenReadContext()) { IWebResetWorkQueue broker = ctx.GetBroker <IWebResetWorkQueue>(); foreach (WorkQueue item in items) { WebResetWorkQueueParameters parameters = new WebResetWorkQueueParameters { WorkQueueKey = item.Key, NewScheduledTime = newScheduledTime, NewExpirationTime = expirationTime }; if (!broker.Execute(parameters)) { Platform.Log(LogLevel.Error, "Unexpected error when calling WebResetWorkQueue stored procedure. Could not reset {0} work queue entry {1}", item.WorkQueueTypeEnum.Description, item.Key); } } } }
private static Device FindServer(string retrieveAeTitle) { var webUser = Thread.CurrentPrincipal as CustomPrincipal; if (webUser != null) { foreach (var partition in ServerPartitionMonitor.Instance) { if (partition.AeTitle.Equals(retrieveAeTitle, StringComparison.InvariantCulture)) { if (!partition.IsUserAccessAllowed(webUser)) { throw new PermissionDeniedException(string.Format("User does not have permission to access partition {0}", partition.AeTitle)); } } } } using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { var broker = ctx.GetBroker <IDeviceEntityBroker>(); var criteria = new DeviceSelectCriteria(); criteria.AeTitle.EqualTo(retrieveAeTitle); IList <Device> list = broker.Find(criteria); foreach (Device theDevice in list) { if (string.Compare(theDevice.AeTitle, retrieveAeTitle, false, CultureInfo.InvariantCulture) == 0) { return(theDevice); } } } return(null); }
private void checkBoxLoadTest_CheckedChanged(object sender, EventArgs e) { try { WorkQueueTypeEnum t = WorkQueueTypeEnum.CompressStudy; using (IReadContext read = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IInsertStudyStorage insert = read.GetBroker <IInsertStudyStorage>(); InsertStudyStorageParameters criteria = new InsertStudyStorageParameters(); criteria.StudyInstanceUid = "1.2.3.4"; criteria.FilesystemKey = FilesystemMonitor.Instance.GetFilesystems().GetEnumerator().Current.Filesystem.GetKey(); criteria.Folder = "20070101"; criteria.StudyStatusEnum = StudyStatusEnum.Online; criteria.QueueStudyStateEnum = QueueStudyStateEnum.Idle; IList <StudyStorageLocation> storage = insert.Find(criteria); StudyStorageLocation storageEntry = storage[0]; } } catch (Exception x) { Platform.Log(LogLevel.Error, x); } }
private void LoadDeletedStudies() { using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IStudyDeleteRecordEntityBroker broker = context.GetBroker <IStudyDeleteRecordEntityBroker>(); _deletedStudies = broker.Find(new StudyDeleteRecordSelectCriteria()); } }
private void LoadSIQEntries() { using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IStudyIntegrityQueueEntityBroker broker = ctx.GetBroker <IStudyIntegrityQueueEntityBroker>(); _siqEntries = new List <StudyIntegrityQueue>(broker.Find(new StudyIntegrityQueueSelectCriteria())); } }
private static void CheckSystemMode() { var now = Platform.Time; if (!_systemModeLastCheckTimestamp.HasValue || now - _systemModeLastCheckTimestamp > TimeSpan.FromSeconds(15)) { lock (_syncLock) { if (!_systemModeLastCheckTimestamp.HasValue || now - _systemModeLastCheckTimestamp > TimeSpan.FromSeconds(15)) { try { IPersistentStore store = PersistentStoreRegistry.GetDefaultStore(); using (IReadContext ctx = store.OpenReadContext()) { var deleteRuleBroker = ctx.GetBroker <IServerRuleEntityBroker>(); var deleteRuleSearchCriteria = new ServerRuleSelectCriteria(); deleteRuleSearchCriteria.ServerRuleTypeEnum.EqualTo(ServerRuleTypeEnum.StudyDelete); deleteRuleSearchCriteria.Enabled.EqualTo(true); var deleteRules = deleteRuleBroker.Find(deleteRuleSearchCriteria); if (deleteRules == null || deleteRules.Count == 0) { _serverMode = Common.ServerOperatingMode.Archive; } var defaultDeleteRuleExists = deleteRules.Any(r => r.RuleName.Equals("Default Delete")); var customDeleteRuleExists = deleteRules.Any(r => !r.RuleName.Equals("Default Delete")); if (defaultDeleteRuleExists) { _serverMode = Common.ServerOperatingMode.TemporaryCache; } else { if (customDeleteRuleExists) { _serverMode = Common.ServerOperatingMode.MixedMode; } else { _serverMode = Common.ServerOperatingMode.Archive; } } } } catch (Exception ex) { Platform.Log(LogLevel.Error, ex); } finally { _systemModeLastCheckTimestamp = now; } } } } }
public ImageServerData() { using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { TotalStudiesCount = 0; IServerPartitionEntityBroker partitionBroker = context.GetBroker <IServerPartitionEntityBroker>(); var partitions = partitionBroker.Find(new ServerPartitionSelectCriteria()); foreach (ServerPartition partition in partitions) { TotalStudiesCount += partition.StudyCount; } IDeviceEntityBroker deviceBroker = context.GetBroker <IDeviceEntityBroker>(); DeviceSelectCriteria criteria = new DeviceSelectCriteria(); criteria.Enabled.EqualTo(true); ActiveDeviceCount += deviceBroker.Count(criteria); } }
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)); } }
public IList <Study> LoadRelatedStudies() { using (IReadContext read = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IStudyEntityBroker broker = read.GetBroker <IStudyEntityBroker>(); StudySelectCriteria criteria = new StudySelectCriteria(); criteria.PatientKey.EqualTo(Key); return(broker.Find(criteria)); } }
protected override IList <ConfigurationDocument> GetItemsForExport(IReadContext context, int firstRow, int maxRows) { ConfigurationDocumentSearchCriteria where = new ConfigurationDocumentSearchCriteria(); where.DocumentName.SortAsc(0); where.DocumentVersionString.SortAsc(1); where.User.SortAsc(2); where.InstanceKey.SortAsc(3); return(context.GetBroker <IConfigurationDocumentBroker>().Find(where, new SearchResultPage(firstRow, maxRows))); }
public WorkQueueProcessor(int numberThreads, ManualResetEvent terminateEvent, string name) { _terminateEvent = terminateEvent; _threadStop = new ManualResetEvent(false); using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IWorkQueueTypePropertiesEntityBroker broker = ctx.GetBroker <IWorkQueueTypePropertiesEntityBroker>(); WorkQueueTypePropertiesSelectCriteria criteria = new WorkQueueTypePropertiesSelectCriteria(); IList <WorkQueueTypeProperties> propertiesList = broker.Find(criteria); foreach (WorkQueueTypeProperties prop in propertiesList) { _propertiesDictionary.Add(prop.WorkQueueTypeEnum, prop); } } _threadPool = new WorkQueueThreadPool(numberThreads, WorkQueueSettings.Instance.PriorityWorkQueueThreadCount, WorkQueueSettings.Instance.MemoryLimitedWorkQueueThreadCount, _propertiesDictionary) { ThreadPoolName = name + " Pool" }; WorkQueueFactoryExtensionPoint ep = new WorkQueueFactoryExtensionPoint(); object[] factories = ep.CreateExtensions(); if (factories == null || factories.Length == 0) { // No extension for the workqueue processor. Platform.Log(LogLevel.Warn, "No WorkQueueFactory Extension found."); } else { foreach (object obj in factories) { IWorkQueueProcessorFactory factory = obj as IWorkQueueProcessorFactory; if (factory != null) { WorkQueueTypeEnum type = factory.GetWorkQueueType(); _extensions.Add(type, factory); } else { Platform.Log(LogLevel.Error, "Unexpected incorrect type loaded for extension: {0}", obj.GetType()); } } } }
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)); } }
protected override IList <ExternalPractitioner> GetItemsForExport(IReadContext context, int firstRow, int maxRows) { var where = new ExternalPractitionerSearchCriteria(); where.Name.FamilyName.SortAsc(0); where.Name.GivenName.SortAsc(1); where.Name.MiddleName.SortAsc(2); where.LicenseNumber.SortAsc(3); where.BillingNumber.SortAsc(4); return(context.GetBroker <IExternalPractitionerBroker>().Find(where, new SearchResultPage(firstRow, maxRows))); }
private Study GetStudyAndQueues(StudyStorageLocation location, out int integrityQueueCount, out int workQueueCount) { using (IReadContext context = _store.OpenReadContext()) { IStudyIntegrityQueueEntityBroker integrityBroker = context.GetBroker <IStudyIntegrityQueueEntityBroker>(); StudyIntegrityQueueSelectCriteria integrityCriteria = new StudyIntegrityQueueSelectCriteria(); integrityCriteria.StudyStorageKey.EqualTo(location.Key); integrityQueueCount = integrityBroker.Count(integrityCriteria); IWorkQueueEntityBroker workBroker = context.GetBroker <IWorkQueueEntityBroker>(); WorkQueueSelectCriteria workCriteria = new WorkQueueSelectCriteria(); workCriteria.StudyStorageKey.EqualTo(location.Key); workQueueCount = workBroker.Count(workCriteria); IStudyEntityBroker procedure = context.GetBroker <IStudyEntityBroker>(); StudySelectCriteria criteria = new StudySelectCriteria(); criteria.StudyStorageKey.EqualTo(location.Key); return(procedure.FindOne(criteria)); } }
/// <summary> /// Finds all storage locations used for the study. /// </summary> protected void FindAllRelatedDirectories() { // Check the work queue for other entries IList <Model.WorkQueue> list; // NOTE: a local read context is used for lookup because we want to // release the lock on the rows asap. using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IWorkQueueEntityBroker broker = ctx.GetBroker <IWorkQueueEntityBroker>(); WorkQueueSelectCriteria criteria = new WorkQueueSelectCriteria(); criteria.StudyStorageKey.EqualTo(WorkQueueItem.StudyStorageKey); list = broker.Find(criteria); } List <DirectoryInfo> dirs = new List <DirectoryInfo>(); foreach (Model.WorkQueue item in list) { string path = GetWorkQueueSecondaryFolder(item); if (!string.IsNullOrEmpty(path)) { dirs.Add(new DirectoryInfo(path)); } } // NOTE: Under normal operation, the SIQ entries should be // empty at this point because the Delete Study button is disabled otherwise. // This block of code is still needed just in case this DeleteStudy work queue entry // is inserted through different means. IList <StudyIntegrityQueue> siqList; using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IStudyIntegrityQueueEntityBroker broker = ctx.GetBroker <IStudyIntegrityQueueEntityBroker>(); StudyIntegrityQueueSelectCriteria criteria = new StudyIntegrityQueueSelectCriteria(); criteria.StudyStorageKey.EqualTo(WorkQueueItem.StudyStorageKey); siqList = broker.Find(criteria); } foreach (StudyIntegrityQueue item in siqList) { string path = GetSIQItemStorageFolder(item); if (!string.IsNullOrEmpty(path)) { dirs.Add(new DirectoryInfo(path)); } } _relatedDirectories = dirs; }
/// <summary> /// Load the list of currently configured <see cref="ServerPartition"/> instances. /// </summary> /// <returns>The partition list.</returns> private static IList <ServerPartition> LoadPartitions() { //Get partitions IPersistentStore store = PersistentStoreRegistry.GetDefaultStore(); using (IReadContext read = store.OpenReadContext()) { IServerPartitionEntityBroker broker = read.GetBroker <IServerPartitionEntityBroker>(); ServerPartitionSelectCriteria criteria = new ServerPartitionSelectCriteria(); return(broker.Find(criteria)); } }
/// <summary> /// Load the list of <see cref="PartitionArchive"/> entries that are enabled. /// </summary> /// <returns>The list of <see cref="PartitionArchive"/> instances from the persistant store</returns> private static IList <PartitionArchive> LoadEnabledPartitionArchives() { using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IPartitionArchiveEntityBroker broker = readContext.GetBroker <IPartitionArchiveEntityBroker>(); PartitionArchiveSelectCriteria criteria = new PartitionArchiveSelectCriteria(); criteria.Enabled.EqualTo(true); return(broker.Find(criteria)); } }
private static bool CheckIfStudyIsInWorkQueue(ScanResultEntry scanResult) { using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IWorkQueueEntityBroker broker = ctx.GetBroker <IWorkQueueEntityBroker>(); WorkQueueSelectCriteria criteria = new WorkQueueSelectCriteria(); criteria.StudyStorageKey.EqualTo(scanResult.Storage.Key); var list = broker.Find(criteria); scanResult.IsInWorkQueue = list != null && list.Count > 0; } return(scanResult.IsInWorkQueue); }
private StudyStorageLocation ReloadStorageLocation() { using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { var parms = new StudyStorageLocationQueryParameters { StudyStorageKey = _location.Key }; var broker = readContext.GetBroker <IQueryStudyStorageLocation>(); _location = broker.FindOne(parms); } return(_location); }
protected override IEnumerable <IExportItem> ExportCore() { using (PersistenceScope scope = new PersistenceScope(PersistenceContextType.Read)) { IReadContext context = (IReadContext)PersistenceScope.CurrentContext; IMetadataBroker metaBroker = context.GetBroker <IMetadataBroker>(); IEnumBroker enumBroker = context.GetBroker <IEnumBroker>(); List <Type> enumClasses = CollectionUtils.Sort(metaBroker.ListEnumValueClasses(), delegate(Type x, Type y) { return(x.FullName.CompareTo(y.FullName)); }); foreach (Type enumClass in enumClasses) { EnumerationData data = new EnumerationData(); data.EnumerationClass = enumClass.FullName; data.Members = CollectionUtils.Map <EnumValue, EnumerationMemberData>(enumBroker.Load(enumClass, true), delegate(EnumValue v) { return(new EnumerationMemberData(v)); }); yield return(new ExportItem(data)); } scope.Complete(); } }
protected bool GetStudyStorageLocation(ServerEntityKey partitionKey, string studyInstanceUid, out StudyStorageLocation location) { using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IQueryStudyStorageLocation procedure = context.GetBroker <IQueryStudyStorageLocation>(); StudyStorageLocationQueryParameters parms = new StudyStorageLocationQueryParameters(); parms.ServerPartitionKey = partitionKey; parms.StudyInstanceUid = studyInstanceUid; location = procedure.FindOne(parms); return(location != null); } }
/// <summary> /// Load from the database the configured transfer syntaxes /// </summary> /// <param name="read">a Read context</param> /// <param name="partitionKey">The partition to retrieve the transfer syntaxes for</param> /// <param name="encapsulated">true if searching for encapsulated syntaxes only</param> /// <returns>The list of syntaxes</returns> protected static IList<PartitionTransferSyntax> LoadTransferSyntaxes(IReadContext read, ServerEntityKey partitionKey, bool encapsulated) { var broker = read.GetBroker<IQueryServerPartitionTransferSyntaxes>(); var criteria = new PartitionTransferSyntaxQueryParameters { ServerPartitionKey = partitionKey }; IList<PartitionTransferSyntax> list = broker.Find(criteria); var returnList = new List<PartitionTransferSyntax>(); foreach (PartitionTransferSyntax syntax in list) { if (!syntax.Enabled) continue; TransferSyntax dicomSyntax = TransferSyntax.GetTransferSyntax(syntax.Uid); if (dicomSyntax.Encapsulated == encapsulated) returnList.Add(syntax); } return returnList; }