12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using ProjectManagementSystem.Common.Config;
- using ProjectManagementSystem.Common.Core;
- using ProjectManagementSystem.Common.Dispatch;
- using ProjectManagementSystem.Language;
- using ProjectManagementSystem.WebApi.Service;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- namespace ProjectManagementSystemView.Entrance
- {
- public class DispatchSystem
- {
- public DispatchSystem()
- {
- if (ExcelConfig.Instance == null)
- {
- KillCurrentProcess(Langs.InitFailExcelConfig);
- return;
- }
- if (!SystemInitialize.InitDataSource())
- {
- KillCurrentProcess(Langs.InitFailDataSource);
- return;
- }
- //if (RouteCalled.Instance == null)
- //{
- // KillCurrentProcess(Langs.InitFailRouteCalled);
- // return;
- //}
- if (PlcControl.Instance == null)
- {
- KillCurrentProcess(Langs.InitFailPlcControl);
- return;
- }
- if (DeviceControl.Instance == null)
- {
- KillCurrentProcess(Langs.InitFailDeviceControl);
- return;
- }
- if (!WebApiServerHost.Instance.StartServer())
- {
- KillCurrentProcess(Langs.InitFailWebApi);
- return;
- }
- SystemInitialize.InitWMS();
- if (SimpleProcess.Instance == null)
- {
- KillCurrentProcess("SimpleProcess init failed");
- return;
- }
- if (PackDispatch.Instance == null)
- {
- KillCurrentProcess("PackDispatch init failed");
- return;
- }
- }
- private void KillCurrentProcess(string logContext)
- {
- MessageBox.Show(logContext);
- Application.Current.Shutdown();
- Process[] process = Process.GetProcesses();
- Process currentProcess = Process.GetCurrentProcess();
- for (int idx = 0; idx < process.Count(); idx++)
- {
- if (process[idx].ProcessName == currentProcess.ProcessName)
- {
- process[idx].Kill();
- }
- }
- return;
- }
- }
- }
|