/// <summary> /// Check the currently configured archives and plugins to see if any have been disabled. /// </summary> private void CheckConfiguredArchives() { IList<ServerPartition> partitionList = LoadPartitions(); lock (_syncLock) { IList<PartitionArchiveService> partitionsToDelete = new List<PartitionArchiveService>(); foreach (PartitionArchiveService archiveService in _archiveServiceList) { archiveService.PartitionArchive = PartitionArchive.Load(archiveService.PartitionArchive.GetKey()); if (!archiveService.PartitionArchive.Enabled) { Platform.Log(LogLevel.Info, "PartitionArchive {0} has been disabled, stopping plugin.", archiveService.PartitionArchive.Description); archiveService.ArchivePlugin.Stop(); partitionsToDelete.Add(archiveService); } else { bool bFound = false; foreach (ServerPartition serverPartition in partitionList) { if (serverPartition.GetKey().Equals(archiveService.ServerPartition.GetKey()) && serverPartition.Enabled) { bFound = true; break; } } if (!bFound) { Platform.Log(LogLevel.Info, "Partition was deleted or disabled, shutting down archive server {0}", archiveService.ServerPartition.Description); archiveService.ArchivePlugin.Stop(); partitionsToDelete.Add(archiveService); } } } // Remove the services from our internal list. foreach (PartitionArchiveService archivePlugin in partitionsToDelete) _archiveServiceList.Remove(archivePlugin); // Load the current extension list ImageServerArchiveExtensionPoint ep = new ImageServerArchiveExtensionPoint(); ExtensionInfo[] extensionInfoList = ep.ListExtensions(); // Scan the current list of enabled partition archives to see if any // new archives have been added foreach (PartitionArchive partitionArchive in LoadEnabledPartitionArchives()) { ServerPartition newPartition = ServerPartition.Load(partitionArchive.ServerPartitionKey); if (!newPartition.Enabled) continue; bool bFound = false; foreach (PartitionArchiveService service in _archiveServiceList) { if (!partitionArchive.GetKey().Equals(service.PartitionArchive.GetKey())) continue; // Reset the context partition, incase its changed. service.PartitionArchive = partitionArchive; bFound = true; break; } if (!bFound) { // No match, scan the current extensions for a matching extension // to run the service foreach (ExtensionInfo extensionInfo in extensionInfoList) { IImageServerArchivePlugin archive = (IImageServerArchivePlugin)ep.CreateExtension(new ClassNameExtensionFilter(extensionInfo.FormalName)); if (archive.ArchiveType.Equals(partitionArchive.ArchiveTypeEnum)) { PartitionArchiveService service = new PartitionArchiveService(archive, partitionArchive, newPartition); Platform.Log(LogLevel.Info, "Detected PartitionArchive was added, starting archive {0}", partitionArchive.Description); service.ArchivePlugin.Start(partitionArchive); _archiveServiceList.Add(service); break; } } } } } }
/// <summary> /// Check the currently configured archives and plugins to see if any have been disabled. /// </summary> private void CheckConfiguredArchives() { IList <ServerPartition> partitionList = LoadPartitions(); lock (_syncLock) { IList <PartitionArchiveService> partitionsToDelete = new List <PartitionArchiveService>(); foreach (PartitionArchiveService archiveService in _archiveServiceList) { archiveService.PartitionArchive = PartitionArchive.Load(archiveService.PartitionArchive.GetKey()); if (!archiveService.PartitionArchive.Enabled) { Platform.Log(LogLevel.Info, "PartitionArchive {0} has been disabled, stopping plugin.", archiveService.PartitionArchive.Description); archiveService.ArchivePlugin.Stop(); partitionsToDelete.Add(archiveService); } else { bool bFound = false; foreach (ServerPartition serverPartition in partitionList) { if (serverPartition.GetKey().Equals(archiveService.ServerPartition.GetKey()) && serverPartition.Enabled) { bFound = true; break; } } if (!bFound) { Platform.Log(LogLevel.Info, "Partition was deleted or disabled, shutting down archive server {0}", archiveService.ServerPartition.Description); archiveService.ArchivePlugin.Stop(); partitionsToDelete.Add(archiveService); } } } // Remove the services from our internal list. foreach (PartitionArchiveService archivePlugin in partitionsToDelete) { _archiveServiceList.Remove(archivePlugin); } // Load the current extension list ImageServerArchiveExtensionPoint ep = new ImageServerArchiveExtensionPoint(); ExtensionInfo[] extensionInfoList = ep.ListExtensions(); // Scan the current list of enabled partition archives to see if any // new archives have been added foreach (PartitionArchive partitionArchive in LoadEnabledPartitionArchives()) { ServerPartition newPartition = ServerPartition.Load(partitionArchive.ServerPartitionKey); if (!newPartition.Enabled) { continue; } bool bFound = false; foreach (PartitionArchiveService service in _archiveServiceList) { if (!partitionArchive.GetKey().Equals(service.PartitionArchive.GetKey())) { continue; } // Reset the context partition, incase its changed. service.PartitionArchive = partitionArchive; bFound = true; break; } if (!bFound) { // No match, scan the current extensions for a matching extension // to run the service foreach (ExtensionInfo extensionInfo in extensionInfoList) { IImageServerArchivePlugin archive = (IImageServerArchivePlugin)ep.CreateExtension(new ClassNameExtensionFilter(extensionInfo.FormalName)); if (archive.ArchiveType.Equals(partitionArchive.ArchiveTypeEnum)) { PartitionArchiveService service = new PartitionArchiveService(archive, partitionArchive, newPartition); Platform.Log(LogLevel.Info, "Detected PartitionArchive was added, starting archive {0}", partitionArchive.Description); service.ArchivePlugin.Start(partitionArchive); _archiveServiceList.Add(service); break; } } } } } }