diff --git a/CPF_Cef/Common/ChunkedUpload.cs b/CPF_Cef/Common/ChunkedUpload.cs
index 3480341..ca4e4c1 100644
--- a/CPF_Cef/Common/ChunkedUpload.cs
+++ b/CPF_Cef/Common/ChunkedUpload.cs
@@ -17,7 +17,7 @@ namespace AksWebBrowser.Common
public class ChunkedUpload
{
private readonly HttpClient _httpClient;
-
+ public static string callback = string.Empty;
public ChunkedUpload(HttpClient httpClient)
{
_httpClient = httpClient;
@@ -93,13 +93,14 @@ namespace AksWebBrowser.Common
/// 获取签字版数据
///
///
- public async Task PostSign() {
- string ret = string.Empty;
+ public async Task PostSign(string type, string _callback)
+ {
try
{
+ callback = _callback;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl);
- var content = new StringContent("{\r\n command: \"sign\",\r\n command_num: 111,\r\n data: {\r\n operation: \"open\",\r\n operation_code: 1,\r\n parameters: {\r\n data_type: 1,\r\n title_name: \"\",\r\n }\r\n }\r\n }", null, "text/plain");
+ var content = new StringContent("{\r\n command: \"sign\",\r\n command_num: 111,\r\n data: {\r\n operation: \"" + type + "\",\r\n operation_code: 1,\r\n parameters: {\r\n data_type: 1,\r\n title_name: \"\",\r\n }\r\n }\r\n }", null, "text/plain");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
@@ -107,14 +108,13 @@ namespace AksWebBrowser.Common
{
// 读取响应内容
string body = await response.Content.ReadAsStringAsync();
- ret = body;
+ Log.Info(body);
}
}
catch (Exception ex)
{
Log.Error("签字版post请求: " + ex.Message);
}
- return ret;
}
}
}
diff --git a/CPF_Cef/Devices/Fingerprint.cs b/CPF_Cef/Devices/Fingerprint.cs
index 24ebfca..8fc2a97 100644
--- a/CPF_Cef/Devices/Fingerprint.cs
+++ b/CPF_Cef/Devices/Fingerprint.cs
@@ -1,21 +1,194 @@
-using System;
+using AKSWebBrowser.Commen;
+using CPF.Controls;
+using CPF.Linux;
+using CPF.Windows;
+using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
+using System.Timers;
namespace AksWebBrowser.Devices
{
//apt-get install gcc-c++ libstdc++-devel
public class Fingerprint
{
- public Fingerprint(){}
-
+ public static int td = -1, pnWidth = 0, pnHeight = 0, init = -1;
+ public static string callback = string.Empty, FileName = string.Empty;
+ //开启定时
+ public static System.Timers.Timer timer = new System.Timers.Timer(500);
+
+ public Fingerprint() { }
+
+ //读取指纹
+ public static string LIVESCANFinger(string _callback)
+ {
+ try
+ {
+ callback = _callback;
+ init = LibFingerprint.LIVESCAN_Init();
+ if (init == 1)
+ {
+ Log.Info("初始化指纹成功");
+ td = LibFingerprint.LIVESCAN_GetChannelCount();
+ if (td > 0)
+ {
+
+
+
+ Log.Info("获得采集器通道数量成功");
+ int pnBright = 254;
+ int status = LibFingerprint.LIVESCAN_GetBright(td, ref pnBright);
+ Log.Info(" 获得采集器当前的亮度:" + status);
+ Log.Info(" 获得采集器当前的亮度:" + pnBright);
+ int pnContrast = 254;
+ status = LibFingerprint.LIVESCAN_GetContrast(td, ref pnContrast);
+ Log.Info(" 获得采集器当前对比度:" + status);
+ Log.Info(" 获得采集器当前对比度:" + pnBright);
+
+ int pnWidth = 0, pnHeight = 0;
+ status = LibFingerprint.LIVESCAN_GetMaxImageSize(td, ref pnWidth, ref pnHeight);
+ Log.Info(" 获得采集器采集图像的宽度、高度的最大值:" + status);
+ Log.Info(" 获得采集器采集图像的宽度、高度的最大值:" + pnWidth + "*" + pnHeight);
+ byte[] pszDesc = new byte[1024];
+ status = LibFingerprint.LIVESCAN_GetDesc(pszDesc);
+ Log.Info("获得接口规范的说明:" + status);
+ Log.Info("获得接口规范的说明返回数据:" + Encoding.UTF8.GetString(pszDesc));
+
+ MessageBox.Show("转变采集");
+
+ string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+ FileName = "/tmp/" + time + ".bmp";
+ timer.Stop();
+ timer.Elapsed += OnTimedEvent;
+ timer.AutoReset = true;//重复执行
+ timer.Enabled = true;//启动定时器
+ }
+ else
+ {
+ Log.Info("获得采集器通道数量失败");
+ }
+ Task.Run(() =>
+ {
+ LibFingerprint.LIVESCAN_Close();
+ });
+ }
+ else
+ {
+ Log.Info("初始化指纹失败,错误代码:" + init);
+ }
+ }
+ catch (Exception ex)
+ {
+ if (init == 1)
+ {
+ Task.Run(() =>
+ {
+ LibFingerprint.LIVESCAN_Close();
+ });
+ }
+ Log.Error("读取指纹异常:" + ex.Message);
+ }
+
+ return "";
+ }
+
+ //定时任务
+ private static void OnTimedEvent(object sender, ElapsedEventArgs e)
+ {
+ try
+ {
+ int status = LibFingerprint.LIVESCAN_BeginCapture(td);
+ byte[] pRawData = new byte[pnWidth * pnHeight];
+ status = LibFingerprint.LIVESCAN_GetFPRawData(td, pRawData);
+ //status = LibFingerprint.LIVESCAN_GetFPBmpData(td, Encoding.UTF8.GetBytes(FileName));
+ if (status == 1)
+ {
+ Log.Info("采集一帧图像:" + Encoding.UTF8.GetString(pRawData));
+ Log.Info("获取指纹成功");
+ timer.Stop();
+ Log.Info("停止采集");
+ }
+ LibFingerprint.LIVESCAN_EndCapture(td);
+ }
+ catch (Exception ex)
+ {
+ Log.Error("定时读取指纹异常:" + ex.Message);
+ timer.Stop();
+ }
+ }
}
class LibFingerprint
{
- [DllImport("libmsprintsdk", EntryPoint = "SetInit", CharSet = CharSet.Ansi)]
- public static extern int SetInit();
+ //初始化指纹
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_Init", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_Init();
+
+ //关闭
+ [DllImport("libID_FprCap", EntryPoint = " LIVESCAN_Close", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_Close();
+
+ //获得采集器通道数量
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_GetChannelCount", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_GetChannelCount();
+
+ //设置采集器当前的亮度
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_SetBright", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_SetBright(int nChannel, int nBright);
+
+ //设置采集器当前对比度
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_SetContrast", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_SetContrast(int nChannel, int nContrast);
+
+ //获得采集器当前的亮度
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_GetBright", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_GetBright(int nChannel, ref int pnBright);
+
+ //获得采集器当前对比度
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_GetContrast", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_GetContrast(int nChannel, ref int pnContrast);
+
+ // 获得采集器采集图像的宽度、高度的最大值
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_GetMaxImageSize", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_GetMaxImageSize(int nChannel, ref int pnWidth, ref int pnHeight);
+
+ //获得当前图像的采集位置、宽度和高度
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_GetCaptWindow", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_GetCaptWindow(int nChannel, ref int pnOriginX, ref int pnOriginY, ref int pnWidth, ref int pnHeight);
+
+ //设置当前图像的采集位置、宽度和高度
+ [DllImport("libID_FprCap", EntryPoint = " LIVESCAN_SetCaptWindow", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_SetCaptWindow(int nChannel, int nOriginX, int nOriginY, int nWidth, int nHeight);
+
+ //调用采集器的属性设置对话框
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_Setup", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_Setup();
+
+ //采集器是否支持设置对话框
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_IsSupportSetup", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_IsSupportSetup();
+
+ //准备采集一帧图像
+ [DllImport("libID_FprCap", EntryPoint = "LIVESCAN_BeginCapture", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_BeginCapture(int nChannel);
+
+ //采集一帧图像
+ [DllImport("libID_FprCap", EntryPoint = " LIVESCAN_GetFPRawData", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_GetFPRawData(int nChannel, byte[] pRawData);
+
+ //采集一帧 BMP 格式图像数据
+ [DllImport("libID_FprCap", EntryPoint = " LIVESCAN_GetFPBmpData", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_GetFPBmpData(int nChannel, byte[] pBmpData);
+ //结束采集一帧图像
+ [DllImport("libID_FprCap", EntryPoint = " LIVESCAN_EndCapture", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_EndCapture(int nChannel);
+
+ //获得接口规范的说明
+ [DllImport("libID_FprCap", EntryPoint = " LIVESCAN_GetDesc", SetLastError = true, CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LIVESCAN_GetDesc(byte[] pszDesc);
}
}
diff --git a/CPF_Cef/Devices/PrintPJ.cs b/CPF_Cef/Devices/PrintPJ.cs
index fb590d8..a4dca87 100644
--- a/CPF_Cef/Devices/PrintPJ.cs
+++ b/CPF_Cef/Devices/PrintPJ.cs
@@ -69,23 +69,24 @@ namespace AksWebBrowser.Devices
///
public int Print(string ph, string ddrs, string qrcode, string ywmc)
{
- StringBuilder sbData = new StringBuilder("");
try
{
- sbData = new StringBuilder(string.Format(" 您预约办理的{0}业务-,排号为:", ywmc));
+ //注册gb2312
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+ string txt = string.Format(" 您预约办理的{0}业务-,排号为:", ywmc);
LibPrint.SetClean();
LibPrint.SetReadZKmode(0);
LibPrint.SetAlignment(0);
LibPrint.SetSizetext(2, 1);
LibPrint.SetLinespace(20);
- LibPrint.PrintString(sbData, 0);
+ LibPrint.PrintString(Encoding.GetEncoding("gb2312").GetBytes(txt), 0);
+ LibPrint.PrintFeedDot(0);
//排号
LibPrint.SetAlignment(1);
LibPrint.SetBold(1);
LibPrint.SetSizetext(2, 2);
- sbData = new StringBuilder(ph);
- LibPrint.PrintString(sbData, 0);
+ LibPrint.PrintString(Encoding.GetEncoding("gb2312").GetBytes(ph), 0);
LibPrint.SetAlignment(0);
LibPrint.SetBold(0);
@@ -93,32 +94,30 @@ namespace AksWebBrowser.Devices
LibPrint.PrintFeedDot(10);
//等候
- sbData = new StringBuilder(string.Format("您前面有 {0} 人等候,注意业务窗口的呼叫号码信息。过号请重新取号。", ddrs));
- LibPrint.PrintString(sbData, 1);
+ txt = string.Format("您前面有 {0} 人等候,注意业务窗口的呼叫号码信息。过号请重新取号。", ddrs);
+ LibPrint.PrintString(Encoding.GetEncoding("gb2312").GetBytes(txt), 1);
LibPrint.PrintFeedDot(60);
//二维码
LibPrint.SetClean();
LibPrint.SetCommandmode(10);
LibPrint.SetAlignment(1);
- LibPrint.SetLeftmargin(-60);
- sbData = new StringBuilder(qrcode);
- LibPrint.PrintQrcode(sbData, 2, 6, 1);
+ LibPrint.SetLeftmargin(-40);
+ LibPrint.PrintQrcode(Encoding.GetEncoding("gb2312").GetBytes(qrcode), 0, 8, 1);
LibPrint.PrintRemainQR();
- LibPrint.PrintFeedDot(100);
+ LibPrint.PrintFeedDot(80);
//时间
LibPrint.SetClean();
LibPrint.SetSizetext(0, 0);
LibPrint.SetAlignment(2);
- sbData = new StringBuilder(DateTime.Now.ToLocalTime().ToString());
- LibPrint.PrintString(sbData, 1);
- LibPrint.PrintFeedDot(190);
- LibPrint.PrintFeedDot(200);
+ LibPrint.PrintString(Encoding.GetEncoding("gb2312").GetBytes(DateTime.Now.ToLocalTime().ToString()), 1);
+ LibPrint.PrintFeedDot(140);
LibPrint.PrintCutpaper(0);
}
catch (Exception ex)
{
+ Log.Error("票据打印失败:"+ex.Message);
return 1;
}
return 0;
@@ -188,7 +187,7 @@ namespace AksWebBrowser.Devices
public static extern int SetDevname(int iDevtype, byte[] cDevname, int iBaudrate);
[DllImport("libmsprintsdk", EntryPoint = "PrintString", CharSet = CharSet.Ansi)]
- public static extern int PrintString(StringBuilder strData, int iImme);
+ public static extern int PrintString(byte[] strData, int iImme);
[DllImport("libmsprintsdk", EntryPoint = "PrintFeedline", CharSet = CharSet.Ansi)]
public static extern int PrintFeedline(int iLine);
@@ -221,7 +220,7 @@ namespace AksWebBrowser.Devices
public static extern int PrintDiskimgfile(StringBuilder strData);
[DllImport("libmsprintsdk", EntryPoint = "PrintQrcode", CharSet = CharSet.Ansi)]
- public static extern int PrintQrcode(StringBuilder strData, int iLmargin, int iMside, int iRound);
+ public static extern int PrintQrcode(byte[] strData, int iLmargin, int iMside, int iRound);
[DllImport("libmsprintsdk", EntryPoint = "PrintRemainQR", CharSet = CharSet.Ansi)]
public static extern int PrintRemainQR();
diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs
index 1769ce0..bbb3a85 100644
--- a/CPF_Cef/MainModel.cs
+++ b/CPF_Cef/MainModel.cs
@@ -27,6 +27,7 @@ using System.Web;
using System.Xml.Linq;
using static System.Net.Mime.MediaTypeNames;
using AksWebBrowser.Devices;
+using System.Reflection;
namespace AKS.EnterpriseLibrary.WebBrowser
{
@@ -50,9 +51,9 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{
try
{
+ //Finger("","");
IDCard iDCard = new IDCard();
string result = iDCard.getIdCard();
- Log.Info(result);
SubmitLogs(result, "IDCardRead");
return result;
}
@@ -355,10 +356,9 @@ namespace AKS.EnterpriseLibrary.WebBrowser
}
else
{
-
- sign.OpenComDevice(callback);
- string result = "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"png\",\"data\":\"" + "成功" + "\"}";
- SubmitLogs(result, "OpenSign");
+ Task.Run(() => HttpPostResponseBySign("open", callback));
+ string result = "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + "签字版已打开" + "\"}";
+ SubmitLogs(result, "openCamera");
return result;
}
}
@@ -371,6 +371,38 @@ namespace AKS.EnterpriseLibrary.WebBrowser
}
}
+ ///
+ /// 指纹
+ ///
+ ///
+ ///
+ [JSFunction]
+ public string Finger(string paramsString, string callback)
+ {
+ try
+ {
+ if (false)//!isFuncisFuncObject("Finger")
+ {
+ Utils.MessagesBox("指纹设备未授权使用");
+ return "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "指纹设备未授权使用" + "\"}";
+ }
+ else
+ {
+
+ string result = Fingerprint.LIVESCANFinger(callback);
+ SubmitLogs(result, "Finger");
+ return result;
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.Error("指纹异常: " + ex.Message + "");
+ string result = "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
+ SubmitLogs(result, "Finger");
+ return result;
+ }
+ }
+
///
/// 关闭签字版
///
@@ -386,10 +418,6 @@ namespace AKS.EnterpriseLibrary.WebBrowser
Utils.MessagesBox("签字版设备未授权使用");
return "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "签字版设备未授权使用" + "\"}";
}
- else if (Parame.tcpClient == null)
- {
- return "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "硬件服务未启动" + "\"}";
- }
else
{
//paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"7\",\"param\":{\"data\":\"" + "" + "\"}}";
@@ -1052,46 +1080,15 @@ namespace AKS.EnterpriseLibrary.WebBrowser
@event6.Set();
}
- ///
- /// 获取签字版base64
- ///
- ///
- public string GetSignBase64()
- {
- //获取设备信息
-
- Task.Run(() => HttpPostResponseBySign());
- @event6.WaitOne();
- if (string.IsNullOrEmpty(qzbStr))
- {
- return "";
- }
- else
- {
- JObject jo = (JObject)JsonConvert.DeserializeObject(qzbStr);
- if (jo["code"].ToString() == "0")
- {
- return jo["data"].ToString();
- }
- else
- {
- Log.Info(jo["returnMsg"].ToString());
- return "";
- }
- }
- }
///
/// 签字版
///
- private string qzbStr = string.Empty;
- private AutoResetEvent @event7 = new AutoResetEvent(false);
- private async void HttpPostResponseBySign()
+ private async void HttpPostResponseBySign(string type,string callback)
{
var httpClient = new HttpClient();
var uploader = new ChunkedUpload(httpClient);
- qzbStr = await uploader.PostSign();
- @event7.Set();
+ await uploader.PostSign(type, callback);
}
///
diff --git a/CPF_Cef/Parame.cs b/CPF_Cef/Parame.cs
index a61ca29..ec3f9ec 100644
--- a/CPF_Cef/Parame.cs
+++ b/CPF_Cef/Parame.cs
@@ -24,7 +24,8 @@ namespace AksWebBrowser
//签字版
public static string signUrl = "http://127.0.0.1:9399/device";
//票据打印机
- public static string pritPj = "/dev/ttyUSB7";
+ public static string pritPj = "/dev/ttyS7";
+ //波特率
public static int pritPjPort = 38400;
}
public struct Func