From 055585e908a87d0ce768d797907a971d9fa108ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=BD=87=E9=98=B3?= Date: Fri, 24 May 2024 11:37:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=9B=BD=E4=BA=A7=E5=8C=96?= =?UTF-8?q?=E7=AD=BE=E5=AD=97=E7=89=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CPF_Cef/Common/COMUtils.cs | 34 ++--- CPF_Cef/Common/TcpClients.cs | 39 +++++- CPF_Cef/Devices/SignDll.cs | 260 +++++++++++++++++++++++++++++++++++ CPF_Cef/FrmMain.cs | 8 +- CPF_Cef/MainModel.cs | 122 +++++++++++----- 5 files changed, 401 insertions(+), 62 deletions(-) create mode 100644 CPF_Cef/Devices/SignDll.cs diff --git a/CPF_Cef/Common/COMUtils.cs b/CPF_Cef/Common/COMUtils.cs index 708e29a..60ed1a9 100644 --- a/CPF_Cef/Common/COMUtils.cs +++ b/CPF_Cef/Common/COMUtils.cs @@ -49,7 +49,7 @@ namespace AKSWebBrowser.Common if (!string.IsNullOrEmpty(parm)) { ml = "/dev/" + parm; - Log.Info("输出结果:" + ml); + //Log.Info("输出结果:" + ml); //给管理权限 LinuxCmd(ml); //打开串口 @@ -73,21 +73,21 @@ namespace AKSWebBrowser.Common timer.Elapsed += OnTimedEvent; timer.AutoReset = true;//重复执行 timer.Enabled = true;//启动定时器 - Log.Info("浏览器COM服务启动成功"); + //Log.Info("浏览器COM服务启动成功"); } else { - Log.Info("串口类型不匹配"); + //Log.Info("串口类型不匹配"); } } else { - Log.Info("当前设备没有串口设备"); + //Log.Info("当前设备没有串口设备"); } } catch (Exception ex) { - Log.Info("服务启动异常ex: " + ex.Message + ""); + //Log.Info("服务启动异常ex: " + ex.Message + ""); } } @@ -121,7 +121,7 @@ namespace AKSWebBrowser.Common } 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 + "\"}"); // CShaseBJavaScript(jsonstr); } @@ -139,7 +139,7 @@ namespace AKSWebBrowser.Common } catch (Exception ex) { - Log.Info("定时任务打开串口异常: " + ex.Message + ""); + //Log.Info("定时任务打开串口异常: " + ex.Message + ""); } } @@ -155,7 +155,7 @@ namespace AKSWebBrowser.Common jsonstr = string.Empty; //写入数据并以换行符结束 serialPort.WriteLine(data); - Log.Info("发送数据成功: " + data + ""); + //Log.Info("发送数据成功: " + data + ""); while (string.IsNullOrEmpty(jsonstr)) { Task.Delay(10).Wait(); @@ -171,7 +171,7 @@ namespace AKSWebBrowser.Common jsonstr = string.Empty; //写入数据并以换行符结束 serialPort.WriteLine(data); - Log.Info("发送数据成功: " + data + ""); + //Log.Info("发送数据成功: " + data + ""); while (string.IsNullOrEmpty(jsonstr)) { Task.Delay(10).Wait(); @@ -181,7 +181,7 @@ namespace AKSWebBrowser.Common { jsontemp = string.Empty; jsonstr = string.Empty; - Log.Info("发送数据失败"); + //Log.Info("发送数据失败"); jsonstr = MainModel.str2Base64("{\"callback\":\"" + this.callback + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "串口未打开" + "\"}"); //CShaseBJavaScript(jsonstr); } @@ -191,7 +191,7 @@ namespace AKSWebBrowser.Common { jsontemp = 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 + "\"}"); //CShaseBJavaScript(jsonstr); } @@ -251,19 +251,19 @@ namespace AKSWebBrowser.Common Task.Run(async () => { param = MainModel.Base64str2(param); - Log.Info("返回数据:" + param); + //Log.Info("返回数据:" + param); JObject jo = (JObject)JsonConvert.DeserializeObject(param); bool fieldExists = jo.ContainsKey("callback"); if (fieldExists) { string callback = jo["callback"].ToString(); - Log.Info("回调js方法:" + callback); + //Log.Info("回调js方法:" + callback); string _parm = callback + "('" + param + "')"; await Parame.webBrowser.ExecuteJavaScript(_parm); } else { - Log.Info("回调js方法为空"); + //Log.Info("回调js方法为空"); } }); } @@ -272,7 +272,7 @@ namespace AKSWebBrowser.Common public void LinuxCmd(string command) { command = $"echo 'aks@123456' sudo -S chmod 777 {command}"; - Log.Info("执行命令:" + command); + //Log.Info("执行命令:" + command); // 启动进程 var process = new Process { @@ -290,8 +290,8 @@ namespace AKSWebBrowser.Common string output = process.StandardOutput.ReadToEnd(); string error = process.StandardError.ReadToEnd(); process.WaitForExit(); - Log.Info("执行命令结果返回:" + output); - Log.Info("执行命令错误结果返回:" + error); + //Log.Info("执行命令结果返回:" + output); + //Log.Info("执行命令错误结果返回:" + error); } //执行命令返回数组 diff --git a/CPF_Cef/Common/TcpClients.cs b/CPF_Cef/Common/TcpClients.cs index 1ef9f3d..51856fa 100644 --- a/CPF_Cef/Common/TcpClients.cs +++ b/CPF_Cef/Common/TcpClients.cs @@ -74,7 +74,7 @@ namespace AksWebBrowser.Common if (messageSize == -1) { Parame.tcpClient = null; - Console.WriteLine("与服务端连接断开"); + //Console.WriteLine("与服务端连接断开"); break; } // 读取消息内容 @@ -85,20 +85,45 @@ namespace AksWebBrowser.Common if (bytesRead < messageSize) { Parame.tcpClient = null; - Console.WriteLine("无法读取消息,可能是连接断开"); + //Console.WriteLine("无法读取消息,可能是连接断开"); break; } string message = Encoding.UTF8.GetString(buffer, 0, bytesRead); if (!message.Contains("heartbeatService")) { //接收到服务端口返回数据 - Console.WriteLine("接收到服务端口返回数据:{0}", message); + //Console.WriteLine("接收到服务端口返回数据:{0}", message); jsonstr = message; } + else if (message.Contains("@")) + { + string[] str = message.Split('@'); + string data = MainModel.Base64str2(str[1]); + if (data == "400" || data.Contains("fali")) + { + //读取签字版主动回复数据 + string result = "{\"message\":\"fail\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "签字失败" + "\"}"; + string _parm = "callback('" + result + "')"; + Task.Run(async () => + { + await Parame.webBrowser.ExecuteJavaScript(_parm); + }); + } + else + { + //读取签字版主动回复数据 + string result = "{\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"png\",\"data\":\"" + str[1] + "\"}"; + string _parm = "callback('" + result + "')"; + Task.Run(async () => + { + await Parame.webBrowser.ExecuteJavaScript(_parm); + }); + } + } else { //收到服务器心跳反馈 - Console.WriteLine("收到服务器心跳反馈:{0}", message); + //Console.WriteLine("收到服务器心跳反馈:{0}", message); SendDataWithHeader(stream, "heartbeatClient"); } } @@ -128,7 +153,7 @@ namespace AksWebBrowser.Common { Task.Delay(10).Wait(); timeout = timeout + 10; - if (timeout > 5000) + if (timeout > 9000) { jsonstr = MainModel.str2Base64("{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "获取数据超时!" + "\"}"); } @@ -158,7 +183,7 @@ namespace AksWebBrowser.Common // 每隔2分钟向服务端发送一条指令 Thread.Sleep(122000); SendDataWithHeader(stream, "keepAlive"); - Console.WriteLine("发送心跳指令关闭连接"); + //Console.WriteLine("发送心跳指令关闭连接"); } } catch { Parame.tcpClient = null; } @@ -180,7 +205,7 @@ namespace AksWebBrowser.Common if (headerBytesRead < 4) { Parame.tcpClient = null; - Console.WriteLine("无法读取包头,可能是连接断开"); + //Console.WriteLine("无法读取包头,可能是连接断开"); return -1; } return BitConverter.ToInt32(header, 0); diff --git a/CPF_Cef/Devices/SignDll.cs b/CPF_Cef/Devices/SignDll.cs new file mode 100644 index 0000000..0049ef1 --- /dev/null +++ b/CPF_Cef/Devices/SignDll.cs @@ -0,0 +1,260 @@ +using AKSWebBrowser.Commen; +using System; +using System.Globalization; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +//0816加实时报点 +[StructLayout(LayoutKind.Sequential)] +public struct TOUCH_INFO +{ + public int X; + public int Y; + public int Pressure; + public int SN; + public int btnID;//5寸 确定 重签 取消按钮 +} +namespace DevicesService.Devices +{ + + + public class SignDll + { + //public static PointF endPos; + //public static PointF beginPos; + //public static PointF frontPos; + //private static int xypointcount = 0; + //private static int[] lastpointx = new int[3]; + //private static int[] lastpointy = new int[3]; + //Point mPoint = new Point(-1, -1); + //private static System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red); + //private Graphics mGraphicsBuffer; + //private static Pen pen = new Pen(Color.Black); // + public static int status = -1; + //private static Bitmap bitmap = new Bitmap(594, 392); + public SignDll() + { + try + { + //endPos = new PointF(-1F, -1f); + //beginPos = new PointF(-1F, -1f); + //frontPos = new PointF(-1F, -1f); + //lastpointx[0] = -1; + //lastpointy[0] = -1; + //lastpointx[1] = -1; + //lastpointy[1] = -1; + //lastpointx[2] = -1; + //lastpointy[2] = -1; + //xypointcount = 0; + } + catch (Exception ex) { } + finally { } + } + + public static void DevGetTouchNumber(int number) + { + try + { + Log.Info(number.ToString()); + //1 签字确定按钮 2签字取消按钮 3 签字重签按钮(清空界面) + if (number == 1) + { + int ret = FiveInchDll.ComSignOK(); + Log.Info("ComSignOK:" + ret); + FiveInchDll.ComSetBackGroundAdv(); + } + else if (number == 3) + { + string UIFile = Environment.CurrentDirectory + @"/sign_ui.jpg"; + int ret = FiveInchDll.ComSetSignBackgroundImage(UIFile); + Log.Info("ComSetSignBackgroundImage:" + ret); + } + else + { + //lastpointx[0] = -1; + //lastpointy[0] = -1; + //lastpointx[1] = -1; + //lastpointy[1] = -1; + //lastpointx[2] = -1; + //lastpointy[2] = -1; + FiveInchDll.ComSetBackGroundAdv(); + } + } + catch { } + finally { } + } + + //0816加报点 + public static void GetTouchPoint(TOUCH_INFO[] info1) + { + return; + } + + //打开签字版 + public static int OpenComDevice() + { + //GetTouchNumber m_GetTouchCB = new(DevGetTouchNumber); + try + { + status = FiveInchDll.OpenComDevice(DevGetTouchNumber); + Log.Info(status.ToString()); + //Console.WriteLine("OpenComDevice:" + status); + //清空界面 + // GetTouchNumber(2); + if (status == 0) + { + //关闭报点 + int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint); + Log.Info(ret.ToString()); + if (true) + { + string UIFile = Environment.CurrentDirectory + @"/adv_ui.jpg"; + Log.Info(UIFile.ToString()); + int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile); + Log.Info(ret1.ToString()); + // Console.WriteLine("ComSendAdvantageImage:" + ret1); + FiveInchDll.ComSetBackGroundAdv(); + } + + if (true) + { + string UIFile = Environment.CurrentDirectory + @"/sign_ui.jpg"; + Log.Info(UIFile.ToString()); + int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile); + Log.Info(ret1.ToString()); + //Console.WriteLine("ComSetSignBackgroundImage:" + ret1); + } + } + ////status = FiveInchDll.OpenComDevice(DevGetTouchNumber); + //if (status == -1) + //{ + // status = FiveInchDll.OpenComDevice(DevGetTouchNumber); + // Log.Info(status.ToString()); + // //Console.WriteLine("OpenComDevice:" + status); + // //清空界面 + // // GetTouchNumber(2); + // if (status == 0) + // { + // //关闭报点 + // int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint); + // Log.Info(ret.ToString()); + // if (true) + // { + // string UIFile = Environment.CurrentDirectory + @"/adv_ui.jpg"; + // Log.Info(UIFile.ToString()); + // int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile); + // Log.Info(ret1.ToString()); + // // Console.WriteLine("ComSendAdvantageImage:" + ret1); + // FiveInchDll.ComSetBackGroundAdv(); + // } + + // if (true) + // { + // string UIFile = Environment.CurrentDirectory + @"/adv_ui.jpg"; + // Log.Info(UIFile.ToString()); + // int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile); + // Log.Info(ret1.ToString()); + // //Console.WriteLine("ComSetSignBackgroundImage:" + ret1); + // } + // } + //} + //else + //{ + // //清空界面 + // //GetTouchNumber(2); + // if (status == 0) + // { + // //关闭报点 + // int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint); + // if (true) + // { + // string UIFile = Environment.CurrentDirectory + @"/adv_ui.jpg"; + // int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile); + // //Console.WriteLine("ComSendAdvantageImage:" + ret1); + // FiveInchDll.ComSetBackGroundAdv(); + // } + + // if (true) + // { + // string UIFile = Environment.CurrentDirectory + @"/adv_ui.jpg"; + // int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile); + // //Console.WriteLine("ComSetSignBackgroundImage:" + ret1); + // } + // } + //} + } + catch { } + finally { } + return status; + } + + //关闭签字版 + public static int CloseComDevice() + { + int ret = -1; + try + { + if (status == 0) + { + ret = FiveInchDll.CloseComDevice(); + if (ret == 0) + { + status = -1; + } + } + } + catch { } + finally { } + return ret; + } + } + + class FiveInchDll + { + + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)] + public delegate void GetTouchNumber(int number); + //0816加报点 + [System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)] + public delegate void TOUCH_INFO_FUNC([MarshalAs(UnmanagedType.LPArray, SizeConst = 160)] TOUCH_INFO[] info); + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int ComSendPoint(int nState, [MarshalAs(UnmanagedType.FunctionPtr)] TOUCH_INFO_FUNC callback); //0816加报点 + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int OpenComDevice([MarshalAs(UnmanagedType.FunctionPtr)] GetTouchNumber callback); + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int CloseComDevice(); + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int ComSetSignBackgroundImage(string UIFile); + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int ComSetPictureSavePath(string PicturePath, int PicturePathLen); + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int ComSignOK(); + + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int ComSetPenStyle(int PenStyle); + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int ComGetDevSN(StringBuilder pDevSN, int iSync); + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int ComGetDevSN_Async(StringBuilder pDevSN); + + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int ComWhiteScreen(); + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int ComSendAdvantageImage(string UIFile); + + + [DllImport("libdevice5_hid_sdk.so", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] + public static extern int ComSetBackGroundAdv(); + } +} diff --git a/CPF_Cef/FrmMain.cs b/CPF_Cef/FrmMain.cs index 94d7037..8f8af94 100644 --- a/CPF_Cef/FrmMain.cs +++ b/CPF_Cef/FrmMain.cs @@ -139,12 +139,12 @@ namespace AKS.EnterpriseLibrary.WebBrowser { var bytes = element.GetBytes(); postParams = Encoding.UTF8.GetString(bytes); - Console.WriteLine("请求参数:" + postParams); + //Console.WriteLine("请求参数:" + postParams); } } } - Console.WriteLine("请求地址:" + request.Url.ToString()); + //Console.WriteLine("请求地址:" + request.Url.ToString()); } //调用JS内的JS方法 @@ -188,13 +188,13 @@ namespace AKS.EnterpriseLibrary.WebBrowser } else { - Log.Info("未获取授权"); + //Log.Info("未获取授权"); Utils.MessagesBox("未获取授权"); } } else { - Log.Info("未获取授权"); + //Log.Info("未获取授权"); Utils.MessagesBox("未获取授权"); } } diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs index 671b618..3230e91 100644 --- a/CPF_Cef/MainModel.cs +++ b/CPF_Cef/MainModel.cs @@ -4,6 +4,7 @@ using AKSWebBrowser.Commen; using AKSWebBrowser.Common; using CPF.Cef; using CPF.Mac.AppKit; +using DevicesService.Devices; using NAudio.Wave; using NAudio.Wave.SampleProviders; using SkiaSharp; @@ -56,7 +57,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser else { paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"1\",\"param\":{\"data\":\"" + "" + "\"}}"; - Log.Info("读取身份证卡号: " + paramsString + ""); + //Log.Info("读取身份证卡号: " + paramsString + ""); string base64 = str2Base64(paramsString); string str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); string result = Base64str2(str); @@ -98,7 +99,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser else { string paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"2\",\"param\":{\"ph\":\"" + ph + "\",\"ddrs\":\"" + ddrs + "\",\"qrcode\":\"" + qrcode + "\",\"ywmc\":\"" + ywmc + "\"}}"; - Log.Info("打印排队票据: " + paramsString + ""); + //Log.Info("打印排队票据: " + paramsString + ""); string base64 = str2Base64(paramsString); string str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); string result = Base64str2(str); @@ -137,12 +138,13 @@ namespace AKS.EnterpriseLibrary.WebBrowser } else if (Parame.tcpClient == null) { + return "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "硬件服务未启动" + "\"}"; } else { string paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"3\",\"param\":{\"text\":\"" + text + "\",\"ispaye\":\"" + ispaye + "\"}}"; - Log.Info("文字语音播报: " + paramsString + ""); + //Log.Info("文字语音播报: " + paramsString + ""); string base64 = str2Base64(paramsString); //if (base64.Length > 1024) //{ @@ -163,7 +165,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser // System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); // writer.Write(bytes, 0, bytes.Length); // writer.Close(); - // Log.Info("文字语音播报临时文件: " + path + ""); + // //Log.Info("文字语音播报临时文件: " + path + ""); // string id = Guid.NewGuid().ToString(); // //通过文件发送数据 // com.NewMethod(path, ".txt"); @@ -174,7 +176,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser // MatchCollection mc = re.Matches(url);//获取的是一个数组 // string pdfurl = mc[0].ToString() + "://" + mc[1].ToString() + urlpath; // paramsString = "{\"callback\":\"" + callback + "\",\"bsid\":\"" + id + "\",\"type\":\"3\",\"param\":{\"text\":\"" + pdfurl + "\",\"ispaye\":\"" + ispaye + "\"}}"; - // Log.Info("文字语音播报: " + paramsString + ""); + // //Log.Info("文字语音播报: " + paramsString + ""); // base64 = str2Base64(paramsString); //} string str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); @@ -247,7 +249,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser else { string paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"4\",\"param\":{\"content\":\"" + content + "\",\"phone\":\"" + phone + "\"}}"; - Log.Info("发送短信: " + paramsString + ""); + //Log.Info("发送短信: " + paramsString + ""); string base64 = str2Base64(paramsString); string str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); string result = Base64str2(str); @@ -281,20 +283,65 @@ namespace AKS.EnterpriseLibrary.WebBrowser } else if (Parame.tcpClient == null) { - return "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "硬件服务未启动" + "\"}"; + tcpClients = new TcpClients(); + if (Parame.tcpClient != null) + { + string paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"5\",\"param\":{\"url\":\"" + url + "\"}}"; + //Log.Info("打开高拍仪并且进行快速扫描文件: " + paramsString + ""); + string base64 = str2Base64(paramsString); + string str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); + string data = Base64str2(str); + if (data == "400" || data.Contains("fali")) + { + str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); + data = Base64str2(str); + if (data == "400" || data.Contains("fali")) + { + string result = "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "扫描文件失败,请重新扫描!" + "\"}"; + SubmitLogs(result, "openCamera"); + return result; + } + else + { + string result = "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + str + "\"}"; + SubmitLogs(result, "openCamera"); + return result; + } + } + else + { + string result = "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + str + "\"}"; + SubmitLogs(result, "openCamera"); + return result; + } + } + else { + return "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "硬件服务未启动" + "\"}"; + } } else { string paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"5\",\"param\":{\"url\":\"" + url + "\"}}"; - Log.Info("打开高拍仪并且进行快速扫描文件: " + paramsString + ""); + //Log.Info("打开高拍仪并且进行快速扫描文件: " + paramsString + ""); string base64 = str2Base64(paramsString); string str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); string data = Base64str2(str); if (data == "400" || data.Contains("fali")) { - string result = "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "扫描文件失败,请重新扫描!" + "\"}"; - SubmitLogs(result, "openCamera"); - return result; + str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); + data = Base64str2(str); + if (data == "400" || data.Contains("fali")) + { + string result = "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "扫描文件失败,请重新扫描!" + "\"}"; + SubmitLogs(result, "openCamera"); + return result; + } + else + { + string result = "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + str + "\"}"; + SubmitLogs(result, "openCamera"); + return result; + } } else { @@ -335,12 +382,17 @@ namespace AKS.EnterpriseLibrary.WebBrowser else { paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"6\",\"param\":{\"data\":\"" + "" + "\"}}"; - Log.Info("打开签字版: " + paramsString + ""); + //Log.Info("打开签字版: " + paramsString + ""); string base64 = str2Base64(paramsString); string str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); string result = Base64str2(str); SubmitLogs(result, "OpenSign"); return result; + + //SignDll.OpenComDevice(); + //string result = "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"png\",\"data\":\"" + "成功" + "\"}"; + //SubmitLogs(result, "OpenSign"); + //return result; } } catch (Exception ex) @@ -374,7 +426,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser else { paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"7\",\"param\":{\"data\":\"" + "" + "\"}}"; - Log.Info("关闭签字版: " + paramsString + ""); + //Log.Info("关闭签字版: " + paramsString + ""); string base64 = str2Base64(paramsString); string str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); string result = Base64str2(str); @@ -406,18 +458,14 @@ 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 { string paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"8\",\"param\":{\"url\":\"" + url + "\"}}"; - Log.Info("获取签字版数据: " + paramsString + ""); + //Log.Info("获取签字版数据: " + paramsString + ""); string base64 = str2Base64(paramsString); string str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); string data = Base64str2(str); - if (data == "400"|| data.Contains("fali")) + if (data == "400" || data.Contains("fali")) { string result = "{\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + "获取签字失败" + "\"}"; SubmitLogs(result, "OpenSign"); @@ -429,6 +477,12 @@ namespace AKS.EnterpriseLibrary.WebBrowser SubmitLogs(result, "OpenSign"); return result; } + + + + //string result = "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"png\",\"data\":\"" + "成功" + "\"}"; + //SubmitLogs(result, "OpenSign"); + //return result; } } catch (Exception ex) @@ -465,14 +519,14 @@ namespace AKS.EnterpriseLibrary.WebBrowser else { string paramsString = "{\"callback\":\"" + callback + "\",\"type\":\"11\",\"param\":{\"isopen\":\"" + isopen + "\",\"url\":\"" + url + "\"}}"; - Log.Info("开始录音、取消录音、结束录音: " + paramsString + ""); + //Log.Info("开始录音、取消录音、结束录音: " + paramsString + ""); string base64 = str2Base64(paramsString); string str = tcpClients.SendDataWithHeader(Parame.tcpClient.GetStream(), base64); //结束录音上传文件 if (!string.IsNullOrEmpty(url) && !isopen) { string tt = Base64str2(str); - Log.Info("结束录音上传文件"+tt); + //Log.Info("结束录音上传文件" + tt); //下载文件 DateTime dateTime = DateTime.Now; string time = DateTime.Now.ToString( @@ -501,7 +555,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser MatchCollection mc = re.Matches(url);//获取的是一个数组 string wavurl = mc[0].ToString() + "://" + mc[1].ToString() + urlpath; string result = "{\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"wav\",\"data\":\"" + wavurl + "\"}"; - Log.Info(result); + //Log.Info(result); SubmitLogs(result, "SoundRecording"); return result; } @@ -554,7 +608,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser Directory.CreateDirectory(dirpath); } var filepath = System.IO.Path.Combine(dirpath, time); - string path = dirpath + "\\" + time + "." + ext; + string path = dirpath + @"/" + time + "." + ext; WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); using (Stream stream = response.GetResponseStream()) @@ -565,7 +619,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser } } response.Close(); - Log.Info("根据文件base64打印: " + path + ""); + //Log.Info("根据文件base64打印: " + path + ""); string command = $"lp -d {PrinterName} {path}"; ShllCommad(command); }); @@ -623,7 +677,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); writer.Write(bytes, 0, bytes.Length); writer.Close(); - Log.Info("根据文件base64打印: " + path + ""); + //Log.Info("根据文件base64打印: " + path + ""); string command = $"lp -d {PrinterName} {path}"; ShllCommad(command); }); @@ -637,7 +691,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser //try //{ // string paramsString = "{\"callback\":\"" + callback + "\",\"bsid\":\"" + id + "\",\"type\":\"9\",\"param\":{\"url\":\"" + pdfurl + "\",\"ext\":\"" + ext + "\"}}"; - // Log.Info("根据文件base64打印: " + paramsString + ""); + // //Log.Info("根据文件base64打印: " + paramsString + ""); // string base64_1 = str2Base64(paramsString); // string str = com.SendData(base64_1, callback); // return Base64str2(str); @@ -802,7 +856,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser } } } - Log.Info("开始播放"); + //Log.Info("开始播放"); } /// @@ -820,11 +874,11 @@ namespace AKS.EnterpriseLibrary.WebBrowser audioFileReader.Dispose(); player = null; File.Delete(WaveOutPath); - Log.Info("播放完成"); + //Log.Info("播放完成"); } catch (Exception ex) { - Log.Info("播放完成,清除本地文件异常" + ex.Message); + //Log.Info("播放完成,清除本地文件异常" + ex.Message); } } @@ -921,7 +975,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser { byte[] c = Convert.FromBase64String(data); string result = System.Text.Encoding.UTF8.GetString(c); - Log.Info("接收返回数据:" + result); + //Log.Info("接收返回数据:" + result); return result; } @@ -1082,7 +1136,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser } catch (Exception ex) { - Log.Info("录音开启失败:" + ex.Message); + //Log.Info("录音开启失败:" + ex.Message); srpath = ""; return false; } @@ -1107,7 +1161,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser } catch (Exception ex) { - Log.Info("停止录音、取消录音失败:" + ex.Message); + //Log.Info("停止录音、取消录音失败:" + ex.Message); srpath = ""; return false; } @@ -1118,7 +1172,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser /// public static void ShllCommad(string command) { - Log.Info("执行命令:" + command); + //Log.Info("执行命令:" + command); // 启动进程 Typrocess = new Process { @@ -1229,7 +1283,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); - Log.Info(body); + //Log.Info(body); } } });