Browse Source

新增异常补偿服务

master
胡超1 1 year ago
parent
commit
481093d225
  1. 24
      CPF_Cef/Common/WebSocketClientWithHeartbeat.cs
  2. 6
      CPF_Cef/MainModel.cs

24
CPF_Cef/Common/WebSocketClientWithHeartbeat.cs

@ -20,7 +20,7 @@ namespace AksWebBrowser.Common
private readonly string _serverUri;
private readonly ClientWebSocket _webSocket = new ClientWebSocket();
public string funName = string.Empty;
public bool isstop = true;
public bool isstop = true;
//开启定时
System.Timers.Timer timer = new System.Timers.Timer(30000);
public WebSocketClientWithHeartbeat()
@ -66,7 +66,27 @@ namespace AksWebBrowser.Common
{
JObject jo = (JObject)JsonConvert.DeserializeObject(body);
string functionName = jo["functionName"].ToString();
if (functionName == "LiveDetectResult")
if (functionName == "CF_OpenCamera")
{
string status = jo["success"].ToString();
if (status == "0")
{
//开始活检
Send("{\"function\":\"CF_StartLiveDetect\"}", "CF_StartLiveDetect");
}
else
{
timer.Stop();
// 断开连接
_webSocket.Dispose();
isstop = false;
string commod = "cd /opt/lhtserver/files/bin && nohup ./LhtCamServer.sh &";
MainModel.Bash(commod);
Task.Delay(1000).Wait();
MainModel.StartFace();
}
}
else if (functionName == "LiveDetectResult")
{
Log.Error("LiveDetectResult" + "活检准备");
string status = string.Empty;

6
CPF_Cef/MainModel.cs

@ -1780,7 +1780,7 @@ namespace AksWebBrowser
/// </summary>
private static string smresults = string.Empty;
private static AutoResetEvent @event9 = new AutoResetEvent(false);
private static void StartFace()
public static void StartFace()
{
try
{
@ -1796,8 +1796,6 @@ namespace AksWebBrowser
};
//打开摄像头
webSocket.Send(JsonConvert.SerializeObject(mode), "CF_OpenCamera");
//开始活检
webSocket.Send("{\"function\":\"CF_StartLiveDetect\"}", "CF_StartLiveDetect");
}
catch (Exception ex)
{
@ -2245,7 +2243,7 @@ namespace AksWebBrowser
string zxjg = Bash(commod);
if (string.IsNullOrEmpty(zxjg))
{
commod = "chmod -R 777 /opt/lhtserver/files/bin && cd /opt/lhtserver/files/bin && nohup ./LhtCamServer.sh &";
commod = "cd /opt/lhtserver/files/bin && nohup ./LhtCamServer.sh &";
Bash(commod);
Task.Delay(3000).Wait();
}

Loading…
Cancel
Save