Browse Source

提交初版

master
胡超1 1 year ago
parent
commit
564ef93b85
  1. 1
      CPF_Cef/Common/ChunkedUpload.cs
  2. 5
      CPF_Cef/Devices/IDCard.cs
  3. 64
      CPF_Cef/MainModel.cs

1
CPF_Cef/Common/ChunkedUpload.cs

@ -48,6 +48,7 @@ namespace AksWebBrowser.Common
fileStream.Dispose(); fileStream.Dispose();
ret = responseString; ret = responseString;
JObject jo = (JObject)JsonConvert.DeserializeObject(ret); JObject jo = (JObject)JsonConvert.DeserializeObject(ret);
Log.Error("上传文件返回:" + ret);
if (Convert.ToBoolean(jo["IsSucceed"].ToString()) == true) if (Convert.ToBoolean(jo["IsSucceed"].ToString()) == true)
{ {
string result = jo["result"].ToString(); string result = jo["result"].ToString();

5
CPF_Cef/Devices/IDCard.cs

@ -69,9 +69,10 @@ namespace AksWebBrowser.Devices
//var tempFile = dirpath + "/" + time + ".bmp"; //var tempFile = dirpath + "/" + time + ".bmp";
////生成图片 ////生成图片
//LibClass.ParseIDCardPic(PHMsg, 1024, 2, Encoding.Default.GetBytes(tempFile)); //LibClass.ParseIDCardPic(PHMsg, 1024, 2, Encoding.Default.GetBytes(tempFile));
////文件生成base64
//byte[] byteArray = File.ReadAllBytes(tempFile); //byte[] byteArray = File.ReadAllBytes(tempFile);
//string base64String = Convert.ToBase64String(byteArray); //string base64String = Convert.ToBase64String(byteArray);
//Log.Info($"{base64String}");
if (status == 0) if (status == 0)
{ {
string txt = Encoding.UTF8.GetString(FileName); string txt = Encoding.UTF8.GetString(FileName);
@ -79,7 +80,7 @@ namespace AksWebBrowser.Devices
////开启人脸比对 ////开启人脸比对
//LhtCF lht = new LhtCF(); //LhtCF lht = new LhtCF();
//string stat = lht.LhtCFFace(code, tempFile); //string stat = lht.LhtCFFace(code, tempFile);
if (true) if (true)//(stat == "0")
{ {
byte[] sCHMsg = new byte[520]; byte[] sCHMsg = new byte[520];
int itype = 0; int itype = 0;

64
CPF_Cef/MainModel.cs

@ -43,13 +43,13 @@ namespace AKS.EnterpriseLibrary.WebBrowser
ws.OnMessage += (s, e) => ws.OnMessage += (s, e) =>
{ {
string content = Encoding.UTF8.GetString(e.Content); string content = Encoding.UTF8.GetString(e.Content);
Log.Error("收到请求:" + s.ToString() + " 请求参数:" + content);
//读取参数 //读取参数
if (content != "ping" && !string.IsNullOrEmpty(content)) if (content != "ping" && !string.IsNullOrEmpty(content))
{ {
//返回内容 //返回内容
string result = string.Empty; string result = string.Empty;
content = Base64str2(content); content = Base64str2(content);
Log.Error("收到请求:" + s.ToString() + " 请求参数:" + content);
if (!string.IsNullOrEmpty(content)) if (!string.IsNullOrEmpty(content))
{ {
try try
@ -151,9 +151,14 @@ namespace AKS.EnterpriseLibrary.WebBrowser
result = "{\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}"; result = "{\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}";
} }
Log.Error("答复请求者:" + s.ToString() + " 返回数据:" + result); Log.Error("答复请求者:" + s.ToString() + " 返回数据:" + result);
//答复请求者(处理完请求后在些答复) try
byte[] bytes = SerializeContent(result); {
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes)); //答复请求者(处理完请求后在些答复)
byte[] bytes = SerializeContent(result);
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes));
}
catch { result = "{\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"400\",\"status\":true,\"data\":\"返回参数失败\"}"; }
finally { }
} }
//监听心跳并且回复客户端“已ping作为关键字” //监听心跳并且回复客户端“已ping作为关键字”
else if (content == "ping") else if (content == "ping")
@ -351,7 +356,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
//Log.Error("停止失败: " + ex.Message + ""); //Log.Error("停止失败: " + ex.Message + "");
} }
//AutoAudio(false, ""); // AutoAudio(false, "");
}); });
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}"; string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}";
SubmitLogs(result, "payleText"); SubmitLogs(result, "payleText");
@ -363,7 +368,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
//形成语音 //形成语音
tempWav = GenerateWavFromText(text); tempWav = GenerateWavFromText(text);
////开始播放 //////开始播放
string command = $"sox {tempWav} -d"; string command = $"sox {tempWav} -d";
ShllCommad(command); ShllCommad(command);
//AutoAudio(true, tempWav); //AutoAudio(true, tempWav);
@ -462,7 +467,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser
} }
else else
{ {
Task.Run(() => { HttpPostResponseBySign("open", 1, param.code); event2.WaitOne(); }); Task.Run(() => { HttpPostResponseBySign("open", 1, param.code); });
event2.WaitOne();
string result = sginStr; string result = sginStr;
SubmitLogs(result, "OpenSign"); SubmitLogs(result, "OpenSign");
return result; return result;
@ -581,6 +587,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
Regex re = new Regex(@"(((?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(:[0-9]+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)"); Regex re = new Regex(@"(((?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(:[0-9]+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)");
MatchCollection mc = re.Matches(url);//获取的是一个数组 MatchCollection mc = re.Matches(url);//获取的是一个数组
string reurl = mc[0].ToString() + "://" + mc[1].ToString() + urlpath; string reurl = mc[0].ToString() + "://" + mc[1].ToString() + urlpath;
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + reurl + "\"}"; string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + reurl + "\"}";
SubmitLogs(result, "SoundRecording"); SubmitLogs(result, "SoundRecording");
return result; return result;
@ -783,18 +790,18 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
Task.Run(() => Task.Run(() =>
{ {
//if (Typrocess != null) if (Typrocess != null)
//{ {
// // 如果进程还在运行 // 如果进程还在运行
// if (!Typrocess.HasExited) if (!Typrocess.HasExited)
// { {
// // 发送SIGTERM信号来停止进程 // 发送SIGTERM信号来停止进程
// Typrocess.Kill(); Typrocess.Kill();
// // 等待进程真正停止 // 等待进程真正停止
// Typrocess.WaitForExit(); Typrocess.WaitForExit();
// } }
//} }
AutoAudio(ispaly, ""); //AutoAudio(ispaly, "");
}); });
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":" + "停止播放成功" + "}"; string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":" + "停止播放成功" + "}";
SubmitLogs(result, "PalyFile"); SubmitLogs(result, "PalyFile");
@ -830,9 +837,9 @@ namespace AKS.EnterpriseLibrary.WebBrowser
response.Close(); response.Close();
//开始播放 //开始播放
//string command = $"sox {path} -d"; string command = $"sox {path} -d";
//ShllCommad(command); ShllCommad(command);
AutoAudio(ispaly, path); //AutoAudio(ispaly, path);
}); });
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":" + "开始播放" + "}"; string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":" + "开始播放" + "}";
SubmitLogs(result, "PalyFile"); SubmitLogs(result, "PalyFile");
@ -1296,12 +1303,15 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
try try
{ {
// 如果进程还在运行 if (recordingProcess != null)
if (!recordingProcess.HasExited)
{ {
// 发送SIGTERM信号来停止arecord进程 // 如果进程还在运行
recordingProcess.Kill(); if (!recordingProcess.HasExited)
recordingProcess.WaitForExit(); // 等待进程真正停止 {
// 发送SIGTERM信号来停止arecord进程
recordingProcess.Kill();
recordingProcess.WaitForExit(); // 等待进程真正停止
}
} }
return true; return true;
} }

Loading…
Cancel
Save