diff --git a/CPF_Cef/Common/ChunkedUpload.cs b/CPF_Cef/Common/ChunkedUpload.cs index 6ee5d5d..607f73e 100644 --- a/CPF_Cef/Common/ChunkedUpload.cs +++ b/CPF_Cef/Common/ChunkedUpload.cs @@ -48,6 +48,7 @@ namespace AksWebBrowser.Common fileStream.Dispose(); ret = responseString; JObject jo = (JObject)JsonConvert.DeserializeObject(ret); + Log.Error("上传文件返回:" + ret); if (Convert.ToBoolean(jo["IsSucceed"].ToString()) == true) { string result = jo["result"].ToString(); diff --git a/CPF_Cef/Devices/IDCard.cs b/CPF_Cef/Devices/IDCard.cs index e726aa0..f0234fd 100644 --- a/CPF_Cef/Devices/IDCard.cs +++ b/CPF_Cef/Devices/IDCard.cs @@ -69,9 +69,10 @@ namespace AksWebBrowser.Devices //var tempFile = dirpath + "/" + time + ".bmp"; ////生成图片 //LibClass.ParseIDCardPic(PHMsg, 1024, 2, Encoding.Default.GetBytes(tempFile)); - + ////文件生成base64 //byte[] byteArray = File.ReadAllBytes(tempFile); //string base64String = Convert.ToBase64String(byteArray); + //Log.Info($"{base64String}"); if (status == 0) { string txt = Encoding.UTF8.GetString(FileName); @@ -79,7 +80,7 @@ namespace AksWebBrowser.Devices ////开启人脸比对 //LhtCF lht = new LhtCF(); //string stat = lht.LhtCFFace(code, tempFile); - if (true) + if (true)//(stat == "0") { byte[] sCHMsg = new byte[520]; int itype = 0; diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs index a3dc542..fb8179d 100644 --- a/CPF_Cef/MainModel.cs +++ b/CPF_Cef/MainModel.cs @@ -43,13 +43,13 @@ namespace AKS.EnterpriseLibrary.WebBrowser ws.OnMessage += (s, e) => { string content = Encoding.UTF8.GetString(e.Content); - Log.Error("收到请求:" + s.ToString() + " 请求参数:" + content); //读取参数 if (content != "ping" && !string.IsNullOrEmpty(content)) { //返回内容 string result = string.Empty; content = Base64str2(content); + Log.Error("收到请求:" + s.ToString() + " 请求参数:" + content); if (!string.IsNullOrEmpty(content)) { try @@ -151,9 +151,14 @@ namespace AKS.EnterpriseLibrary.WebBrowser result = "{\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}"; } Log.Error("答复请求者:" + s.ToString() + " 返回数据:" + result); - //答复请求者(处理完请求后在些答复) - byte[] bytes = SerializeContent(result); - ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes)); + try + { + //答复请求者(处理完请求后在些答复) + 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作为关键字” else if (content == "ping") @@ -351,7 +356,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser { //Log.Error("停止失败: " + ex.Message + ""); } - //AutoAudio(false, ""); + // AutoAudio(false, ""); }); string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}"; SubmitLogs(result, "payleText"); @@ -363,7 +368,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser { //形成语音 tempWav = GenerateWavFromText(text); - ////开始播放 + //////开始播放 string command = $"sox {tempWav} -d"; ShllCommad(command); //AutoAudio(true, tempWav); @@ -462,7 +467,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser } else { - Task.Run(() => { HttpPostResponseBySign("open", 1, param.code); event2.WaitOne(); }); + Task.Run(() => { HttpPostResponseBySign("open", 1, param.code); }); + event2.WaitOne(); string result = sginStr; SubmitLogs(result, "OpenSign"); return result; @@ -581,6 +587,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser Regex re = new Regex(@"(((?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(:[0-9]+)?|(?:ww‌​w.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?‌​(?:[\w]*))?)"); MatchCollection mc = re.Matches(url);//获取的是一个数组 string reurl = mc[0].ToString() + "://" + mc[1].ToString() + urlpath; + string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + reurl + "\"}"; SubmitLogs(result, "SoundRecording"); return result; @@ -783,18 +790,18 @@ namespace AKS.EnterpriseLibrary.WebBrowser { Task.Run(() => { - //if (Typrocess != null) - //{ - // // 如果进程还在运行 - // if (!Typrocess.HasExited) - // { - // // 发送SIGTERM信号来停止进程 - // Typrocess.Kill(); - // // 等待进程真正停止 - // Typrocess.WaitForExit(); - // } - //} - AutoAudio(ispaly, ""); + if (Typrocess != null) + { + // 如果进程还在运行 + if (!Typrocess.HasExited) + { + // 发送SIGTERM信号来停止进程 + Typrocess.Kill(); + // 等待进程真正停止 + Typrocess.WaitForExit(); + } + } + //AutoAudio(ispaly, ""); }); string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":" + "停止播放成功" + "}"; SubmitLogs(result, "PalyFile"); @@ -830,9 +837,9 @@ namespace AKS.EnterpriseLibrary.WebBrowser response.Close(); //开始播放 - //string command = $"sox {path} -d"; - //ShllCommad(command); - AutoAudio(ispaly, path); + string command = $"sox {path} -d"; + ShllCommad(command); + //AutoAudio(ispaly, path); }); string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":" + "开始播放" + "}"; SubmitLogs(result, "PalyFile"); @@ -1296,12 +1303,15 @@ namespace AKS.EnterpriseLibrary.WebBrowser { try { - // 如果进程还在运行 - if (!recordingProcess.HasExited) + if (recordingProcess != null) { - // 发送SIGTERM信号来停止arecord进程 - recordingProcess.Kill(); - recordingProcess.WaitForExit(); // 等待进程真正停止 + // 如果进程还在运行 + if (!recordingProcess.HasExited) + { + // 发送SIGTERM信号来停止arecord进程 + recordingProcess.Kill(); + recordingProcess.WaitForExit(); // 等待进程真正停止 + } } return true; }