using ProjectManagementSystem.Common.Config; using ProjectManagementSystem.Common.Core; using ProjectManagementSystem.Common.TaskBookEvent; using ProjectManagementSystem.Common.TaskEvent; 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 SystemEntranceV2 { public SystemEntranceV2() { 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; } //if (Common.Tibco.TibcoConnect.Instance == null) //{ // KillCurrentProcess(Langs.InitFailTibcoConnect); // return; //} TaskBookRegister taskBookRegister = new TaskBookRegister(); Task.Factory.StartNew(() => { SystemInitialize.SystemStarted(); SystemInitialize.InitLocationXY(); SystemInitialize.InitWMS(); SystemInitialize.InitSWMS(); SystemInitialize.InitWareHouse(); SystemInitialize.InitOperate(); SystemInitialize.InitAsyncBehavior(); if (PackControlCrms.Instance == null) { KillCurrentProcess(Langs.InitFailPackControl); return; } var taskBehavior = TaskBehavior.Instance; var taskEvent = new CTaskEvent(); }); } 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; } } }