WorklistServer.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 string modality { get; set; }
  19. //public static IWorklistItemsSource CreateItemsSourceService => new WorklistItemsProvider();
  20. public static List<WorklistItem> CurrentWorklistItems { get; private set; }
  21. public static void Start(int port, string aet)
  22. {
  23. AETitle = aet;
  24. NetworkManager.SetImplementation(new DesktopNetworkManager());
  25. Dicom.IO.IOManager.SetImplementation(new Dicom.IO.DesktopIOManager());
  26. _server = DicomServer.Create<WorklistService>("0.0.0.0", port);
  27. // every 30 seconds the worklist source is queried and the current list of items is cached in _currentWorklistItems
  28. //_itemsLoaderTimer = new Timer((state) =>
  29. //{
  30. // var newWorklistItems = CreateItemsSourceService.GetAllCurrentWorklistItems();
  31. // CurrentWorklistItems = newWorklistItems;
  32. //}, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
  33. }
  34. public static void Start(string ipAdress ,int port, string aet)
  35. {
  36. AETitle = aet;
  37. NetworkManager.SetImplementation(new DesktopNetworkManager());
  38. Dicom.IO.IOManager.SetImplementation(new Dicom.IO.DesktopIOManager());
  39. _server = DicomServer.Create<WorklistService>(ipAdress, port);
  40. // every 30 seconds the worklist source is queried and the current list of items is cached in _currentWorklistItems
  41. //_itemsLoaderTimer = new Timer((state) =>
  42. //{
  43. // var newWorklistItems = CreateItemsSourceService.GetAllCurrentWorklistItems();
  44. // CurrentWorklistItems = newWorklistItems;
  45. //}, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
  46. }
  47. public static void Start(string ipAdress ,int port, string aet, string _modality)
  48. {
  49. AETitle = aet;
  50. modality = _modality;
  51. NetworkManager.SetImplementation(new DesktopNetworkManager());
  52. Dicom.IO.IOManager.SetImplementation(new Dicom.IO.DesktopIOManager());
  53. _server = DicomServer.Create<WorklistService>(ipAdress, port);
  54. // every 30 seconds the worklist source is queried and the current list of items is cached in _currentWorklistItems
  55. //_itemsLoaderTimer = new Timer((state) =>
  56. //{
  57. // var newWorklistItems = CreateItemsSourceService.GetAllCurrentWorklistItems();
  58. // CurrentWorklistItems = newWorklistItems;
  59. //}, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
  60. }
  61. public static void Stop()
  62. {
  63. //_itemsLoaderTimer?.Dispose();
  64. _server.Dispose();
  65. }
  66. }
  67. }