DispatchSystem.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using DbCommon.BusinessCore.BaseCore;
  2. using ProjectManagementSystem.Common.Config;
  3. using ProjectManagementSystem.Common.Core;
  4. using ProjectManagementSystem.Common.Logger;
  5. using ProjectManagementSystem.Config;
  6. using ProjectManagementSystem.Dispatch;
  7. using ProjectManagementSystem.DispatchPack;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Diagnostics;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. namespace ProjectManagementSystem.Enterance
  15. {
  16. /// <summary>
  17. /// 磁导航调度入口
  18. /// </summary>
  19. public class DispatchSystem
  20. {
  21. public DispatchSystem()
  22. {
  23. Init();
  24. }
  25. public void Init()
  26. {
  27. CConfiManager.Init();
  28. if (ExcelConfig.Instance == null)
  29. {
  30. string logContext = "Excel配置加载失败,启动失败";
  31. KillCurrentProcess(logContext);
  32. return;
  33. }
  34. if (RouteCalled.Instance == null)
  35. {
  36. string logContext = "初始化RouteCalled失败,启动失败";
  37. KillCurrentProcess(logContext);
  38. return;
  39. }
  40. if (DeviceControl.Instance == null)
  41. {
  42. string logContext = "初始化DeviceControl失败,启动失败";
  43. KillCurrentProcess(logContext);
  44. return;
  45. }
  46. //if (SimpleStep.Instance == null)
  47. //{
  48. // string logContext = "初始化SimpleStep失败,启动失败";
  49. // KillCurrentProcess(logContext);
  50. // return;
  51. //}
  52. PackEngine.Instance.Start();
  53. }
  54. private void KillCurrentProcess(string logContext)
  55. {
  56. System.Windows.Forms.MessageBox.Show(logContext);
  57. System.Windows.Forms.Application.Exit();
  58. Process[] process = Process.GetProcesses();
  59. Process currentProcess = Process.GetCurrentProcess();
  60. for (int idx = 0; idx < process.Count(); idx++)
  61. {
  62. if (process[idx].ProcessName == currentProcess.ProcessName)
  63. {
  64. process[idx].Kill();
  65. }
  66. }
  67. return;
  68. }
  69. }
  70. }