public void Setup() { var services = new ServiceCollection(); services.AddFellowOakDicom() .AddLogManager <NullLoggerManager>() .Configure <DicomClientOptions>(o => { o.AssociationLingerTimeoutInMs = 0; }) .Configure <DicomServiceOptions>(o => { o.LogDataPDUs = false; o.LogDimseDatasets = false; o.MaxPDULength = 512 * 1024 * 1024; }); var serviceProvider = services.BuildServiceProvider(); _dicomServerFactory = serviceProvider.GetRequiredService <IDicomServerFactory>(); _dicomClientFactory = serviceProvider.GetRequiredService <IDicomClientFactory>(); _rootPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _sampleFile = DicomFile.Open(Path.Combine(_rootPath, "Data\\GH355.dcm")); _cStoreServer = _dicomServerFactory.Create <NopCStoreProvider>(11112); _cEchoServer = _dicomServerFactory.Create <DicomCEchoProvider>(11113); }
protected override void OnStart(string[] args) { // update state to start pending ServiceStatus serviceStatus = new ServiceStatus(); serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING; serviceStatus.dwWaitHint = 100000; SetServiceStatus(this.ServiceHandle, ref serviceStatus); // preload dictionary to prevent timeouts var dict = DicomDictionary.Default; int port = int.Parse(ConfigurationManager.AppSettings["OwnListenPort"]); if (port == 0) { port = 104; } logger.Info($"Starting Dicome Storage Service on port {port}"); server = DicomServer.Create <DicomStorageProvider>(port); logger.Debug($"Created Server on port {port}"); watcher = new DicomFileWatcher(DicomFilesPath); logger.Debug($"Created fileSystem Watcher on folder : {DicomFilesPath}"); watcher.StartWatching(); // Update the service state to Running. serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING; SetServiceStatus(this.ServiceHandle, ref serviceStatus); }
public CurrentListener() { Console.Title = "Listener"; FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = Path.GetDirectoryName("./"); watcher.Filter = Path.GetFileName("ServerConfig.txt"); watcher.Changed += new FileSystemEventHandler((o, e) => { changed = true; }); watcher.EnableRaisingEvents = true; int portToListenOn = int.Parse(File.ReadAllLines("ServerConfig.txt")[5]); IDicomServer listener = DicomServer.Create <CStoreSCP>(portToListenOn); Console.WriteLine("Started listening for incoming datasets on port " + portToListenOn); while (true) { Thread.Sleep(1000); if (changed && !IsFileLocked(new FileInfo("ServerConfig.txt"))) { portToListenOn = int.Parse(File.ReadAllLines("ServerConfig.txt")[5]); listener = DicomServer.Create <CStoreSCP>(portToListenOn); Console.WriteLine("Started listening for incoming datasets on port " + portToListenOn); changed = false; } } }
public void GlobalSetup() { _server = DicomServer.Create <SimpleDicomCEchoProvider>(NetworkManager.IPv4Any, Ports.GetNext(), options: new DicomServiceOptions { LogDimseDatasets = false, LogDataPDUs = false, }); }
public Task StopAsync(CancellationToken cancellationToken) { if (_server != null) { _server.Stop(); _server = null; } return(Task.CompletedTask); }
public Task StartAsync(CancellationToken cancellationToken) { // preload dictionary to prevent tiemouts _ = DicomDictionary.Default; _server = _serverFactory.Create <T>( Options.Port ); return(Task.CompletedTask); }
public Task StartAsync(CancellationToken cancellationToken) { // preload dictionary to prevent tiemouts _ = DicomDictionary.Default; _server = _serverFactory.Create <GeneralPurposeDicomService>( Options.Port, userState: _serviceBuilder ); return(Task.CompletedTask); }
public static void Start(int port, string aet) { AETitle = aet; _server = DicomServer.Create <Worklist_SCP.WorklistService>(port); // every 30 seconds the worklist source is queried and the current list of items is cached in _currentWorklistItems _itemsLoaderTimer = new Timer((state) => { var newWorklistItems = CreateItemsSourceService.GetAllCurrentWorklistItems(); CurrentWorklistItems = newWorklistItems; }, null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); }
public static void Start(int port, string aet) { AETitle = aet; _server = DicomServer.Create <WorklistService>(port); _itemsLoaderTimer = new Timer(state => { var newWorklistItems = CreateItemsSourceService.GetAllCurrentWorklistItems(); CurrentWorklistItems = newWorklistItems; }, null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); }
/// <summary> /// Disposes of the current dicom server instance. /// </summary> private void DisposeDicomServer() { if (_dicomServer != null) { _dicomServer.Stop(); //_dicomServer.BackgroundWorker.Wait(); _dicomServer.Dispose(); _dicomServer = null; } }
public static void Start(int port, string aet) { AETitle = aet; string storageConection = ConfigurationManager.AppSettings["app:PacsStorageConnection"]; if (storageConection.StartsWith("|datadirectory|", StringComparison.OrdinalIgnoreCase)) { var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); var lastIndex = storageConection.IndexOf('|', 1); var userPathPart = storageConection.Substring(lastIndex + 1); storageConection = appDataPath + userPathPart; } IDicomMediaIdFactory mediaIdFactory = new DicomMediaIdFactory(); DbSchemaProvider schemaProvider = new StorageDbSchemaProvider(); DatabaseService = new SqlDatabaseFactory(ConfigurationManager.AppSettings["app:PacsDataArchieve"]); IObjectArchieveDataAccess dataAccess = new ObjectArchieveDataAccess( schemaProvider, new ObjectArchieveDataAdapter( schemaProvider, DatabaseService ) ); IMediaStorageService storageService = new FileStorageService(storageConection); IDicomMediaWriterFactory dicomMediaWriterFactory = new DicomMediaWriterFactory( storageService, mediaIdFactory ); StorageService = new ObjectStoreService( new Pacs.Commands.DCloudCommandFactory( storageService, dataAccess, dicomMediaWriterFactory, mediaIdFactory ) ); QueryService = new ObjectArchieveQueryService(dataAccess); RetrieveService = new ObjectRetrieveService( storageService, dicomMediaWriterFactory, mediaIdFactory ); _server = DicomServer.Create <SCP>(port); }
public bool CreateServer(int port, string serverAET) { if (IsListening()) { return(true); } AETitle = serverAET; defaultServer = DicomServer.Create <WorklistService>(port); MppsSource = new MppsHandler(WorklistItems, defaultServer.Logger); return(IsListening()); }
public DicomConnector(List <StoredDicomServer> servers) { logger.Trace("Instantiating Dicom connector.."); DicomServers = servers; DicomTranslator.connector = this; _preferences = DicomModule.GetPreferences(); server = DicomServer.Create <CStoreSCP>(_preferences.Port); _preferences.HostName = Dns.GetHostName(); _preferences.IPAddress = GetLocalIPAddress(); logger.Info("DicomServer AETITLE: {0}; IPAddress: {1}; Port {2}; TimeoutDelay: {3}; HostName: {4}", _preferences.AETitle, _preferences.IPAddress, _preferences.Port, _preferences.TimeoutDelay, _preferences.HostName); DicomModule.SavePreferences(_preferences); logger.Info("Server is listening: " + server.IsListening); ReceivedFiles = new List <DicomFile>(); logger.Trace("Instantiating Dicom connector... done."); }
public SearchServiceFactory(Wrapper <FusPersistencyFoSettings> settings) { _settings = settings.Value; try { CStoreScp.StorageCleanup(_settings.StorageHiWaterMarkGb, _settings.StorageLoWaterMarkGb); } catch (Exception ex) { _logger.Error(ex, "Dicom storage cleanup failed"); } _storeScp = DicomServer.Create <CStoreScp>(_settings.CStoreScpPort); }
public bool CreateServer(int port, string serverAET) { if (IsListening()) { return(true); } AETitle = serverAET; defaultServer = DicomServer.Create <PrintService>(port); Printer = new Printer(serverAET); return(IsListening()); }
/// <inheritdoc /> /// <exception cref="DicomNetworkException">If the service is already listening.</exception> /// <exception cref="System.Net.Sockets.SocketException">If another service is already listening on this socket.</exception> public bool StartServer(int port, Func <IReadOnlyDictionary <DicomUID, DicomTransferSyntax[]> > getAcceptedTransferSyntaxes, TimeSpan timeout) { if (!ApplicationEntityValidationHelpers.ValidatePort(port)) { throw new ArgumentException("The port is not valid.", nameof(port)); } // Check if we are already listening if (IsListening) { throw new DicomNetworkException("We are already listening. Please call stop server before starting."); } // Looks like StartServer has been called before but failed to start listening. // Lets dispose of the current instance and try again. if (_dicomServer != null) { DisposeDicomServer(); } var fileStoreParameters = new DicomFileStoreParameters(DicomDataReceiverUpdate, getAcceptedTransferSyntaxes, _dicomSaver); // Preload dictionary to prevent timeouts DicomDictionary.EnsureDefaultDictionariesLoaded(); // Constructing the listener dicom server will attempt to start the service. _dicomServer = DicomServer.Create <ListenerDicomService>(ipAddress: "localhost", port: port, userState: fileStoreParameters); // Wait until listening or we have an exception. SpinWait.SpinUntil(() => _dicomServer.IsListening || _dicomServer.Exception != null, timeout); if (_dicomServer.Exception != null) { // Throw any exceptions throw _dicomServer.Exception; } return(_dicomServer?.IsListening ?? false); }
public bool CreateServer(int port, string serverAET, string fileSaveDir = "") { if (IsListening()) { return(true); } AETitle = serverAET; if (!string.IsNullOrEmpty(fileSaveDir)) { DcmDirPath = fileSaveDir; // 如果文件夹不存在就创建 if (!System.IO.Directory.Exists(fileSaveDir)) { System.IO.Directory.CreateDirectory(fileSaveDir); } } defaultServer = DicomServer.Create <StoreService>(port); return(IsListening()); }
public static void Start(int port, string aet) { AETitle = aet; _server = DicomServer.Create <QRService>(port); }
public void StartOwnPacs() { _ourPacs = DicomServer.Create <QRService>(11112); }
public static void Start() { isRunning = true; LogManager.SetImplementation(ConsoleLogManager.Instance); server = DicomServer.Create <DicomCStoreProvider>(port); }
/// <summary> /// Register a new DICOM server /// </summary> /// <param name="dicomServer">The DICOM server that is now running</param> /// <param name="task">The task that represents the running of the DICOM server</param> public static DicomServerRegistration Register(IDicomServer dicomServer, Task task) => Setup.ServiceProvider.GetRequiredService <IDicomServerRegistry>().Register(dicomServer, task);
public static void Start(int port, string aet) { Printer = new Printer(aet); _server = DicomServer.Create<PrintService>(port); }
public DicomServerRegistration(IDicomServerRegistry registry, IDicomServer dicomServer, Task task) { Registry = registry ?? throw new ArgumentNullException(nameof(registry)); DicomServer = dicomServer ?? throw new ArgumentNullException(nameof(dicomServer)); Task = task ?? throw new ArgumentNullException(nameof(task)); }
public MyDicomServer(int port, Logger logger) { _logger = logger; _dicomServer = DicomServer.Create <CStoreSCPProvider>(port, null, null, null, logger); }
public void Start() { _server = DicomServer.Create <SimpleCStoreProvider>(12345); }
public static void Start(int port, string aet) { Printer = new Printer(aet); _server = DicomServer.Create <PrintService>(port); }
public static void Start(int port, string aet) { AETitle = aet; _server = DicomServer.Create <WorklistService>(port); CreateItemsSourceService.Start(_server.Logger); }
public async Task SendAsync_WithSocketException_ShouldNotLoopInfinitely() { var port = Ports.GetNext(); var logger = _logger.IncludePrefix("UnitTest"); IDicomServer server = null; DicomCStoreResponse response1 = null, response2 = null, response3 = null; DicomRequest.OnTimeoutEventArgs timeout1 = null, timeout2 = null, timeout3 = null; using (CreateServer <InMemoryDicomCStoreProvider>(port)) { var request1HasArrived = false; var clientFactory = CreateClientFactory(new ConfigurableNetworkManager(() => { if (request1HasArrived) { throw new IOException("Request 1 has arrived, we can no longer write to this stream!", new SocketException()); } })); var client = clientFactory.Create("127.0.0.1", port, false, "SCU", "ANY-SCP"); client.Logger = _logger.IncludePrefix(typeof(DicomClient).Name).WithMinimumLevel(LogLevel.Debug); // Ensure requests are handled sequentially client.NegotiateAsyncOps(1, 1); // Size = 5 192 KB, one PDU = 16 KB, so this will result in 325 PDUs // If stream timeout = 1500ms, then total time to send will be 325 * 1500 = 487.5 seconds var request1 = new DicomCStoreRequest(@"./Test Data/10200904.dcm") { OnResponseReceived = (req, res) => { request1HasArrived = true; response1 = res; }, OnTimeout = (sender, args) => timeout1 = args }; var request2 = new DicomCStoreRequest(@"./Test Data/10200904.dcm") { OnResponseReceived = (req, res) => response2 = res, OnTimeout = (sender, args) => timeout2 = args }; var request3 = new DicomCStoreRequest(@"./Test Data/10200904.dcm") { OnResponseReceived = (req, res) => response3 = res, OnTimeout = (sender, args) => timeout3 = args }; await client.AddRequestsAsync(new[] { request1, request2, request3 }).ConfigureAwait(false); using var cancellation = new CancellationTokenSource(TimeSpan.FromMinutes(1)); Exception exception = null; try { await client.SendAsync(cancellation.Token, DicomClientCancellationMode.ImmediatelyAbortAssociation).ConfigureAwait(false); } catch (Exception e) { exception = e; } Assert.NotNull(exception); Assert.False(cancellation.IsCancellationRequested); } Assert.NotNull(response1); Assert.Null(response2); Assert.Null(response3); Assert.Null(timeout1); Assert.Null(timeout2); Assert.Null(timeout3); }
public static void Start(int port) { _server = DicomServer.Create <PrintService>(port); }