diff --git a/BPASmartClient.ScreenLib/AppMain.cs b/BPASmartClient.ScreenLib/AppMain.cs
index 9ee9a81b..363531eb 100644
--- a/BPASmartClient.ScreenLib/AppMain.cs
+++ b/BPASmartClient.ScreenLib/AppMain.cs
@@ -18,7 +18,7 @@ namespace BPASmartClient.ScreenLib
//启动Redis数据读取
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
FSystemHelper.GetInstance.CreateDesktopShortcut();
- // FSystemHelper.GetInstance.AutoStart(true);
+ //FSystemHelper.GetInstance.AutoStart(true);
WindowLargeScreen windowLarge = new WindowLargeScreen();
#region 设置显示页面与标题
string TitleName = $"{type.Assembly.ManifestModule.Name.Replace(".dll", "")}";
diff --git a/BPASmartClient.ScreenLib/Helper/Main.cs b/BPASmartClient.ScreenLib/Helper/Main.cs
index 961411c0..8636109d 100644
--- a/BPASmartClient.ScreenLib/Helper/Main.cs
+++ b/BPASmartClient.ScreenLib/Helper/Main.cs
@@ -5,6 +5,7 @@ using IWshRuntimeLibrary;
using Microsoft.Web.WebView2.Wpf;
using Newtonsoft.Json;
using System;
+using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
@@ -168,12 +169,35 @@ namespace BPASmartClient.ScreenLib
///
public void StartServer()
{
+ string path = System.Configuration.ConfigurationManager.AppSettings["StartServer"].ToString();
+ string processName = "";
+
try
{
- string path = System.Configuration.ConfigurationManager.AppSettings["StartServer"].ToString();
if (System.IO.File.Exists(path))
{
- Process.Start(path);
+ processName = System.IO.Path.GetFileNameWithoutExtension(path);
+ if (!IsProcess(processName))
+ {
+ Process.Start(path);
+ }
+
+
+ ThreadManage.GetInstance().StartLong(new Action(() =>
+ {
+ try
+ {
+ if (!IsProcess(processName))
+ {
+ Process.Start(path);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageLog.GetInstance.ShowEx($"{Name}:线程服务异常,原因:{ex.Message}");
+ }
+ Thread.Sleep(3000);
+ }), $"{Name},进程监控");
}
}
catch (Exception ex)
@@ -181,6 +205,46 @@ namespace BPASmartClient.ScreenLib
}
}
+
+ public bool IsProcess(string procName)
+ {
+ bool isProcess = false;
+ Process[] ps = Process.GetProcessesByName(procName);
+ if (ps.Length > 0)
+ {
+ isProcess=true;
+ }
+ return isProcess;
+ }
+ ///
+ /// 关闭进程
+ ///
+ ///
+ ///
+ public bool CloseProc(string procName)
+ {
+ bool result = false;
+ ArrayList procList = new ArrayList();
+ string tempName;
+ int begpos;
+ int endpos;
+ foreach (Process thisProc in Process.GetProcesses())
+ {
+ tempName = thisProc.ToString();
+ begpos = tempName.IndexOf("(") + 1;
+ endpos = tempName.IndexOf(")");
+ tempName = tempName[begpos..endpos];
+ procList.Add(tempName);
+ if (tempName == procName)
+ {
+ if (!thisProc.CloseMainWindow())
+ // 当发送关闭窗口命令无效时强行结束进程
+ thisProc.Kill();
+ result = true;
+ }
+ }
+ return result;
+ }
///
/// 停止服务
///
diff --git a/BPASmartClient.ScreenSplitMeals/App.config b/BPASmartClient.ScreenSplitMeals/App.config
index 48ea2863..afd11df9 100644
--- a/BPASmartClient.ScreenSplitMeals/App.config
+++ b/BPASmartClient.ScreenSplitMeals/App.config
@@ -9,7 +9,7 @@
-
+