diff --git a/CPF_Cef/Common/ChunkedUpload.cs b/CPF_Cef/Common/ChunkedUpload.cs
index 1b7581e..f0d910a 100644
--- a/CPF_Cef/Common/ChunkedUpload.cs
+++ b/CPF_Cef/Common/ChunkedUpload.cs
@@ -138,7 +138,7 @@ namespace AksWebBrowser.Common
{
//关闭签字版
await PublicSign("close", 2, timeout);
- Task.Delay(1000).Wait();
+ Task.Delay(500).Wait();
string body = await PublicSign(type, typeCode, timeout);
if (!string.IsNullOrEmpty(body))
{
@@ -160,10 +160,10 @@ namespace AksWebBrowser.Common
}
else if (jo2["code"].ToString() == "1")
{
- Task.Delay(1000).Wait();
+ Task.Delay(500).Wait();
//关闭签字版
await PublicSign("close", 2, timeout);
- Task.Delay(1000).Wait();
+ Task.Delay(500).Wait();
//打开签字版
body = await PublicSign(type, typeCode, timeout);
if (!string.IsNullOrEmpty(body))
@@ -251,7 +251,7 @@ namespace AksWebBrowser.Common
///
///
///
- public static async Task PublicSign(string type, int typeCode, int timeout)
+ public async Task PublicSign(string type, int typeCode, int timeout)
{
string body = string.Empty;
timeout = timeout == 0 ? Parame.timeout : timeout;
@@ -385,39 +385,49 @@ namespace AksWebBrowser.Common
try
{
await PublicFinger("close", 2, timeout);
- Task.Delay(1000).Wait();
+ Task.Delay(500).Wait();
string body = await PublicFinger(type, typeCode, timeout);
if (!string.IsNullOrEmpty(body))
{
+
JObject jo = (JObject)JsonConvert.DeserializeObject(body);
string ret = jo["ret_info"].ToString();
JObject jo2 = (JObject)JsonConvert.DeserializeObject(ret);
if (jo2["code"].ToString() == "0")
{
- //读取指纹
- if (typeCode == 1)
- {
- //读取data数据
- 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 fpr_pic = jo4["fpr_pic"].ToString();
- return fpr_pic;
+ if (type == "open" && typeCode == 1)
+ {
+ //读取指纹
+ if (typeCode == 1)
+ {
+ //读取data数据
+ 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 fpr_pic = jo4["fpr_pic"].ToString();
+ return fpr_pic;
+ }
+ else
+ {
+ //关闭指纹
+ return "200";
+ }
}
else
{
//关闭指纹
return "200";
}
+
}
else if (jo2["code"].ToString() == "1")
{
- Task.Delay(1000).Wait();
+ Task.Delay(500).Wait();
body = await PublicFinger("close", 2, timeout);
- Task.Delay(1000).Wait();
+ Task.Delay(500).Wait();
body = await PublicFinger(type, typeCode, timeout);
if (!string.IsNullOrEmpty(body))
{
@@ -457,6 +467,7 @@ namespace AksWebBrowser.Common
//Log.Error("请求签字失败" + jo["message"].ToString());
return "";
}
+
}
else
{
@@ -483,7 +494,7 @@ namespace AksWebBrowser.Common
///
///
///
- public static async Task PublicFinger(string type, int typeCode, int timeout)
+ public async Task PublicFinger(string type, int typeCode, int timeout)
{
string body = string.Empty;
timeout = timeout == 0 ? Parame.timeout : timeout;
@@ -616,5 +627,30 @@ namespace AksWebBrowser.Common
}
}
}
+
+ ///
+ /// 公共读取指纹
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task PublicIdcard(string type, int typeCode, int timeout)
+ {
+ string body = string.Empty;
+ timeout = timeout == 0 ? Parame.timeout : timeout;
+ var client = new HttpClient();
+ client.Timeout = TimeSpan.FromSeconds(timeout);
+ var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl);
+ var content = new StringContent("{\r\n \"command\": \"idcard\",\r\n \"command_num\": 141,\r\n \"data\": {\r\n \"operation\": \"close\",\r\n \"operation_code\": 2,\r\n \"parameters\": {\r\n }\r\n }\r\n}", null, "text/plain");
+ request.Content = content;
+ var response = await client.SendAsync(request);
+ response.EnsureSuccessStatusCode();
+ if (response.StatusCode.ToString() == "OK")
+ {
+ body = await response.Content.ReadAsStringAsync();
+ }
+ return body;
+ }
}
}
diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs
index f5f0b19..14b3f4d 100644
--- a/CPF_Cef/MainModel.cs
+++ b/CPF_Cef/MainModel.cs
@@ -66,6 +66,11 @@ namespace AKS.EnterpriseLibrary.WebBrowser
});
if (json != null)
{
+ //释放所有硬件
+ Task.Run(() => {
+ HttpResponseClose();
+ });
+ @event8.WaitOne();
//接收指令和参数
string keycode = json.code;
switch (keycode)
@@ -108,7 +113,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
//读取指纹 {"code":"aks100106","isclose":false}
case "aks100106":
result = ReadFingerData(content);
- Log.Info("读取指纹" + result);
+ //Log.Info("读取指纹" + result);
break;
//aks100107 开始录音、取消录音、结束录音
// 开始录音:{ "code":"aks100107","url":"","isopen":true}
@@ -1448,6 +1453,28 @@ namespace AKS.EnterpriseLibrary.WebBrowser
}
}
+ ///
+ /// 关闭硬件
+ ///
+
+ private static AutoResetEvent @event8 = new AutoResetEvent(false);
+ private static async void HttpResponseClose()
+ {
+ try
+ {
+ var httpClient = new HttpClient();
+ var uploader = new ChunkedUpload(httpClient);
+ await uploader.PublicSign("close", 2,0);
+ await uploader.PublicFinger("close", 2, 0);
+ await uploader.PublicIdcard("close", 2, 0);
+ @event8.Set();
+ }
+ catch (Exception ex)
+ {
+ //Log.Error("高拍仪异常:" + ex.Message);
+ }
+ }
+
///
/// 初始文件上传
///
@@ -1848,5 +1875,10 @@ namespace AKS.EnterpriseLibrary.WebBrowser
}
return "";
}
+
+ public static string StartShll() {
+ string commod = "lsof -i:9039";
+ return "";
+ }
}
}