123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- 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;
- }
- }
- }
|