Browse Source

提交签字

master
胡超1 1 year ago
parent
commit
cff323bc39
  1. 34
      CPF_Cef/Common/COMUtils.cs
  2. 121
      CPF_Cef/Common/ChunkedUpload.cs
  3. 30
      CPF_Cef/Devices/Fingerprint.cs
  4. 105
      CPF_Cef/Devices/IDCard.cs
  5. 88
      CPF_Cef/Devices/LhtCF.cs
  6. 6
      CPF_Cef/Devices/PrintPJ.cs
  7. 6
      CPF_Cef/FrmMain.cs
  8. 463
      CPF_Cef/MainModel.cs
  9. 2
      CPF_Cef/Parame.cs
  10. 3
      CPF_Cef/Ramark.txt
  11. 19
      CPF_Cef/Results.cs

34
CPF_Cef/Common/COMUtils.cs

@ -49,7 +49,7 @@ namespace AKSWebBrowser.Common
if (!string.IsNullOrEmpty(parm)) if (!string.IsNullOrEmpty(parm))
{ {
ml = "/dev/" + parm; ml = "/dev/" + parm;
//Log.Info("输出结果:" + ml); //// Log.Info("输出结果:" + ml);
//给管理权限 //给管理权限
LinuxCmd(ml); LinuxCmd(ml);
//打开串口 //打开串口
@ -73,21 +73,21 @@ namespace AKSWebBrowser.Common
timer.Elapsed += OnTimedEvent; timer.Elapsed += OnTimedEvent;
timer.AutoReset = true;//重复执行 timer.AutoReset = true;//重复执行
timer.Enabled = true;//启动定时器 timer.Enabled = true;//启动定时器
//Log.Info("浏览器COM服务启动成功"); //// Log.Info("浏览器COM服务启动成功");
} }
else else
{ {
//Log.Info("串口类型不匹配"); //// Log.Info("串口类型不匹配");
} }
} }
else else
{ {
//Log.Info("当前设备没有串口设备"); //// Log.Info("当前设备没有串口设备");
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
//Log.Info("服务启动异常ex: " + ex.Message + ""); //// Log.Info("服务启动异常ex: " + ex.Message + "");
} }
} }
@ -121,7 +121,7 @@ namespace AKSWebBrowser.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
//Log.Info("接受数据数据异常: " + ex.Message + ""); //// Log.Info("接受数据数据异常: " + ex.Message + "");
jsonstr = MainModel.str2Base64("{\"callback\":\"" + this.callback + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "接受数据数据超时:" + ex.Message + "\"}"); jsonstr = MainModel.str2Base64("{\"callback\":\"" + this.callback + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "接受数据数据超时:" + ex.Message + "\"}");
// CShaseBJavaScript(jsonstr); // CShaseBJavaScript(jsonstr);
} }
@ -139,7 +139,7 @@ namespace AKSWebBrowser.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
//Log.Info("定时任务打开串口异常: " + ex.Message + ""); //// Log.Info("定时任务打开串口异常: " + ex.Message + "");
} }
} }
@ -155,7 +155,7 @@ namespace AKSWebBrowser.Common
jsonstr = string.Empty; jsonstr = string.Empty;
//写入数据并以换行符结束 //写入数据并以换行符结束
serialPort.WriteLine(data); serialPort.WriteLine(data);
//Log.Info("发送数据成功: " + data + ""); //// Log.Info("发送数据成功: " + data + "");
while (string.IsNullOrEmpty(jsonstr)) while (string.IsNullOrEmpty(jsonstr))
{ {
Task.Delay(10).Wait(); Task.Delay(10).Wait();
@ -171,7 +171,7 @@ namespace AKSWebBrowser.Common
jsonstr = string.Empty; jsonstr = string.Empty;
//写入数据并以换行符结束 //写入数据并以换行符结束
serialPort.WriteLine(data); serialPort.WriteLine(data);
//Log.Info("发送数据成功: " + data + ""); //// Log.Info("发送数据成功: " + data + "");
while (string.IsNullOrEmpty(jsonstr)) while (string.IsNullOrEmpty(jsonstr))
{ {
Task.Delay(10).Wait(); Task.Delay(10).Wait();
@ -181,7 +181,7 @@ namespace AKSWebBrowser.Common
{ {
jsontemp = string.Empty; jsontemp = string.Empty;
jsonstr = string.Empty; jsonstr = string.Empty;
//Log.Info("发送数据失败"); //// Log.Info("发送数据失败");
jsonstr = MainModel.str2Base64("{\"callback\":\"" + this.callback + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "串口未打开" + "\"}"); jsonstr = MainModel.str2Base64("{\"callback\":\"" + this.callback + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "串口未打开" + "\"}");
//CShaseBJavaScript(jsonstr); //CShaseBJavaScript(jsonstr);
} }
@ -191,7 +191,7 @@ namespace AKSWebBrowser.Common
{ {
jsontemp = string.Empty; jsontemp = string.Empty;
jsonstr = string.Empty; jsonstr = string.Empty;
//Log.Info("发送数据异常3: " + ex.Message + ""); //// Log.Info("发送数据异常3: " + ex.Message + "");
jsonstr = MainModel.str2Base64("{\"callback\":\"" + this.callback + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "发送数据异常:" + ex.Message + "\"}"); jsonstr = MainModel.str2Base64("{\"callback\":\"" + this.callback + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "发送数据异常:" + ex.Message + "\"}");
//CShaseBJavaScript(jsonstr); //CShaseBJavaScript(jsonstr);
} }
@ -251,19 +251,19 @@ namespace AKSWebBrowser.Common
Task.Run(async () => Task.Run(async () =>
{ {
param = MainModel.Base64str2(param); param = MainModel.Base64str2(param);
//Log.Info("返回数据:" + param); //// Log.Info("返回数据:" + param);
JObject jo = (JObject)JsonConvert.DeserializeObject(param); JObject jo = (JObject)JsonConvert.DeserializeObject(param);
bool fieldExists = jo.ContainsKey("callback"); bool fieldExists = jo.ContainsKey("callback");
if (fieldExists) if (fieldExists)
{ {
string callback = jo["callback"].ToString(); string callback = jo["callback"].ToString();
//Log.Info("回调js方法:" + callback); //// Log.Info("回调js方法:" + callback);
string _parm = callback + "('" + param + "')"; string _parm = callback + "('" + param + "')";
await Parame.webBrowser.ExecuteJavaScript(_parm); await Parame.webBrowser.ExecuteJavaScript(_parm);
} }
else else
{ {
//Log.Info("回调js方法为空"); //// Log.Info("回调js方法为空");
} }
}); });
} }
@ -272,7 +272,7 @@ namespace AKSWebBrowser.Common
public void LinuxCmd(string command) public void LinuxCmd(string command)
{ {
command = $"echo 'aks@123456' sudo -S chmod 777 {command}"; command = $"echo 'aks@123456' sudo -S chmod 777 {command}";
//Log.Info("执行命令:" + command); //// Log.Info("执行命令:" + command);
// 启动进程 // 启动进程
var process = new Process var process = new Process
{ {
@ -290,8 +290,8 @@ namespace AKSWebBrowser.Common
string output = process.StandardOutput.ReadToEnd(); string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd(); string error = process.StandardError.ReadToEnd();
process.WaitForExit(); process.WaitForExit();
//Log.Info("执行命令结果返回:" + output); //// Log.Info("执行命令结果返回:" + output);
//Log.Info("执行命令错误结果返回:" + error); //// Log.Info("执行命令错误结果返回:" + error);
} }
//执行命令返回数组 //执行命令返回数组

121
CPF_Cef/Common/ChunkedUpload.cs

@ -14,6 +14,10 @@ using System.Collections;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using AKS.EnterpriseLibrary.WebBrowser; using AKS.EnterpriseLibrary.WebBrowser;
using System.Globalization; using System.Globalization;
using CPF;
using CPF.Windows;
using static System.Net.Mime.MediaTypeNames;
using System.Text.RegularExpressions;
namespace AksWebBrowser.Common namespace AksWebBrowser.Common
{ {
@ -49,7 +53,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); Log.Info("上传文件返回:" + 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();
@ -69,6 +73,41 @@ namespace AksWebBrowser.Common
public async Task<string> getReq(string query) public async Task<string> getReq(string query)
{ {
string ret = string.Empty; string ret = string.Empty;
ret = await NewMethod(query, ret);
if (query.Contains("getFrame"))
{
string img = string.Empty;
int num = 0;
while (string.IsNullOrEmpty(img) && num < 5)
{
JObject jo = (JObject)JsonConvert.DeserializeObject(ret);
if (jo["returnCode"].ToString() == "0")
{
string data = jo["data"].ToString();
JObject jo1 = (JObject)JsonConvert.DeserializeObject(data);
//Log.Info("img" + num + (jo1["img"].ToString()));
if (string.IsNullOrEmpty(jo1["img"].ToString()))
{
ret = await NewMethod(query, ret);
}
else
{
img = jo1["img"].ToString();
num = 6;
}
}
else
{
ret = await NewMethod(query, ret);
}
num++;
}
}
return ret;
}
private static async Task<string> NewMethod(string query, string ret)
{
using (var httpClient = new HttpClient()) using (var httpClient = new HttpClient())
{ {
// 构建带参数的请求URI // 构建带参数的请求URI
@ -90,6 +129,7 @@ namespace AksWebBrowser.Common
//Log.Error(" get请求: " + e.Message); //Log.Error(" get请求: " + e.Message);
} }
} }
return ret; return ret;
} }
@ -124,32 +164,19 @@ namespace AksWebBrowser.Common
//读取parameters数据 //读取parameters数据
string parameters = jo3["parameters"].ToString(); string parameters = jo3["parameters"].ToString();
JObject jo4 = (JObject)JsonConvert.DeserializeObject(parameters); JObject jo4 = (JObject)JsonConvert.DeserializeObject(parameters);
//读取签字base64 string sign_pic_path = jo4["sign_pic_path"].ToString();
string sign_pic = jo4["sign_pic"].ToString();
string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); string dirpath = Utils.getSystemPaht() + @"/wwwroot/SignFile";
string dirpath = Utils.getSystemPaht() + @"/wwwroot/FileTxt";
if (!Directory.Exists(dirpath)) if (!Directory.Exists(dirpath))
{ {
Directory.CreateDirectory(dirpath); Directory.CreateDirectory(dirpath);
} }
var tempFile = dirpath + "/" + time + ".txt"; var tempFile = dirpath + "/sign.jpg";
using (StreamWriter sw = new StreamWriter(tempFile)) string command = $"convert {sign_pic_path} -quality 10 {tempFile}";
{ MainModel.ShllCommad(command);
sw.Write(sign_pic); byte[] byteArray = File.ReadAllBytes(tempFile);
sw.Close(); string base64String = Convert.ToBase64String(byteArray);
sw.Dispose(); return "{\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":200,\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + base64String + "\"}";
}
string base64 = "";
string[] lines = File.ReadAllLines(tempFile);
foreach (string line in lines)
{
base64 = base64 + line;
}
File.Delete(tempFile);
//读取签字版主动回复数据
//"data:image/png;base64, " +
//Log.Info("读取签字版主动回复数据" + base64);
return "{\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"png\",\"data\":\"" + base64 + "\"}";
} }
else else
{ {
@ -191,7 +218,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\": \"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"); 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,7 +226,7 @@ namespace AksWebBrowser.Common
{ {
// 读取响应内容 // 读取响应内容
string body = await response.Content.ReadAsStringAsync(); string body = await response.Content.ReadAsStringAsync();
Log.Info("文字转语音:" + body); // 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);
@ -252,7 +279,7 @@ namespace AksWebBrowser.Common
{ {
// 读取响应内容 // 读取响应内容
string body = await response.Content.ReadAsStringAsync(); string body = await response.Content.ReadAsStringAsync();
Log.Info("获取指纹:" + body); // 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);
@ -296,16 +323,16 @@ namespace AksWebBrowser.Common
} }
/// <summary> /// <summary>
/// 录音与停止 /// 读取身份证
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<string> PostRecord(string type, int typeCode, string path) public async Task<string> OpenGetIdcard(string type, int typeCode)
{ {
try try
{ {
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\": \"" + path + "\"}\r\n }\r\n}", null, "application/json"); var content = new StringContent("{\r\n \"command\": \"idcard\",\r\n \"command_num\": 141,\r\n \"data\": {\r\n \"operation\": \"open\",\r\n \"operation_code\": 1,\r\n \"parameters\": {\r\n }\r\n }\r\n}", null, "text/plain");
request.Content = content; request.Content = content;
var response = await client.SendAsync(request); var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
@ -313,16 +340,42 @@ 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数据 //读取指纹
string details = jo["details"].ToString(); if (typeCode == 1)
return details; {
//读取data数据
string data = jo["data"].ToString();
JObject jo3 = (JObject)JsonConvert.DeserializeObject(data);
//读取parameters数据
string parameters = jo3["parameters"].ToString();
JObject jo4 = (JObject)JsonConvert.DeserializeObject(parameters);
IDCardModel iDCardModel = new IDCardModel();
iDCardModel.Name = jo4["cn_name"].ToString();
iDCardModel.Sex = jo4["sex"].ToString();
iDCardModel.Nation = jo4["nation"].ToString();
iDCardModel.BirthDay = jo4["birth_date"].ToString();
iDCardModel.Addr = jo4["address"].ToString();
iDCardModel.Id = jo4["idcard_number"].ToString();
iDCardModel.Regorg = jo4["deparment"].ToString();
iDCardModel.StartDate = jo4["validity_begin"].ToString();
iDCardModel.EndDate = jo4["balidity_end"].ToString();
iDCardModel.ImageBase64 = "data:image/jpg;base64," + jo4["face_data"].ToString();
var OBJ = new
{
Data = iDCardModel
};
return JsonConvert.SerializeObject(OBJ); ;
}
else
{
//关闭
return "200";
}
} }
else else
{ {

30
CPF_Cef/Devices/Fingerprint.cs

@ -32,28 +32,28 @@ namespace AksWebBrowser.Devices
init = LibFingerprint.LIVESCAN_Init(); init = LibFingerprint.LIVESCAN_Init();
if (init == 1) if (init == 1)
{ {
// Log.Info("初始化指纹成功"); // // Log.Info("初始化指纹成功");
td = LibFingerprint.LIVESCAN_GetChannelCount(); td = LibFingerprint.LIVESCAN_GetChannelCount();
if (td > 0) if (td > 0)
{ {
// Log.Info("获得采集器通道数量成功"); // // Log.Info("获得采集器通道数量成功");
int pnBright = 254; int pnBright = 254;
int status = LibFingerprint.LIVESCAN_GetBright(td, ref pnBright); int status = LibFingerprint.LIVESCAN_GetBright(td, ref pnBright);
// Log.Info(" 获得采集器当前的亮度:" + status); // // Log.Info(" 获得采集器当前的亮度:" + status);
// Log.Info(" 获得采集器当前的亮度:" + pnBright); // // Log.Info(" 获得采集器当前的亮度:" + pnBright);
int pnContrast = 254; int pnContrast = 254;
status = LibFingerprint.LIVESCAN_GetContrast(td, ref pnContrast); status = LibFingerprint.LIVESCAN_GetContrast(td, ref pnContrast);
// Log.Info(" 获得采集器当前对比度:" + status); // // Log.Info(" 获得采集器当前对比度:" + status);
// Log.Info(" 获得采集器当前对比度:" + pnBright); // // Log.Info(" 获得采集器当前对比度:" + pnBright);
int pnWidth = 0, pnHeight = 0; int pnWidth = 0, pnHeight = 0;
status = LibFingerprint.LIVESCAN_GetMaxImageSize(td, ref pnWidth, ref pnHeight); status = LibFingerprint.LIVESCAN_GetMaxImageSize(td, ref pnWidth, ref pnHeight);
// Log.Info(" 获得采集器采集图像的宽度、高度的最大值:" + status); // // Log.Info(" 获得采集器采集图像的宽度、高度的最大值:" + status);
// Log.Info(" 获得采集器采集图像的宽度、高度的最大值:" + pnWidth + "*" + pnHeight); // // Log.Info(" 获得采集器采集图像的宽度、高度的最大值:" + pnWidth + "*" + pnHeight);
byte[] pszDesc = new byte[1024]; byte[] pszDesc = new byte[1024];
status = LibFingerprint.LIVESCAN_GetDesc(pszDesc); status = LibFingerprint.LIVESCAN_GetDesc(pszDesc);
// Log.Info("获得接口规范的说明:" + status); // // Log.Info("获得接口规范的说明:" + status);
// Log.Info("获得接口规范的说明返回数据:" + Encoding.UTF8.GetString(pszDesc)); // // Log.Info("获得接口规范的说明返回数据:" + Encoding.UTF8.GetString(pszDesc));
MessageBox.Show("转变采集"); MessageBox.Show("转变采集");
@ -66,7 +66,7 @@ namespace AksWebBrowser.Devices
} }
else else
{ {
// Log.Info("获得采集器通道数量失败"); // // Log.Info("获得采集器通道数量失败");
} }
Task.Run(() => Task.Run(() =>
{ {
@ -75,7 +75,7 @@ namespace AksWebBrowser.Devices
} }
else else
{ {
// Log.Info("初始化指纹失败,错误代码:" + init); // // Log.Info("初始化指纹失败,错误代码:" + init);
} }
} }
catch (Exception ex) catch (Exception ex)
@ -104,10 +104,10 @@ namespace AksWebBrowser.Devices
//status = LibFingerprint.LIVESCAN_GetFPBmpData(td, Encoding.UTF8.GetBytes(FileName)); //status = LibFingerprint.LIVESCAN_GetFPBmpData(td, Encoding.UTF8.GetBytes(FileName));
if (status == 1) if (status == 1)
{ {
// Log.Info("采集一帧图像:" + Encoding.UTF8.GetString(pRawData)); // // Log.Info("采集一帧图像:" + Encoding.UTF8.GetString(pRawData));
// Log.Info("获取指纹成功"); // // Log.Info("获取指纹成功");
timer.Stop(); timer.Stop();
// Log.Info("停止采集"); // // Log.Info("停止采集");
} }
LibFingerprint.LIVESCAN_EndCapture(td); LibFingerprint.LIVESCAN_EndCapture(td);
} }

105
CPF_Cef/Devices/IDCard.cs

@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
@ -40,6 +41,21 @@ namespace AksWebBrowser.Devices
{ {
try try
{ {
if (icdev <= 0)
{
int num = 5;
while (num < 5)
{
num++;
//打开设备
icdev = LibClass.ICReaderOpenUsbByFD(0);
if (icdev > 0)
{
num = 6;
}
}
}
Log.Info("icdev" + icdev);
if (icdev > 0) if (icdev > 0)
{ {
IDCardModel iDCardModel = new IDCardModel(); IDCardModel iDCardModel = new IDCardModel();
@ -52,38 +68,35 @@ namespace AksWebBrowser.Devices
byte[] PHMsg = new byte[1032]; byte[] PHMsg = new byte[1032];
byte[] FPMsg = new byte[1032]; byte[] FPMsg = new byte[1032];
int cLen = 0, pLen = 0, fLen = 0; int cLen = 0, pLen = 0, fLen = 0;
status = LibClass.ReadIDCardBaseMsg(Convert.ToInt32(icdev), 1, CHMsg, ref cLen, PHMsg, ref pLen, FPMsg, ref fLen); string restus = string.Empty;
if (status == 0) string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
string dirpath = Utils.getSystemPaht() + @"/wwwroot/Face";
if (!Directory.Exists(dirpath))
{ {
//生成base64 Directory.CreateDirectory(dirpath);
byte[] FileName = new byte[65536]; }
status = LibClass.ParseIDCardPic(PHMsg, 1024, 3, FileName); // Log.Info(dirpath);
var tempFile = dirpath + "/faceA.jpg";
string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); int num = 0;
string dirpath = Utils.getSystemPaht() + @"/wwwroot/Face"; bool isSu = false;
if (!Directory.Exists(dirpath)) while (num < 5)
{ {
Directory.CreateDirectory(dirpath); Task.Delay(500).Wait();
} num++;
Log.Info(dirpath); status = LibClass.ReadIDCardBaseMsg(Convert.ToInt32(icdev), 1, CHMsg, ref cLen, PHMsg, ref pLen, FPMsg, ref fLen);
var tempFile = dirpath + "/face.bmp"; Log.Info("读取原始数据"+status);
//生成图片
LibClass.ParseIDCardPic(PHMsg, 1024, 2, Encoding.Default.GetBytes(tempFile));
//文件生成base64
byte[] byteArray = File.ReadAllBytes(tempFile);
string base64String = Convert.ToBase64String(byteArray);
if (status == 0) if (status == 0)
{ {
string txt = Encoding.UTF8.GetString(FileName); //生成图片
iDCardModel.ImageBase64 = "data:image/jpg;base64," + txt.Substring(0, (txt.IndexOf("=") + 1)); LibClass.ParseIDCardPic(PHMsg, 1024, 4, Encoding.Default.GetBytes(tempFile));
////开启人脸比对 Log.Info("生成图片" + status);
//LhtCF lht = new LhtCF(); if (status == 0)
//string stat = lht.LhtCFFace(code, tempFile);
if (true)//(stat == "100")
{ {
//生成文字
byte[] sCHMsg = new byte[520]; byte[] sCHMsg = new byte[520];
int itype = 0; int itype = 0;
status = LibClass.ParseIDCardInfo(CHMsg, cLen, ref itype, sCHMsg); status = LibClass.ParseIDCardInfo(CHMsg, cLen, ref itype, sCHMsg);
Log.Info("生成文字" + status);
if (status == 0) if (status == 0)
{ {
string[] baseinfo = Encoding.UTF8.GetString(sCHMsg).Split("|"); string[] baseinfo = Encoding.UTF8.GetString(sCHMsg).Split("|");
@ -96,28 +109,38 @@ namespace AksWebBrowser.Devices
iDCardModel.Regorg = baseinfo[6]; iDCardModel.Regorg = baseinfo[6];
iDCardModel.StartDate = baseinfo[7]; iDCardModel.StartDate = baseinfo[7];
iDCardModel.EndDate = baseinfo[8]; iDCardModel.EndDate = baseinfo[8];
num = 6;
isSu = true;
} }
var OBJ = new
{
Data = iDCardModel
};
//关闭
LibClass.ICReaderClose(icdev);
return "{\"keycode\":\"" + code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":" + JsonConvert.SerializeObject(OBJ) + "}";
} }
else }
}
if (isSu)
{
//开启人脸比对
LhtCF lht = new LhtCF();
string stat = lht.LhtCFFace(code, tempFile);
if (stat == "100")
{
//文件生成base64
byte[] byteArray = File.ReadAllBytes(tempFile);
string base64String = Convert.ToBase64String(byteArray);
// Log.Info(base64String);
string txt = base64String;
iDCardModel.ImageBase64 = "data:image/jpg;base64," + txt;
var OBJ = new
{ {
//关闭 Data = iDCardModel
LibClass.ICReaderClose(icdev); };
return "{\"keycode\":\"" + code + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "身份证持有者非本人!" + "\"}"; //关闭
LibClass.ICReaderClose(icdev);
} return "{\"keycode\":\"" + code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":" + JsonConvert.SerializeObject(OBJ) + "}";
} }
else else
{ {
//关闭 //关闭
LibClass.ICReaderClose(icdev); LibClass.ICReaderClose(icdev);
return "{\"keycode\":\"" + code + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "读取身份证失败" + "\"}"; return "{\"keycode\":\"" + code + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "身份证持有者非本人!" + "\"}";
} }
} }
else else
@ -131,12 +154,12 @@ namespace AksWebBrowser.Devices
{ {
//关闭 //关闭
LibClass.ICReaderClose(icdev); LibClass.ICReaderClose(icdev);
return "{\"keycode\":\"" + code + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "读取身份证失败" + "\"}"; return "{\"keycode\":\"" + code + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "读取身份证失败3" + "\"}";
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
// Log.Info("获取身份证异常:" + ex.Message); // // Log.Info("获取身份证异常:" + ex.Message);
if (icdev != -1) if (icdev != -1)
{ {
LibClass.ICReaderClose(icdev); LibClass.ICReaderClose(icdev);

88
CPF_Cef/Devices/LhtCF.cs

@ -18,7 +18,8 @@ namespace AksWebBrowser.Devices
{ {
public class LhtCF public class LhtCF
{ {
public static string pathfile = string.Empty; public string pathfile = string.Empty;
public string tempFile = string.Empty;
libLhtCFs.DetectCallBack pDetectCallBack = null; libLhtCFs.DetectCallBack pDetectCallBack = null;
private delegate int DetectCallBackDelegate(int nResultID); private delegate int DetectCallBackDelegate(int nResultID);
public LhtCF() public LhtCF()
@ -45,6 +46,13 @@ namespace AksWebBrowser.Devices
status = libLhtCFs.CF_OpenCamera(); status = libLhtCFs.CF_OpenCamera();
if (status == 0) if (status == 0)
{ {
string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
string dirpath = Utils.getSystemPaht() + @"/wwwroot/Face";
if (!Directory.Exists(dirpath))
{
Directory.CreateDirectory(dirpath);
}
tempFile = dirpath + "/faceB.jpg";
Task.Run(() => Task.Run(() =>
{ {
status = libLhtCFs.CF_CreatWindow(0, 0, 300, 800, 600, 500); status = libLhtCFs.CF_CreatWindow(0, 0, 300, 800, 600, 500);
@ -54,16 +62,49 @@ namespace AksWebBrowser.Devices
} }
}); });
@event6.WaitOne(); @event6.WaitOne();
if (string.IsNullOrEmpty(tempFile))
{
hdStatus = -1;
}
else
{
byte[] faceA = Encoding.Default.GetBytes(pathfile);
byte[] faceB = Encoding.Default.GetBytes(tempFile);
int score = 0;
hdStatus = libLhtCFs.CF_FaceCompare(faceA, faceB, ref score);
if (score > 60 && hdStatus == 0)
{
hdStatus = 100;
}
else
{
hdStatus = -1;
}
}
status = hdStatus; status = hdStatus;
Log.Info("人脸比对结果:" + status); // Log.Info("人脸比对结果:" + status);
//停止活体检测
//libLhtCFs.CF_StopLiveDetect();
//关闭视频预览窗口
libLhtCFs.CF_CloseWindow(0);
//关闭摄像头
libLhtCFs.CF_CloseCamera();
//反初始化
//libLhtCFs.CF_Uninit();
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
//停止活体检测
//libLhtCFs.CF_StopLiveDetect();
//关闭视频预览窗口
libLhtCFs.CF_CloseWindow(0);
//关闭摄像头
libLhtCFs.CF_CloseCamera();
//反初始化 //反初始化
libLhtCFs.CF_Uninit(); //libLhtCFs.CF_Uninit();
Log.Info("双目摄像头采集人脸异常:" + ex.Message); // Log.Info("双目摄像头采集人脸异常:" + ex.Message);
} }
return status.ToString(); return status.ToString();
} }
@ -76,46 +117,15 @@ namespace AksWebBrowser.Devices
{ {
try try
{ {
string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); hdStatus = libLhtCFs.CF_GetImage(2, Encoding.Default.GetBytes(tempFile));
string dirpath = Utils.getSystemPaht() + @"/wwwroot/Face"; if (hdStatus != 0)
if (!Directory.Exists(dirpath))
{
Directory.CreateDirectory(dirpath);
}
var tempFile = dirpath + "/" + time + ".jpg";
hdStatus = libLhtCFs.CF_GetImage(0, Encoding.Default.GetBytes(tempFile));
byte[] faceA = File.ReadAllBytes(pathfile);
byte[] faceB = File.ReadAllBytes(tempFile);
int score = 0;
hdStatus = libLhtCFs.CF_FaceCompare(faceA, faceB, ref score);
if (score > 60 && hdStatus == 0)
{
hdStatus = nResultID;
}
else
{ {
hdStatus = -1; tempFile = string.Empty;
} }
////停止活体检测
//libLhtCFs.CF_StopLiveDetect();
////关闭视频预览窗口
//libLhtCFs.CF_CloseWindow(0);
////关闭摄像头
//libLhtCFs.CF_CloseCamera();
//反初始化
libLhtCFs.CF_Uninit();
} }
catch (Exception ex) catch (Exception ex)
{ {
////停止活体检测 tempFile = string.Empty;
//libLhtCFs.CF_StopLiveDetect();
////关闭视频预览窗口
//libLhtCFs.CF_CloseWindow(0);
////关闭摄像头
//libLhtCFs.CF_CloseCamera();
//反初始化
libLhtCFs.CF_Uninit();
Log.Info("检测回调函数异常:" + ex.Message);
} }
@event6.Set(); @event6.Set();
} }

6
CPF_Cef/Devices/PrintPJ.cs

@ -134,17 +134,17 @@ namespace AksWebBrowser.Devices
m_iInit = LibPrint.SetDevname(3,"", 0); m_iInit = LibPrint.SetDevname(3,"", 0);
if (m_iInit == 0) if (m_iInit == 0)
{ {
// Log.Info("热敏打印机已连接"); // // Log.Info("热敏打印机已连接");
//初始化打印机 //初始化打印机
m_iInit = LibPrint.SetInit(); m_iInit = LibPrint.SetInit();
if (m_iInit == 0) if (m_iInit == 0)
{ {
// Log.Info("初始化成功"); // // Log.Info("初始化成功");
LibPrint.SetCommandmode(3); LibPrint.SetCommandmode(3);
} }
else else
{ {
// Log.Info("初始化失败"); // // Log.Info("初始化失败");
} }
} }
} }

6
CPF_Cef/FrmMain.cs

@ -152,7 +152,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{ {
try try
{ {
// Log.Info("定时任务执行时间: " + DateTime.Now); // // Log.Info("定时任务执行时间: " + DateTime.Now);
string file = System.IO.Directory.GetCurrentDirectory(); string file = System.IO.Directory.GetCurrentDirectory();
file = file + @"/wwwroot"; file = file + @"/wwwroot";
// 这里添加你的任务代码 // 这里添加你的任务代码
@ -248,13 +248,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("未获取授权");
} }
} }

463
CPF_Cef/MainModel.cs

File diff suppressed because one or more lines are too long

2
CPF_Cef/Parame.cs

@ -1,5 +1,6 @@
using AKS.EnterpriseLibrary.WebBrowser; using AKS.EnterpriseLibrary.WebBrowser;
using CPF.Controls; using CPF.Controls;
using Fleck;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -11,6 +12,7 @@ namespace AksWebBrowser
{ {
public class Parame public class Parame
{ {
public static IWebSocketConnection socket { get; set; }
public static TcpClient tcpClient { get; set; } public static TcpClient tcpClient { get; set; }
public static VideoView videoV { get; set; } public static VideoView videoV { get; set; }
public static CusWebBrowser webBrowser { get; set; } public static CusWebBrowser webBrowser { get; set; }

3
CPF_Cef/Ramark.txt

@ -25,3 +25,6 @@ espeak --compile=zh
sudo apt-get update sudo apt-get update
sudo apt-get install gcc make zlib1g-dev libphonon-dev sudo apt-get install gcc make zlib1g-dev libphonon-dev
sudo apt-get install imagemagick

19
CPF_Cef/Results.cs

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AksWebBrowser
{
public class Results
{
public string keycode { set; get; }
public string message { set; get; }
public int code { set; get; }
public bool status { set; get; }
public string suffix { set; get; }
public string data { set; get; }
}
}
Loading…
Cancel
Save