Program.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright (c) 2012-2020 fo-dicom contributors.
  2. // Licensed under the Microsoft Public License (MS-PL).
  3. using Dicom.Log;
  4. using System;
  5. using System.Configuration;
  6. using System.Threading;
  7. namespace Worklist_SCP
  8. {
  9. public class Program
  10. {
  11. protected Program()
  12. {
  13. }
  14. static void Main(string[] args)
  15. {
  16. // Initialize log manager.
  17. LogManager.SetImplementation(ConsoleLogManager.Instance);
  18. var configIpAddress = ConfigurationManager.AppSettings["IpAddress"];
  19. var configPort = ConfigurationManager.AppSettings["Port"];
  20. var configAETitle = ConfigurationManager.AppSettings["AETitle"];
  21. var configModality = ConfigurationManager.AppSettings["Modality"];
  22. // AETitle,CallingAE,Modality,Port,IpAddress
  23. if(args.Length == 0) {
  24. Console.WriteLine("启动服务器 没有传入任何参数默认启动");
  25. } else if(args.Length == 1){
  26. ConsoleLogger.Instance.Debug("启动服务器 监听端口:{0}", args);
  27. configPort = args[0];
  28. //Console.WriteLine("启动服务器 监听端口:" + args[0]);
  29. } else if(args.Length == 3) {
  30. ConsoleLogger.Instance.Debug("启动服务器 监听端口:{0} 检查类型:{1} 设备AEtitle:{2}", args);
  31. configPort = args[0];
  32. configModality = args[1];
  33. configAETitle = args[2];
  34. //Console.WriteLine("启动服务器 监听端口:" + args[0] + "\t 检查类型:" + args[1] + "\t AEtitle" + args[2]);
  35. } else {
  36. ConsoleLogger.Instance.Debug("参数个数有误 传入了{0}个参数 请检查参数列表",args.Length);
  37. }
  38. Console.WriteLine($"Starting QR SCP server with AET: {configAETitle} on ipAdress {configIpAddress} port {configPort}");
  39. WorklistServer.Start(configIpAddress, int.Parse(configPort), configAETitle, configModality);
  40. Console.WriteLine("Press any key to stop the service");
  41. //Console.Read();
  42. //while (true)
  43. //{
  44. // // Console.WriteLine("Stopping QR service");
  45. //}
  46. //WorklistServer.Stop();
  47. for (; ; )
  48. {
  49. try
  50. {
  51. Thread.Sleep(10000);
  52. }
  53. catch (ThreadInterruptedException e)
  54. {
  55. ConsoleLogger.Instance.Error("捕获异常{0}", e.Message);
  56. }
  57. }
  58. }
  59. }
  60. }