Browse Source

完成 语音转文字、指纹、认证合一

master
胡超1 1 year ago
parent
commit
592fad6d5c
  1. 2
      CPF_Cef/AKS.EnterpriseLibrary.WebBrowser.csproj
  2. 19
      CPF_Cef/Common/ChunkedUpload.cs
  3. 13
      CPF_Cef/Devices/IDCard.cs
  4. 105
      CPF_Cef/Devices/LhtCF.cs
  5. 4
      CPF_Cef/FrmMain.cs
  6. 111
      CPF_Cef/MainModel.cs

2
CPF_Cef/AKS.EnterpriseLibrary.WebBrowser.csproj

@ -39,8 +39,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Fleck" Version="1.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SAEA.WebSocket" Version="7.23.9.24" />
<PackageReference Include="System.IO.Ports" Version="8.0.0" /> <PackageReference Include="System.IO.Ports" Version="8.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" /> <PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
<PackageReference Include="Xhm.CPF" Version="0.9.6.7" /> <PackageReference Include="Xhm.CPF" Version="0.9.6.7" />

19
CPF_Cef/Common/ChunkedUpload.cs

@ -182,7 +182,7 @@ namespace AksWebBrowser.Common
} }
/// <summary> /// <summary>
/// 文字转语音、录音与停止 /// 文字转语音
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<string> PostTTS(string type, int typeCode, string tts_text) public async Task<string> PostTTS(string type, int typeCode, string tts_text)
@ -191,7 +191,7 @@ namespace AksWebBrowser.Common
{ {
var client = new HttpClient(); var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl); var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl);
var content = new StringContent("{\r\n \"command\": \"tts\",\r\n \"command_num\": 201,\r\n \"data\": {\r\n \"operation\": \"" + type + "\",\r\n \"operation_code\": " + typeCode + ",\r\n \"parameters\": {\r\n \"data_type\": 1,\r\n \" tts_text\": \"" + tts_text + "\"}\r\n }\r\n}", null, "application/json"); var content = new StringContent("{\r\n \"command\": \"tts\",\r\n \"command_num\": 201,\r\n \"data\": {\r\n \"operation\": \"text_to_wav\",\r\n \"operation_code\": 1,\r\n \"parameters\": {\r\n \"data_type\": 1,\r\n \"tts_text\": \""+ tts_text + "\"\r\n }\r\n }\r\n }", null, "application/json");
request.Content = content; request.Content = content;
var response = await client.SendAsync(request); var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
@ -199,14 +199,22 @@ namespace AksWebBrowser.Common
{ {
// 读取响应内容 // 读取响应内容
string body = await response.Content.ReadAsStringAsync(); string body = await response.Content.ReadAsStringAsync();
Log.Info("文字转语音:" + body);
JObject jo = (JObject)JsonConvert.DeserializeObject(body); JObject jo = (JObject)JsonConvert.DeserializeObject(body);
string ret = jo["ret_info"].ToString(); string ret = jo["ret_info"].ToString();
JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret); JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret);
if (jo2["code"].ToString() == "0") if (jo2["code"].ToString() == "0")
{ {
//读取data数据 //读取data数据
string details = jo["details"].ToString(); //读取data数据
return details; string data = jo["data"].ToString();
JObject jo3 = (JObject)JsonConvert.DeserializeObject(data);
//读取parameters数据
string parameters = jo3["parameters"].ToString();
JObject jo4 = (JObject)JsonConvert.DeserializeObject(parameters);
//读取签字base64
string sound_path = jo4["sound_path"].ToString();
return sound_path;
} }
else else
{ {
@ -244,6 +252,7 @@ namespace AksWebBrowser.Common
{ {
// 读取响应内容 // 读取响应内容
string body = await response.Content.ReadAsStringAsync(); string body = await response.Content.ReadAsStringAsync();
Log.Info("获取指纹:" + body);
JObject jo = (JObject)JsonConvert.DeserializeObject(body); JObject jo = (JObject)JsonConvert.DeserializeObject(body);
string ret = jo["ret_info"].ToString(); string ret = jo["ret_info"].ToString();
JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret); JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret);
@ -304,6 +313,8 @@ namespace AksWebBrowser.Common
{ {
// 读取响应内容 // 读取响应内容
string body = await response.Content.ReadAsStringAsync(); string body = await response.Content.ReadAsStringAsync();
Log.Info("录音与停止:" + body);
JObject jo = (JObject)JsonConvert.DeserializeObject(body); JObject jo = (JObject)JsonConvert.DeserializeObject(body);
string ret = jo["ret_info"].ToString(); string ret = jo["ret_info"].ToString();
JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret); JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret);

13
CPF_Cef/Devices/IDCard.cs

@ -55,7 +55,7 @@ namespace AksWebBrowser.Devices
status = LibClass.ReadIDCardBaseMsg(Convert.ToInt32(icdev), 1, CHMsg, ref cLen, PHMsg, ref pLen, FPMsg, ref fLen); status = LibClass.ReadIDCardBaseMsg(Convert.ToInt32(icdev), 1, CHMsg, ref cLen, PHMsg, ref pLen, FPMsg, ref fLen);
if (status == 0) if (status == 0)
{ {
////生成base64 //生成base64
byte[] FileName = new byte[65536]; byte[] FileName = new byte[65536];
status = LibClass.ParseIDCardPic(PHMsg, 1024, 3, FileName); status = LibClass.ParseIDCardPic(PHMsg, 1024, 3, FileName);
@ -66,21 +66,20 @@ namespace AksWebBrowser.Devices
Directory.CreateDirectory(dirpath); Directory.CreateDirectory(dirpath);
} }
Log.Info(dirpath); Log.Info(dirpath);
var tempFile = dirpath + "/" + time + ".bmp"; var tempFile = dirpath + "/face.bmp";
//生成图片 //生成图片
LibClass.ParseIDCardPic(PHMsg, 1024, 2, Encoding.Default.GetBytes(tempFile)); LibClass.ParseIDCardPic(PHMsg, 1024, 2, Encoding.Default.GetBytes(tempFile));
//文件生成base64 //文件生成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);
iDCardModel.ImageBase64 = "data:image/jpg;base64," + txt.Substring(0, (txt.IndexOf("=") + 1)); iDCardModel.ImageBase64 = "data:image/jpg;base64," + txt.Substring(0, (txt.IndexOf("=") + 1));
//开启人脸比对 ////开启人脸比对
LhtCF lht = new LhtCF(); //LhtCF lht = new LhtCF();
string stat = lht.LhtCFFace(code, tempFile); //string stat = lht.LhtCFFace(code, tempFile);
if (stat == "0") if (true)//(stat == "100")
{ {
byte[] sCHMsg = new byte[520]; byte[] sCHMsg = new byte[520];
int itype = 0; int itype = 0;

105
CPF_Cef/Devices/LhtCF.cs

@ -8,8 +8,10 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AksWebBrowser.Devices namespace AksWebBrowser.Devices
@ -38,69 +40,41 @@ namespace AksWebBrowser.Devices
status = libLhtCFs.CF_Init(); status = libLhtCFs.CF_Init();
if (status == 0) if (status == 0)
{ {
//设置检测回调
status = libLhtCFs.CF_SetDetectCallBack(DetectCallBackPro, 0); //设置回调
status = libLhtCFs.CF_OpenCamera(); status = libLhtCFs.CF_OpenCamera();
if (status == 0) if (status == 0)
{
Task.Run(() =>
{ {
status = libLhtCFs.CF_CreatWindow(0, 0, 300, 800, 600, 500); status = libLhtCFs.CF_CreatWindow(0, 0, 300, 800, 600, 500);
if (status == 0) if (status == 0)
{ {
status = libLhtCFs.CF_StartLiveDetectEx(10000); status = libLhtCFs.CF_StartLiveDetectEx(10000);
if (status == 0)
{
string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
string dirpath = Utils.getSystemPaht() + @"/wwwroot/Face";
if (!Directory.Exists(dirpath))
{
Directory.CreateDirectory(dirpath);
}
var tempFile = dirpath + "/" + time + ".jpg";
status = libLhtCFs.CF_GetImage(0, Encoding.Default.GetBytes(tempFile));
Log.Info("人脸路径:" + tempFile);
byte[] faceA = File.ReadAllBytes(pathfile);
Log.Info("身份证图片路径:" + pathfile);
byte[] faceB = File.ReadAllBytes(tempFile);
int score = 0;
status = libLhtCFs.CF_FaceCompare(faceA, faceB, ref score);
Log.Info("人脸比对:" + status);
Log.Info("人脸值:" + score);
if (score > 60 && status == 0)
{
status = 0;
}
else
{
status = -1;
} }
} });
//关闭视频预览窗口 @event6.WaitOne();
Task.Run(() => { libLhtCFs.CF_CloseWindow(0); }); status = hdStatus;
} Log.Info("人脸比对结果:" + status);
//关闭摄像头
Task.Run(() => { libLhtCFs.CF_CloseCamera(); });
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
////关闭视频预览窗口 //反初始化
//Task.Run(() => { libLhtCFs.CF_CloseWindow(0); }); libLhtCFs.CF_Uninit();
////关闭摄像头
//Task.Run(() => { libLhtCFs.CF_CloseCamera(); });
Log.Info("双目摄像头采集人脸异常:" + ex.Message); Log.Info("双目摄像头采集人脸异常:" + ex.Message);
} }
return status.ToString(); return status.ToString();
} }
private static AutoResetEvent @event6 = new AutoResetEvent(false);
private static int hdStatus = -1;
//检测回调函数 //检测回调函数
public void DetectCallBackPro(int nResultID, IntPtr lpParam) public void DetectCallBackPro(int nResultID, int lpParam)
{
Log.Info("检测回调函数:" + nResultID);
}
public int DetectCallBackResult(int nResultID)
{ {
Log.Info("检测回调函数:" + nResultID);
if (nResultID == 100) if (nResultID == 100)
{
try
{ {
string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
string dirpath = Utils.getSystemPaht() + @"/wwwroot/Face"; string dirpath = Utils.getSystemPaht() + @"/wwwroot/Face";
@ -109,29 +83,42 @@ namespace AksWebBrowser.Devices
Directory.CreateDirectory(dirpath); Directory.CreateDirectory(dirpath);
} }
var tempFile = dirpath + "/" + time + ".jpg"; var tempFile = dirpath + "/" + time + ".jpg";
int status = libLhtCFs.CF_GetImage(0, Encoding.Default.GetBytes(tempFile)); hdStatus = libLhtCFs.CF_GetImage(0, Encoding.Default.GetBytes(tempFile));
Log.Info("人脸路径:" + tempFile);
byte[] faceA = File.ReadAllBytes(pathfile); byte[] faceA = File.ReadAllBytes(pathfile);
Log.Info("身份证图片路径:" + pathfile);
byte[] faceB = File.ReadAllBytes(tempFile); byte[] faceB = File.ReadAllBytes(tempFile);
int score = 0; int score = 0;
status = libLhtCFs.CF_FaceCompare(faceA, faceB, ref score); hdStatus = libLhtCFs.CF_FaceCompare(faceA, faceB, ref score);
Log.Info("人脸比对:" + status); if (score > 60 && hdStatus == 0)
Log.Info("人脸值:" + score);
if (score > 60 && status == 0)
{ {
status = 0; hdStatus = nResultID;
} }
else else
{ {
status = -1; hdStatus = -1;
} }
//关闭视频预览窗口 ////停止活体检测
Task.Run(() => { libLhtCFs.CF_CloseWindow(0); }); //libLhtCFs.CF_StopLiveDetect();
//关闭摄像头 ////关闭视频预览窗口
Task.Run(() => { libLhtCFs.CF_CloseCamera(); }); //libLhtCFs.CF_CloseWindow(0);
////关闭摄像头
//libLhtCFs.CF_CloseCamera();
//反初始化
libLhtCFs.CF_Uninit();
}
catch (Exception ex)
{
////停止活体检测
//libLhtCFs.CF_StopLiveDetect();
////关闭视频预览窗口
//libLhtCFs.CF_CloseWindow(0);
////关闭摄像头
//libLhtCFs.CF_CloseCamera();
//反初始化
libLhtCFs.CF_Uninit();
Log.Info("检测回调函数异常:" + ex.Message);
}
@event6.Set();
} }
return 0;
} }
} }
@ -140,7 +127,7 @@ namespace AksWebBrowser.Devices
public static int FeatureSize = 5120; public static int FeatureSize = 5120;
// 检测回调函数定义 // 检测回调函数定义
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void DetectCallBack(int nEventId, IntPtr lpContext); public delegate void DetectCallBack(int nEventId, int lpContext);
//RGB数据回调函数定义 //RGB数据回调函数定义
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
@ -164,7 +151,7 @@ namespace AksWebBrowser.Devices
//设置检测回调函数 //设置检测回调函数
[DllImport("libLhtCF", CallingConvention = CallingConvention.Cdecl)] [DllImport("libLhtCF", CallingConvention = CallingConvention.Cdecl)]
public static extern int CF_SetDetectCallBack(DetectCallBack pCB, IntPtr lpContext); public static extern int CF_SetDetectCallBack(DetectCallBack pCB, int lpContext);
//设置彩色摄像头视频流回调 //设置彩色摄像头视频流回调
[DllImport("libLhtCF", EntryPoint = "SetCamADataCallback", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] [DllImport("libLhtCF", EntryPoint = "SetCamADataCallback", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]

4
CPF_Cef/FrmMain.cs

@ -249,13 +249,13 @@ namespace AKS.EnterpriseLibrary.WebBrowser
else else
{ {
//Log.Info("未获取授权"); //Log.Info("未获取授权");
Utils.MessagesBox("未获取授权"); //Utils.MessagesBox("未获取授权");
} }
} }
else else
{ {
//Log.Info("未获取授权"); //Log.Info("未获取授权");
Utils.MessagesBox("未获取授权"); //Utils.MessagesBox("未获取授权");
} }
} }
Parame.FuncObject = list; Parame.FuncObject = list;

111
CPF_Cef/MainModel.cs

@ -5,6 +5,7 @@ using AKSWebBrowser.Commen;
using CPF.Cef; using CPF.Cef;
using CPF.Shapes; using CPF.Shapes;
using CPF.Windows; using CPF.Windows;
using Fleck;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System; using System;
@ -16,6 +17,8 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.WebSockets;
using System.Reflection.Metadata;
using System.Security.Authentication; using System.Security.Authentication;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -33,24 +36,29 @@ namespace AKS.EnterpriseLibrary.WebBrowser
public static void DeviceControllerInit() public static void DeviceControllerInit()
{ {
List<string> lit = new List<string>(); List<string> lit = new List<string>();
SAEA.WebSocket.WSServer ws = new SAEA.WebSocket.WSServer(19983); var server = new WebSocketServer("ws://0.0.0.0:19983");
ws.OnConnected += (s) => server.Start(socket =>
{
socket.OnOpen = () =>
{ {
string result = "{\"keycode\":\"" + "" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"连接成功\"}"; string result = "{\"keycode\":\"" + "" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"连接成功\"}";
byte[] bytes = SerializeContent(result); socket.Send(result);
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes));
Log.Error("请求连接" + s.ToString());
}; };
ws.OnMessage += (s, e) => socket.OnClose = () =>
{ {
string content = Encoding.UTF8.GetString(e.Content); string result = "{\"keycode\":\"" + "" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"连接关闭\"}";
socket.Send(result);
};
socket.OnMessage = message =>
{
string content = message;
//读取参数 //读取参数
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); Log.Error("收到请求:" + socket.ConnectionInfo.ClientIpAddress + " 请求参数:" + content);
if (!string.IsNullOrEmpty(content)) if (!string.IsNullOrEmpty(content))
{ {
try try
@ -120,8 +128,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser
//aks100109 //aks100109
//根据文件base64打印(PDF) { "code":"aks100109","base64":"ADFJLAKSDJFLKASJF...","ext":"pdf"} //根据文件base64打印(PDF) { "code":"aks100109","base64":"ADFJLAKSDJFLKASJF...","ext":"pdf"}
case "aks100109": case "aks100109":
//result = PrintBase64(content); result = PrintBase64(content);
result = "{\"keycode\":\"" + "aks100109" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"Base64打印保留原方式\"}"; //result = "{\"keycode\":\"" + "aks100109" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"Base64打印保留原方式\"}";
break; break;
//aks100110 //aks100110
//播放音频文件 { "code":"aks100110","url":"http://127.0.0.1/test.wav","ispaye":false} //播放音频文件 { "code":"aks100110","url":"http://127.0.0.1/test.wav","ispaye":false}
@ -157,12 +165,11 @@ 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);
try try
{ {
//答复请求者(处理完请求后在些答复) //答复请求者(处理完请求后在些答复)
byte[] bytes = SerializeContent(result); byte[] bytes = SerializeContent(result);
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes)); socket.Send(result);
} }
catch { result = "{\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"400\",\"status\":true,\"data\":\"返回参数失败\"}"; } catch { result = "{\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"400\",\"status\":true,\"data\":\"返回参数失败\"}"; }
finally { } finally { }
@ -171,26 +178,15 @@ namespace AKS.EnterpriseLibrary.WebBrowser
else if (content == "ping") else if (content == "ping")
{ {
string result = "{\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"收到客户端心跳\"}"; string result = "{\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"收到客户端心跳\"}";
byte[] bytes = SerializeContent(result); socket.Send(result);
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes));
} }
else else
{ {
string result = "{\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"收到客户端心跳\"}"; string result = "{\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"收到客户端心跳\"}";
byte[] bytes = SerializeContent(result); socket.Send(result);
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes));
} }
}; };
ws.OnDisconnected += (s) => });
{
try
{
Log.Error("断开连接" + s.ToString());
}
catch { }
finally { }
};
ws.Start();
} }
//解包 //解包
@ -234,11 +230,12 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
try try
{ {
//Finger("","");
IDCard iDCard = new IDCard(); IDCard iDCard = new IDCard();
string result = iDCard.getIdCard(code); string result = iDCard.getIdCard(code);
SubmitLogs(result, "IDCardRead"); SubmitLogs(result, "IDCardRead");
return result; //LhtCF lht = new LhtCF();
//string stat = lht.LhtCFFace(code, "/home/aks/aks/wwwroot/Face/20240529134642.bmp");
return "";
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -277,7 +274,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
if (!isFuncisFuncObject("SendByPrint")) if (!isFuncisFuncObject("SendByPrint"))
{ {
Utils.MessagesBox("打印排队票据设备未授权使用"); //Utils.MessagesBox("打印排队票据设备未授权使用");
return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "打印排队票据设备未授权使用" + "\"}"; return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "打印排队票据设备未授权使用" + "\"}";
} }
else else
@ -336,7 +333,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
bool ispaye = param.ispaye; bool ispaye = param.ispaye;
if (!isFuncisFuncObject("payleText")) if (!isFuncisFuncObject("payleText"))
{ {
Utils.MessagesBox("文字语音播报设备未授权使用"); //Utils.MessagesBox("文字语音播报设备未授权使用");
return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "文字语音播报设备未授权使用" + "\"}"; return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "文字语音播报设备未授权使用" + "\"}";
} }
else else
@ -472,7 +469,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
if (!isFuncisFuncObject("OpenSign")) if (!isFuncisFuncObject("OpenSign"))
{ {
Utils.MessagesBox("签字版设备未授权使用"); //Utils.MessagesBox("签字版设备未授权使用");
return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "签字版设备未授权使用" + "\"}"; return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "签字版设备未授权使用" + "\"}";
} }
else else
@ -505,7 +502,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
if (!isFuncisFuncObject("OpenSign")) if (!isFuncisFuncObject("OpenSign"))
{ {
Utils.MessagesBox("签字版设备未授权使用"); //Utils.MessagesBox("签字版设备未授权使用");
return "{\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "签字版设备未授权使用" + "\"}"; return "{\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "签字版设备未授权使用" + "\"}";
} }
else else
@ -542,7 +539,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
if (!isFuncisFuncObject("ReadFingerData")) if (!isFuncisFuncObject("ReadFingerData"))
{ {
Utils.MessagesBox("指纹设备未授权使用"); //Utils.MessagesBox("指纹设备未授权使用");
return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "指纹设备未授权使用" + "\"}"; return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "指纹设备未授权使用" + "\"}";
} }
else else
@ -564,7 +561,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser
SubmitLogs(result, "ReadFingerData"); SubmitLogs(result, "ReadFingerData");
return result; return result;
} }
else { else
{
Task.Run(() => { HttpPostResponseByFinger("open", 1); }); Task.Run(() => { HttpPostResponseByFinger("open", 1); });
event2.WaitOne(); event2.WaitOne();
string result = string.Empty; string result = string.Empty;
@ -623,9 +621,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
//结束录音上传文件 //结束录音上传文件
if (!string.IsNullOrEmpty(url) && !isopen) if (!string.IsNullOrEmpty(url) && !isopen)
{ {
Task.Run(() => { HttpPostResponseByRecord("stop_record", 3, ""); }); if (StopRecording())
event2.WaitOne();
if (string.IsNullOrEmpty(srpath))
{ {
Task.Run(async () => Task.Run(async () =>
{ {
@ -649,16 +645,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
} }
else if (isopen)//开始录音 else if (isopen)//开始录音
{ {
string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); if (StartRecording())
string dirpath = Utils.getSystemPaht() + @"/wwwroot/Record";
if (!Directory.Exists(dirpath))
{
Directory.CreateDirectory(dirpath);
}
string path = dirpath + "/" + time + ".wav";
Task.Run(() => { HttpPostResponseByRecord("start_record", 2, path); });
event2.WaitOne();
if (string.IsNullOrEmpty(srpath))
{ {
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + "开始录音" + "\"}"; string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + "开始录音" + "\"}";
SubmitLogs(result, "SoundRecording"); SubmitLogs(result, "SoundRecording");
@ -673,9 +660,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
} }
else //取消录音 else //取消录音
{ {
Task.Run(() => { HttpPostResponseByRecord("stop_record", 3, ""); }); if (StopRecording())
event2.WaitOne();
if (string.IsNullOrEmpty(srpath))
{ {
srpath = string.Empty; srpath = string.Empty;
string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + "取消录音" + "\"}"; string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + "取消录音" + "\"}";
@ -722,7 +707,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
string ext = param.ext; string ext = param.ext;
if (!isFuncisFuncObject("PrintFile")) if (!isFuncisFuncObject("PrintFile"))
{ {
Utils.MessagesBox("打印机设备未授权使用"); //Utils.MessagesBox("打印机设备未授权使用");
return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "打印机设备未授权使用" + "\"}"; return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "打印机设备未授权使用" + "\"}";
} }
else else
@ -774,15 +759,21 @@ namespace AKS.EnterpriseLibrary.WebBrowser
/// <param name="base64"></param> /// <param name="base64"></param>
/// <param name="ext"></param> /// <param name="ext"></param>
/// <returns></returns> /// <returns></returns>
[JSFunction] //[JSFunction]
public static string PrintBase64(string url, string base64, string ext) public static string PrintBase64(string content)
{ {
var param = content.ConvertToAnonymousType(new
{
code = default(string),
base64 = default(string),
ext = default(string)
});
try try
{ {
if (!isFuncisFuncObject("PrintBase64")) if (!isFuncisFuncObject("PrintBase64"))
{ {
Utils.MessagesBox("打印机设备未授权使用"); //Utils.MessagesBox("打印机设备未授权使用");
return "{\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "打印机设备未授权使用" + "\"}"; return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "打印机设备未授权使用" + "\"}";
} }
else else
{ {
@ -797,8 +788,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser
Directory.CreateDirectory(dirpath); Directory.CreateDirectory(dirpath);
} }
var filepath = System.IO.Path.Combine(dirpath, time); var filepath = System.IO.Path.Combine(dirpath, time);
string path = dirpath + @"/" + time + "." + ext; string path = dirpath + @"/" + time + "." + param.ext;
byte[] bytes = Convert.FromBase64String(base64); byte[] bytes = Convert.FromBase64String(param.base64);
System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.CreateNew); System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.CreateNew);
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
writer.Write(bytes, 0, bytes.Length); writer.Write(bytes, 0, bytes.Length);
@ -807,14 +798,14 @@ namespace AKS.EnterpriseLibrary.WebBrowser
string command = $"lp -d {PrinterName} {path}"; string command = $"lp -d {PrinterName} {path}";
ShllCommad(command); ShllCommad(command);
}); });
string result = "{\"keycode\":\"" + "" + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "打印成功" + "\"}"; string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "打印成功" + "\"}";
SubmitLogs(result, "PrintBase64"); SubmitLogs(result, "PrintBase64");
return result; return result;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
string result = "{\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}"; string result = "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
SubmitLogs(result, "PrintBase64"); SubmitLogs(result, "PrintBase64");
return result; return result;
} }
@ -840,7 +831,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
bool ispaly = param.ispaly; bool ispaly = param.ispaly;
if (!isFuncisFuncObject("PalyFile")) if (!isFuncisFuncObject("PalyFile"))
{ {
Utils.MessagesBox("音频设备未授权使用"); //Utils.MessagesBox("音频设备未授权使用");
return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "音频设备未授权使用" + "\"}"; return "{\"keycode\":\"" + param.code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "音频设备未授权使用" + "\"}";
} }
else else

Loading…
Cancel
Save