123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using ProjectManagementSystem.Common.Config;
- using ProjectManagementSystem.Common.Core;
- using ProjectManagementSystem.Common.TaskBookEvent;
- using ProjectManagementSystem.Common.TaskEvent;
- using ProjectManagementSystem.WebApi.Service;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ProjectManagementSystem.Enterance
- {
- public class SystemEntranceV2
- {
- public SystemEntranceV2()
- {
- if (ExcelConfig.Instance == null)
- {
- KillCurrentProcess("Excel配置加载失败,启动失败");
- return;
- }
- if (!SystemInitialize.InitDataSource())
- {
- KillCurrentProcess("数据库初始化失败,启动失败");
- return;
- }
- //if (RouteCalled.Instance == null)
- //{
- // KillCurrentProcess("初始化RouteCalled失败,启动失败");
- // return;
- //}
- if (PlcControl.Instance == null)
- {
- KillCurrentProcess("初始化Plc失败,启动失败");
- return;
- }
- if (DeviceControl.Instance == null)
- {
- KillCurrentProcess("初始化DeviceControl失败,启动失败");
- return;
- }
- //if (!WebApiServerHost.Instance.StartServer())
- //{
- // KillCurrentProcess("初始化WebApi失败,启动失败");
- // return;
- //}
- TaskBookRegister taskBookRegister = new TaskBookRegister();
- Task.Factory.StartNew(() =>
- {
- SystemInitialize.SystemStarted();
- SystemInitialize.InitWMS();
- SystemInitialize.InitWareHouse();
- SystemInitialize.InitOperate();
- SystemInitialize.InitAsyncBehavior();
- //SystemInitialize.InitLocationXY();
- //SystemInitialize.InitPmsAutoupdateXml();
- if (PackControl.Instance == null)
- {
- KillCurrentProcess("初始化PackControl失败,启动失败");
- return;
- }
- var taskBehavior = TaskBehavior.Instance;
- var taskEvent = new CTaskEvent();
- });
- }
- private void KillCurrentProcess(string logContext)
- {
- System.Windows.Forms.MessageBox.Show(logContext);
- System.Windows.Forms.Application.Exit();
- 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;
- }
- }
- }
|