diff --git a/CPF_Cef/Common/ChunkedUpload.cs b/CPF_Cef/Common/ChunkedUpload.cs
index b29d2c5..29f5542 100644
--- a/CPF_Cef/Common/ChunkedUpload.cs
+++ b/CPF_Cef/Common/ChunkedUpload.cs
@@ -148,6 +148,7 @@ namespace AksWebBrowser.Common
{
try
{
+ timeout = timeout == 0 ? Parame.timeout : timeout;
var client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(timeout);
var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl);
@@ -271,6 +272,7 @@ namespace AksWebBrowser.Common
{
try
{
+ timeout = timeout == 0 ? Parame.timeout : timeout;
var client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(timeout);
var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl);
@@ -339,6 +341,7 @@ namespace AksWebBrowser.Common
{
try
{
+ timeout = timeout == 0 ? Parame.timeout : timeout;
var client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(timeout);
var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl);
@@ -367,33 +370,7 @@ namespace AksWebBrowser.Common
string base64 = jo4["face_data"].ToString();
if (Parame.isTMZ)
{
- //生成文件
- string dirpath = Utils.getSystemPaht() + @"/wwwroot/FileTxt";
- if (!Directory.Exists(dirpath))
- {
- Directory.CreateDirectory(dirpath);
- }
- var tempFile = dirpath + "/faceA.txt";
- using (StreamWriter sw = new StreamWriter(tempFile))
- {
- sw.Write(base64);
- sw.Close();
- sw.Dispose();
- }
- //生成图片
- string dirpath1 = Utils.getSystemPaht() + @"/wwwroot/Face";
- if (!Directory.Exists(dirpath1))
- {
- Directory.CreateDirectory(dirpath1);
- }
- var faceA = dirpath1 + "/faceA.jpg";
- string command = $"base64 -d {tempFile} > {faceA}";
- MainModel.ShllCommad(command);
- //删除图片
- Task.Run(() =>
- {
- File.Delete(tempFile);
- });
+ var faceA =Utils.Base64ByImages(base64);
//开启人脸比对
LhtCF lht = new LhtCF();
string stat = lht.LhtCFFace("", faceA);
diff --git a/CPF_Cef/Common/Utils.cs b/CPF_Cef/Common/Utils.cs
index c49842f..5ab43ad 100644
--- a/CPF_Cef/Common/Utils.cs
+++ b/CPF_Cef/Common/Utils.cs
@@ -1,9 +1,11 @@
-using AKSWebBrowser.Commen;
+using AKS.EnterpriseLibrary.WebBrowser;
+using AKSWebBrowser.Commen;
using CPF.Controls;
using System;
using System.Drawing;
using System.Globalization;
using System.IO;
+using System.Threading.Tasks;
namespace AksWebBrowser.Common
{
@@ -52,7 +54,10 @@ namespace AksWebBrowser.Common
// 删除所有文件
foreach (string file in files)
{
- File.Delete(file);
+ if (!file.Contains("SignFile"))
+ {
+ File.Delete(file);
+ }
}
}
@@ -94,5 +99,64 @@ namespace AksWebBrowser.Common
long timestamp = (long)timeSpan.TotalSeconds;
return timestamp.ToString();
}
+
+ //图片旋转
+ public static string ImagesByRotate(string base64, int rotate)
+ {
+ string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+ //生成图片
+ string dirpath1 = Utils.getSystemPaht() + @"/wwwroot/TmpFile";
+ if (!Directory.Exists(dirpath1))
+ {
+ Directory.CreateDirectory(dirpath1);
+ }
+ var outImgpath = dirpath1 + $"/{time}.jpg";
+ var Imgpath = Base64ByImages(base64);
+ string command = $"convert {Imgpath} -rotate {rotate} {outImgpath}";
+ MainModel.ShllCommad(command);
+ byte[] bytes = File.ReadAllBytes(outImgpath);
+ string _base64 = Convert.ToBase64String(bytes);
+ //删除图片
+ Task.Run(() =>
+ {
+ File.Delete(Imgpath);
+ File.Delete(outImgpath);
+ });
+ return _base64;
+ }
+
+ //base64转图片
+ public static string Base64ByImages(string base64)
+ {
+ string time = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+ //生成文件
+ string dirpath = Utils.getSystemPaht() + @"/wwwroot/TmpFile";
+ if (!Directory.Exists(dirpath))
+ {
+ Directory.CreateDirectory(dirpath);
+ }
+ var tempFile = dirpath + $"/{time}.txt";
+ using (StreamWriter sw = new StreamWriter(tempFile))
+ {
+ sw.Write(base64);
+ sw.Close();
+ sw.Dispose();
+ }
+ //生成图片
+ string dirpath1 = Utils.getSystemPaht() + @"/wwwroot/TmpFile";
+ if (!Directory.Exists(dirpath1))
+ {
+ Directory.CreateDirectory(dirpath1);
+ }
+ var Imgpath = dirpath1 + $"/{time}.jpg";
+ string command = $"base64 -d {tempFile} > {Imgpath}";
+ MainModel.ShllCommad(command);
+ //删除图片
+ Task.Run(() =>
+ {
+ File.Delete(tempFile);
+ });
+ return Imgpath;
+ }
}
}
diff --git a/CPF_Cef/FrmMain.cs b/CPF_Cef/FrmMain.cs
index 906daa0..28f0c19 100644
--- a/CPF_Cef/FrmMain.cs
+++ b/CPF_Cef/FrmMain.cs
@@ -21,7 +21,6 @@ namespace AKS.EnterpriseLibrary.WebBrowser
public int w = 1080;
public int h = 1920;
-
protected override void InitializeComponent()
{
//注册gb2312
@@ -118,60 +117,12 @@ namespace AKS.EnterpriseLibrary.WebBrowser
//获取设备
MainModel.GetSnIndex();
//打开高拍仪
- if (MainModel.OpenSn("0") == "200")
+ if (MainModel.OpenSn(Parame.gpydevIndex) == "200")
{
Parame.isGPY = true;
}
- ////删除临时文件
- //Task.Run(() => { DeleteFile(); });
- ////开启定时清理任务
- //Task.Run(() => { Time(); });
}
- //凌晨2点执行,清理当天缓存文件
- public void Time()
- {
- try
- {
- // 获取当前时间
- DateTime now = DateTime.Now;
- // 计算明天凌晨的时间// 假设凌晨2点执行
- DateTime tomorrowMorning = new DateTime(now.Year, now.Month, now.Day) + TimeSpan.FromDays(1) + TimeSpan.FromHours(2);
- // 计算时间差(明天凌晨时间减去现在时间)
- TimeSpan timeToGo = tomorrowMorning - now;
- // 设置定时器
- Timer timer = new Timer(ExecuteTask, null, timeToGo, Timeout.InfiniteTimeSpan);
- }
- catch (Exception ex)
- {
- //Log.Error("定时任务开启异常: " + ex.Message);
- }
- }
-
- // 要执行的任务
- private static void ExecuteTask(object state)
- {
- DeleteFile();
- }
-
- //删除临时文件
- public static void DeleteFile()
- {
- try
- {
- // // Log.Info("定时任务执行时间: " + DateTime.Now);
- string file = System.IO.Directory.GetCurrentDirectory();
- file = file + @"/wwwroot";
- // 这里添加你的任务代码
- Utils.DeleteAllFiles(file);
- }
- catch (Exception ex)
- {
- //Log.Error("定时任务执行异常: " + ex.Message);
- }
- }
-
-
public void Writelog(string str, string dirName = @"logs")
{
try
@@ -192,6 +143,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
}
catch { }
}
+
private void CusRequest_CusResquestEvent(CefPostData postData, CefRequest request)
{
string postParams = string.Empty;
diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs
index 83c520c..a452c2e 100644
--- a/CPF_Cef/MainModel.cs
+++ b/CPF_Cef/MainModel.cs
@@ -232,7 +232,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
///
public static string IDCardRead(string content)
{
-
+
try
{
var param = content.ConvertToAnonymousType(new
@@ -268,7 +268,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
catch (Exception ex)
{
//Log.Error("读取身份证卡号异常: " + ex.Message + "");
- string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" +""+ "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
+ string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
SubmitLogs(result, "IDCardRead");
return result;
}
@@ -329,7 +329,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
catch (Exception ex)
{
//Log.Error("打印排队票据异常: " + ex.Message + "");
- string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" +"" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
+ string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
SubmitLogs(result, "SendByPrint");
return result;
}
@@ -369,25 +369,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{
Task.Run(() =>
{
- try
- {
- if (Typrocess != null)
- {
- // 如果进程还在运行
- if (!Typrocess.HasExited)
- {
- // 发送SIGTERM信号来停止进程
- Typrocess.Kill();
- // 等待进程真正停止
- Typrocess.WaitForExit();
- }
- }
- }
- catch (Exception ex)
- {
- //Log.Error("停止失败: " + ex.Message + "");
- }
- // AutoAudio(false, "");
+ Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); });
});
string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}";
SubmitLogs(result, "payleText");
@@ -414,12 +396,15 @@ namespace AKS.EnterpriseLibrary.WebBrowser
else
{
Task.Run(() => { string command = $"sox {ttsStr} -d"; ShllCommad(command); });
- string filename = Path.GetFileName(ttsStr);
- Log.Info(filename);
- string source_file = dirpath + $"/{filename}";
- Log.Info(source_file);
- string command = $"cp {ttsStr} -t {dirpath} && mv {source_file} {tempFile}";
- ShllCommad(command);
+ if (!string.IsNullOrEmpty(ywid))
+ {
+ string filename = Path.GetFileName(ttsStr);
+ Log.Info(filename);
+ string source_file = dirpath + $"/{filename}";
+ Log.Info(source_file);
+ string command = $"cp {ttsStr} -t {dirpath} && mv {source_file} {tempFile}";
+ ShllCommad(command);
+ }
result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "开始播放" + "\"}";
}
}
@@ -437,7 +422,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
catch (Exception ex)
{
//Log.Error("文字语音播报异常2: " + ex.Message + "");
- string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" +"" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
+ string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
SubmitLogs(result, "payleText");
return result;
}
@@ -492,7 +477,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
catch (Exception ex)
{
//Log.Error("文字语音播报异常2: " + ex.Message + "");
- string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + ""+ "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
+ string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
return result;
}
}
@@ -521,6 +506,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
}
else
{
+ param = Utils.ImagesByRotate(param, 90);
//关闭
//StopSn("0");
string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + param + "\"}";
@@ -531,7 +517,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
else
{
//打开高拍仪
- string param = OpenSn("0");
+ string param = OpenSn(Parame.gpydevIndex);
if (string.IsNullOrEmpty(param))
{
string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"jpg\",\"data\":\"" + "扫描仪打开失败" + "\"}";
@@ -554,6 +540,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
}
else
{
+ string base64 = Utils.ImagesByRotate(param, 90);
//关闭
//StopSn("0");
string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + param + "\"}";
@@ -582,7 +569,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
///
public static string OpenSign(string content)
{
-
+
try
{
var param = content.ConvertToAnonymousType(new
@@ -615,7 +602,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
catch (Exception ex)
{
//Log.Error("打开签字版异常: " + ex.Message + "");
- string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + ""+ "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
+ string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}";
SubmitLogs(result, "OpenSign");
return result;
}
@@ -637,7 +624,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
}
else
{
- Task.Run(() => HttpPostResponseBySign("close", 2, "",5));
+ Task.Run(() => HttpPostResponseBySign("close", 2, "", 5));
string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + "签字版已关闭" + "\"}";
SubmitLogs(result, "openCamera");
return result;
@@ -832,7 +819,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
///
public static string PrintFile(string content)
{
-
+
try
{
var param = content.ConvertToAnonymousType(new
@@ -965,7 +952,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
///
public static string PalyFile(string content)
{
-
+
try
{
var param = content.ConvertToAnonymousType(new
@@ -991,18 +978,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{
Task.Run(() =>
{
- if (Typrocess != null)
- {
- // 如果进程还在运行
- if (!Typrocess.HasExited)
- {
- // 发送SIGTERM信号来停止进程
- Typrocess.Kill();
- // 等待进程真正停止
- Typrocess.WaitForExit();
- }
- }
- //AutoAudio(ispaly, "");
+ Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); });
});
string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}";
SubmitLogs(result, "PalyFile");
@@ -1014,18 +990,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
{
Task.Run(() =>
{
- if (Typrocess != null)
- {
- // 如果进程还在运行
- if (!Typrocess.HasExited)
- {
- // 发送SIGTERM信号来停止进程
- Typrocess.Kill();
- // 等待进程真正停止
- Typrocess.WaitForExit();
- }
- }
- //AutoAudio(ispaly, "");
+ Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); });
});
Uri uri = new Uri(url);
//返回 123.xlsx
@@ -1155,10 +1120,13 @@ namespace AKS.EnterpriseLibrary.WebBrowser
string name = string.Empty;
foreach (JObject jo2 in jo1)
{
- devidx = jo2["dev_idx"].ToString();
name = jo2["name"].ToString();
- // // Log.Info(name);
- break;
+ if (name.Contains(Parame.gpyVersion))
+ {
+ devidx = jo2["dev_idx"].ToString();
+ Parame.gpydevIndex = devidx;
+ break;
+ }
}
return devidx;
}
@@ -1380,7 +1348,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
///
/// 签字版
///
- private static async void HttpPostResponseBySign(string type, int typeCode, string code,int timeout)
+ private static async void HttpPostResponseBySign(string type, int typeCode, string code, int timeout)
{
try
{
@@ -1419,7 +1387,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser
///
/// 指紋
///
- private static async void HttpPostResponseByFinger(string type, int typeCode,int timeout)
+ private static async void HttpPostResponseByFinger(string type, int typeCode, int timeout)
{
try
{
diff --git a/CPF_Cef/Parame.cs b/CPF_Cef/Parame.cs
index f01d95a..15eeea6 100644
--- a/CPF_Cef/Parame.cs
+++ b/CPF_Cef/Parame.cs
@@ -25,8 +25,13 @@ namespace AksWebBrowser
public static string Ip = "192.168.1.166";
//高拍仪url
public static string gpyUrl = "http://127.0.0.1:6543";
+ //高拍仪
+ public static string gpyVersion = "S1000A3";
+ //高拍仪devIndex
+ public static string gpydevIndex = "0";
//签字版、指纹、身份证
- public static string signUrl = "http://192.168.0.234:9399/device";
+ public static string signUrl = "http://127.0.0.1:9399/device";
+ public static int timeout= 60;
//票据打印机
public static string pritPj = "/dev/ttyS7";
//波特率