WorklistServer.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright (c) 2012-2020 fo-dicom contributors.
  2. // Licensed under the Microsoft Public License (MS-PL).
  3. using Dicom.Network;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Threading;
  7. using Worklist_SCP.Model;
  8. namespace Worklist_SCP
  9. {
  10. public class WorklistServer
  11. {
  12. private static IDicomServer _server;
  13. //private static Timer _itemsLoaderTimer;
  14. protected WorklistServer()
  15. {
  16. }
  17. public static string AETitle { get; set; }
  18. //public static IWorklistItemsSource CreateItemsSourceService => new WorklistItemsProvider();
  19. public static List<WorklistItem> CurrentWorklistItems { get; private set; }
  20. public static void Start(int port, string aet)
  21. {
  22. AETitle = aet;
  23. NetworkManager.SetImplementation(new DesktopNetworkManager());
  24. Dicom.IO.IOManager.SetImplementation(new Dicom.IO.DesktopIOManager());
  25. _server = DicomServer.Create<WorklistService>("0.0.0.0", port);
  26. // every 30 seconds the worklist source is queried and the current list of items is cached in _currentWorklistItems
  27. //_itemsLoaderTimer = new Timer((state) =>
  28. //{
  29. // var newWorklistItems = CreateItemsSourceService.GetAllCurrentWorklistItems();
  30. // CurrentWorklistItems = newWorklistItems;
  31. //}, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
  32. }
  33. public static void Start(string ipAdress ,int port, string aet)
  34. {
  35. AETitle = aet;
  36. NetworkManager.SetImplementation(new DesktopNetworkManager());
  37. Dicom.IO.IOManager.SetImplementation(new Dicom.IO.DesktopIOManager());
  38. _server = DicomServer.Create<WorklistService>(ipAdress, port);
  39. // every 30 seconds the worklist source is queried and the current list of items is cached in _currentWorklistItems
  40. //_itemsLoaderTimer = new Timer((state) =>
  41. //{
  42. // var newWorklistItems = CreateItemsSourceService.GetAllCurrentWorklistItems();
  43. // CurrentWorklistItems = newWorklistItems;
  44. //}, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
  45. }
  46. public static void Stop()
  47. {
  48. //_itemsLoaderTimer?.Dispose();
  49. _server.Dispose();
  50. }
  51. }
  52. }