From 53448a3faac3dd39928a2a15aa7b8b9e449fdd51 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:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=AD=BE=E5=AD=97=E7=89=88?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DevicesService/Commen/COMUtils.cs | 18 +- DevicesService/Commen/Func.cs | 4 + DevicesService/Commen/ScriptCallbackObject.cs | 44 +- DevicesService/Commen/TcpServer.cs | 86 +++- DevicesService/Devices/HScamera.cs | 4 +- DevicesService/Devices/SignDll.cs | 387 ++++++++++-------- DevicesService/DevicesService.csproj | 8 +- DevicesService/Program.cs | 1 - 8 files changed, 340 insertions(+), 212 deletions(-) diff --git a/DevicesService/Commen/COMUtils.cs b/DevicesService/Commen/COMUtils.cs index fcc02a8..cad47fd 100644 --- a/DevicesService/Commen/COMUtils.cs +++ b/DevicesService/Commen/COMUtils.cs @@ -58,7 +58,7 @@ namespace DevicesService.Common timer.Elapsed += OnTimedEvent; timer.AutoReset = true;//重复执行 timer.Enabled = true;//启动定时器 - Log.Info("硬件服务启动成功"); + //Log.Info("硬件服务启动成功"); } catch (Exception ex) { @@ -87,7 +87,7 @@ namespace DevicesService.Common { indata = _json + indata; string result = Util.Base64str2(indata); - Log.Info("接收到COM口传来数据:" + result); + //Log.Info("接收到COM口传来数据:" + result); if (!string.IsNullOrEmpty(result)) { JObject jo = (JObject)JsonConvert.DeserializeObject(result); @@ -107,7 +107,7 @@ namespace DevicesService.Common data = joparam["data"].ToString(); resultback = scriptCallback.IDCardRead(data, callback); //Console.WriteLine(resultback); - Log.Info("读取身份证 返回数据:" + resultback); + //Log.Info("读取身份证 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendData(base64); @@ -122,7 +122,7 @@ namespace DevicesService.Common string qrcode = joparam["qrcode"].ToString(); string ywmc = joparam["ywmc"].ToString(); resultback = scriptCallback.SendByPrint(ph, ddrs, qrcode, ywmc, callback); - Log.Info("打印排队票据 返回数据:" + resultback); + //Log.Info("打印排队票据 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendData(base64); @@ -135,7 +135,7 @@ namespace DevicesService.Common string content = joparam["content"].ToString(); string phone = joparam["phone"].ToString(); resultback = scriptCallback.SendSSM(content, phone, callback); - Log.Info("发送短信 返回数据:" + resultback); + //Log.Info("发送短信 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendData(base64); @@ -147,7 +147,7 @@ namespace DevicesService.Common joparam = (JObject)JsonConvert.DeserializeObject(param); data = joparam["url"].ToString(); resultback = scriptCallback.openCamera(data, callback); - Log.Info("打开高拍仪并且进行快速扫描文件 返回数据:" + resultback); + //Log.Info("打开高拍仪并且进行快速扫描文件 返回数据:" + resultback); //base64 = Util.str2Base64(resultback); //向com对方发送数据 SendData(resultback); @@ -159,7 +159,7 @@ namespace DevicesService.Common joparam = (JObject)JsonConvert.DeserializeObject(param); data = joparam["data"].ToString(); resultback = scriptCallback.OpenSign(data, callback); - Log.Info("打开签字版数据 返回数据:" + resultback); + //Log.Info("打开签字版数据 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendData(base64); @@ -171,7 +171,7 @@ namespace DevicesService.Common joparam = (JObject)JsonConvert.DeserializeObject(param); data = joparam["data"].ToString(); resultback = scriptCallback.CloseSign(data, callback); - Log.Info("关闭签字版数据 返回数据:" + resultback); + //Log.Info("关闭签字版数据 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendData(base64); @@ -213,7 +213,7 @@ namespace DevicesService.Common { resultback = Util.str2Base64("400"); } - Log.Info("获取签字版数据 返回数据:" + resultback); + //Log.Info("获取签字版数据 返回数据:" + resultback); // base64 = Util.str2Base64(resultback); //向com对方发送数据 SendData(resultback); diff --git a/DevicesService/Commen/Func.cs b/DevicesService/Commen/Func.cs index 4f9924d..d098544 100644 --- a/DevicesService/Commen/Func.cs +++ b/DevicesService/Commen/Func.cs @@ -56,5 +56,9 @@ namespace DevicesService.Commen /// 音频文件播放与暂停 /// public const int Paly = 12; + /// + /// 读取指纹 + /// + public const int Finger = 13; } } diff --git a/DevicesService/Commen/ScriptCallbackObject.cs b/DevicesService/Commen/ScriptCallbackObject.cs index 26cb113..1f51180 100644 --- a/DevicesService/Commen/ScriptCallbackObject.cs +++ b/DevicesService/Commen/ScriptCallbackObject.cs @@ -228,7 +228,7 @@ namespace DevicesService.Common } catch (Exception ex) { - Log.Info("扫描仪异常:" + ex.Message); + //Log.Info("扫描仪异常:" + ex.Message); return Util.str2Base64("400"); } } @@ -344,7 +344,7 @@ namespace DevicesService.Common } catch (Exception ex) { - Log.Info("获取签字版数据异常:" + ex.Message); + //Log.Info("获取签字版数据异常:" + ex.Message); return Util.str2Base64("400"); } } @@ -467,7 +467,7 @@ namespace DevicesService.Common { string filename = Path.GetFileName(srpath); string path = ConfigurationManager.AppSettings["rootPath"].ToString() + "Record/" + filename; - Log.Info("结束录音上传文件" + path); + //Log.Info("结束录音上传文件" + path); return path; } else if (isopen)//开始录音 @@ -491,6 +491,32 @@ namespace DevicesService.Common } } + /// + /// 获取指纹数据 + /// + /// + public string ReadFingerData(string callback) + { + try + { + Task resultModel = deviceCaller.ReadFingerData(); + if (resultModel.Result.Code == "1") + { + string json = JsonConvert.SerializeObject(resultModel.Result); + return "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":" + json + "}"; + } + else + { + + return "{\"callback\":\"" + callback + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + resultModel.Result.Message + "\"}"; + } + } + catch (Exception ex) + { + return "{\"callback\":\"" + callback + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}"; + } + } + /// /// 播放与暂停 /// @@ -521,7 +547,7 @@ namespace DevicesService.Common if (string.IsNullOrEmpty(url)) { player.Play(); - Log.Info("恢复播放"); + //Log.Info("恢复播放"); return "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "恢复播放" + "\"}"; } else @@ -552,7 +578,7 @@ namespace DevicesService.Common if (string.IsNullOrEmpty(url)) { player.Pause(); - Log.Info("暂停播放"); + //Log.Info("暂停播放"); return "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "暂停播放" + "\"}"; } else @@ -563,7 +589,7 @@ namespace DevicesService.Common audioFileReader.Dispose(); player = null; File.Delete(WaveOutPath); - Log.Info("停止播放"); + //Log.Info("停止播放"); return "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放" + "\"}"; } } @@ -628,7 +654,7 @@ namespace DevicesService.Common } } } - Log.Info("开始播放"); + //Log.Info("开始播放"); } /// @@ -646,11 +672,11 @@ namespace DevicesService.Common audioFileReader.Dispose(); player = null; File.Delete(WaveOutPath); - Log.Info("播放完成"); + //Log.Info("播放完成"); } catch (Exception ex) { - Log.Info("播放完成,清除本地文件异常" + ex.Message); + //Log.Info("播放完成,清除本地文件异常" + ex.Message); } } diff --git a/DevicesService/Commen/TcpServer.cs b/DevicesService/Commen/TcpServer.cs index 813c42c..e2bd063 100644 --- a/DevicesService/Commen/TcpServer.cs +++ b/DevicesService/Commen/TcpServer.cs @@ -27,14 +27,14 @@ namespace DevicesService.Commen { public static List clients = new List(); private static ScriptCallbackObject scriptCallback = new ScriptCallbackObject(); - public void Start() + public void Start() { try { TcpListener listener = new TcpListener(IPAddress.Any, 1234); listener.Start(); Console.WriteLine("服务器已启动,等待客户端连接..."); - Timer timer = new Timer(SendHelloMessage, null, TimeSpan.Zero, TimeSpan.FromSeconds(20)); + Timer timer = new Timer(SendHelloMessage, null, TimeSpan.Zero, TimeSpan.FromSeconds(200)); while (true) { TcpClient client = listener.AcceptTcpClient(); @@ -44,7 +44,10 @@ namespace DevicesService.Commen ThreadPool.QueueUserWorkItem(ReceiveMessage, client); } } - catch (Exception ex) { Console.WriteLine(ex.Message); } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } finally { } } @@ -68,7 +71,10 @@ namespace DevicesService.Commen stream.Write(data, 0, data.Length); } } - catch (Exception ex) { Console.WriteLine(ex.Message); } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } finally { } } @@ -108,7 +114,6 @@ namespace DevicesService.Commen if (client != null) { NetworkStream stream = client.GetStream(); - while (true) { try @@ -136,7 +141,7 @@ namespace DevicesService.Commen { string result = Util.Base64str2(indata); - Log.Info("接收到COM口传来数据:" + result); + //Log.Info("接收到COM口传来数据:" + result); if (!string.IsNullOrEmpty(result)) { JObject jo = (JObject)JsonConvert.DeserializeObject(result); @@ -158,7 +163,7 @@ namespace DevicesService.Commen data = joparam["data"].ToString(); resultback = scriptCallback.IDCardRead(data, callback); //Console.WriteLine(resultback); - Log.Info("读取身份证 返回数据:" + resultback); + //Log.Info("读取身份证 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendDataWithHeader(client, base64); @@ -182,7 +187,7 @@ namespace DevicesService.Commen string qrcode = joparam["qrcode"].ToString(); string ywmc = joparam["ywmc"].ToString(); resultback = scriptCallback.SendByPrint(ph, ddrs, qrcode, ywmc, callback); - Log.Info("打印排队票据 返回数据:" + resultback); + //Log.Info("打印排队票据 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendDataWithHeader(client, base64); @@ -205,7 +210,7 @@ namespace DevicesService.Commen bool ispaye = Convert.ToBoolean(joparam["ispaye"].ToString()); resultback = scriptCallback.payleText(data, ispaye, callback); //Console.WriteLine(resultback); - Log.Info("文字语音播报 返回数据:" + resultback); + //Log.Info("文字语音播报 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendDataWithHeader(client, base64); @@ -227,7 +232,7 @@ namespace DevicesService.Commen string content = joparam["content"].ToString(); string phone = joparam["phone"].ToString(); resultback = scriptCallback.SendSSM(content, phone, callback); - Log.Info("发送短信 返回数据:" + resultback); + //Log.Info("发送短信 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendDataWithHeader(client, base64); @@ -248,7 +253,7 @@ namespace DevicesService.Commen joparam = (JObject)JsonConvert.DeserializeObject(param); data = joparam["url"].ToString(); resultback = scriptCallback.openCamera(data, callback); - Log.Info("打开高拍仪并且进行快速扫描文件 返回数据:" + resultback); + //Log.Info("打开高拍仪并且进行快速扫描文件 返回数据:" + resultback); //base64 = Util.str2Base64(resultback); //向com对方发送数据 SendDataWithHeader(client, resultback); @@ -269,7 +274,7 @@ namespace DevicesService.Commen joparam = (JObject)JsonConvert.DeserializeObject(param); data = joparam["data"].ToString(); resultback = scriptCallback.OpenSign(data, callback); - Log.Info("打开签字版数据 返回数据:" + resultback); + //Log.Info("打开签字版数据 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendDataWithHeader(client, base64); @@ -290,7 +295,7 @@ namespace DevicesService.Commen joparam = (JObject)JsonConvert.DeserializeObject(param); data = joparam["data"].ToString(); resultback = scriptCallback.CloseSign(data, callback); - Log.Info("关闭签字版数据 返回数据:" + resultback); + //Log.Info("关闭签字版数据 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendDataWithHeader(client, base64); @@ -309,7 +314,7 @@ namespace DevicesService.Commen try { resultback = scriptCallback.GetSignData(data, callback); - Log.Info("获取签字版数据 返回数据:" + resultback); + //Log.Info("获取签字版数据 返回数据:" + resultback); //base64 = Util.str2Base64(resultback); //向com对方发送数据 SendDataWithHeader(client, resultback); @@ -333,7 +338,30 @@ namespace DevicesService.Commen string url = joparam["url"].ToString(); bool isopen = Convert.ToBoolean(joparam["isopen"].ToString()); resultback = scriptCallback.SoundRecording(isopen, url, callback); - Log.Info("开始录音、取消录音、结束录音 返回数据:" + resultback); + //Log.Info("开始录音、取消录音、结束录音 返回数据:" + resultback); + base64 = Util.str2Base64(resultback); + //向com对方发送数据 + SendDataWithHeader(client, base64); + } + catch (Exception ex) + { + string rest = "{\"callback\":\"" + "callback" + "\",\"message\":\"fali\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}"; + base64 = Util.str2Base64(rest); + SendDataWithHeader(client, base64); + } + #endregion + break; + + //{"type":"13","param":{"data":""}} + case Func.Finger: + #region 读取指纹 + try + { + joparam = (JObject)JsonConvert.DeserializeObject(param); + data = joparam["data"].ToString(); + resultback = scriptCallback.IDCardRead(data, callback); + //Console.WriteLine(resultback); + //Log.Info("读取指纹 返回数据:" + resultback); base64 = Util.str2Base64(resultback); //向com对方发送数据 SendDataWithHeader(client, base64); @@ -344,6 +372,7 @@ namespace DevicesService.Commen base64 = Util.str2Base64(rest); SendDataWithHeader(client, base64); } + #endregion break; default: @@ -373,6 +402,7 @@ namespace DevicesService.Commen } catch { } finally { } + GC.Collect(); } } } @@ -427,6 +457,32 @@ namespace DevicesService.Commen catch { return -1; } finally { } } + + /// + /// 回传签字图片 + /// + /// + public static void SendImages(string Message) { + try + { + foreach (TcpClient client in clients) + { + try + { + SendDataWithHeader(client, " heartbeatService"); + } + catch (Exception ex) + { + Console.WriteLine("向客户端 {0} 发送消息失败:{1}", client.Client.RemoteEndPoint, ex.Message); + clients.Remove(client); + break; + } + } + } + catch { } + finally { } + + } } } diff --git a/DevicesService/Devices/HScamera.cs b/DevicesService/Devices/HScamera.cs index cfdee9b..42357de 100644 --- a/DevicesService/Devices/HScamera.cs +++ b/DevicesService/Devices/HScamera.cs @@ -143,7 +143,7 @@ namespace DevicesService.Devices } catch (Exception ex) { - Log.Info("扫描图片旋转异常1:" + ex.Message); + //Log.Info("扫描图片旋转异常1:" + ex.Message); return ""; } } @@ -190,7 +190,7 @@ namespace DevicesService.Devices } catch (Exception ex) { - Log.Info("扫描图片旋转异常:" + ex.Message); + //Log.Info("扫描图片旋转异常:" + ex.Message); return ex.Message; } } diff --git a/DevicesService/Devices/SignDll.cs b/DevicesService/Devices/SignDll.cs index febba5e..bd6b327 100644 --- a/DevicesService/Devices/SignDll.cs +++ b/DevicesService/Devices/SignDll.cs @@ -1,4 +1,5 @@ using DevicesService.Commen; +using DevicesService.Common; using Functions.FileExt; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using System; @@ -7,6 +8,7 @@ using System.Globalization; using System.IO; using System.Runtime.InteropServices; using System.Text; +using System.Threading.Tasks; //0816加实时报点 [StructLayout(LayoutKind.Sequential)] public struct TOUCH_INFO @@ -19,40 +21,42 @@ public struct TOUCH_INFO } 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); + //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); // + // private static Pen pen = new Pen(Color.Black); // public static int status = -1; - private static Bitmap bitmap = new Bitmap(594, 392); + //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; + //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) { Log.Info(ex.Message); } + catch (Exception ex) { } finally { } } - public static void GetTouchNumber(int number) + public static void DevGetTouchNumber(int number) { try { @@ -63,6 +67,12 @@ namespace DevicesService.Devices int ret = FiveInchDll.ComSignOK(); Console.WriteLine("ComSignOK:" + ret); FiveInchDll.ComSetBackGroundAdv(); + Task.Run(() => { + ScriptCallbackObject script = new ScriptCallbackObject(); + string str = script.GetSignData("","'"); + str = "@" + str; + TcpServer.SendImages(str); + }); } else if (number == 3) { @@ -72,17 +82,16 @@ namespace DevicesService.Devices } else { - lastpointx[0] = -1; - lastpointy[0] = -1; - lastpointx[1] = -1; - lastpointy[1] = -1; - lastpointx[2] = -1; - lastpointy[2] = -1; - + //lastpointx[0] = -1; + //lastpointy[0] = -1; + //lastpointx[1] = -1; + //lastpointy[1] = -1; + //lastpointx[2] = -1; + //lastpointy[2] = -1; FiveInchDll.ComSetBackGroundAdv(); } } - catch (Exception ex) { Log.Info(ex.Message); } + catch { } finally { } } @@ -90,163 +99,195 @@ namespace DevicesService.Devices public static void GetTouchPoint(TOUCH_INFO[] info1) { return; - int x = 0, y = 0; - int pressurevl; - int dx = 0, dy = 0; + //int x = 0, y = 0; + //int pressurevl; + //int dx = 0, dy = 0; + + //for (int k = 0; k < 80; k++) + //{ + + // x = info1[k].X; + // y = info1[k].Y; + + // //落笔 + // if (info1[k].Pressure > 0) + // { + // if (info1[k].Pressure > 0 && info1[k].Pressure < 500) + // { + // pressurevl = 1; + // pen.Width = 1; + // } + // else if (info1[k].Pressure >= 500 && info1[k].Pressure < 1000) + // { + // pressurevl = 2; + // pen.Width = 2; + // } + // else if (info1[k].Pressure >= 1000 && info1[k].Pressure < 1500) + // { + // pressurevl = 3; + // pen.Width = 3; + // } + // else if (info1[k].Pressure >= 1500 && info1[k].Pressure < 2048) + // { + // pressurevl = 4; + // pen.Width = 4; + // } + // else + // { + // pressurevl = 0; + // pen.Width = 1; + // } + // } + // else + // { + // //抬笔 + // pressurevl = 0; + + // lastpointx[0] = -1; + // lastpointy[0] = -1; + // lastpointx[1] = -1; + // lastpointy[1] = -1; + // lastpointx[2] = -1; + // lastpointy[2] = -1; + // continue; + // } + + // if (info1[k].Pressure > 10) //有画线宽度 + // { + // lastpointx[2] = x; + // lastpointy[2] = y; + + + // if (lastpointx[2] != -1) + // { + // if (lastpointx[1] != -1 && lastpointx[0] != -1) + // { + // //float dx = Math.Abs(lastpointx[2] - beginPos.X); + // //float dy = Math.Abs(endPos.Y - beginPos.Y); + + // dx = Math.Abs(lastpointx[2] - lastpointx[1]); + // dy = Math.Abs(lastpointy[2] - lastpointy[1]); + // if ((dx != 0) && (dy != 0)) + // { + + // if (lastpointy[1] != -1 && lastpointy[2] != -1) //y轴相同的点不画,直接跳过 + // { + // if (lastpointx[1] != -1 && lastpointx[2] != -1) //第3个点和第二个点比较是否x坐标在同一个位置,不是就执行画第一个点到第二个点的线 + // { + // //painter->drawLine(frontPos, beginPos); //画线 + // //g.DrawLine(pen, lastpointx[0], lastpointy[0], lastpointx[1], lastpointy[1]); + // //painter->drawPoint(beginPos); //画点 + // //frontPos = beginPos; + // //beginPos = endPos; + // lastpointx[0] = lastpointx[1]; + // lastpointy[0] = lastpointy[1]; + // lastpointx[1] = lastpointx[2]; + // lastpointy[1] = lastpointy[2]; + // } + // else + // { + // //是就执行画第一个点到第三个点的线 + // //painter->drawLine(frontPos, endPos); + // //g.DrawLine(pen, lastpointx[0], lastpointy[0], lastpointx[2], lastpointy[2]); + // //frontPos = endPos; //第三个点赋值第一个点 + // //beginPos = QPointF(0, 0); //第二个点置空 + // //beginPos.X = -1; + // //beginPos.Y = -1; + // lastpointx[0] = lastpointx[2]; + // lastpointy[0] = lastpointy[2]; + // lastpointx[1] = -1; + // lastpointy[1] = -1; + // } + // } + // } + // }// + // else + // { + // if (lastpointx[1] != -1) //不为空在赋值,防止丢弃点时赋空值 + // { + // lastpointx[0] = lastpointx[1]; + // lastpointy[0] = lastpointy[1]; + // } + // lastpointx[1] = lastpointx[2]; + // lastpointy[1] = lastpointy[2]; + // } + // } + + // } + // else + // { + // dx = dy = 0; + // lastpointx[0] = -1; + // lastpointy[0] = -1; + // lastpointx[1] = -1; + // lastpointy[1] = -1; + // lastpointx[2] = -1; + // lastpointy[2] = -1; + + // } + //} + } - for (int k = 0; k < 80; k++) + //打开签字版 + public static int OpenComDevice() + { + //GetTouchNumber m_GetTouchCB = new(DevGetTouchNumber); + try { - - x = info1[k].X; - y = info1[k].Y; - - //落笔 - if (info1[k].Pressure > 0) - { - if (info1[k].Pressure > 0 && info1[k].Pressure < 500) - { - pressurevl = 1; - pen.Width = 1; - } - else if (info1[k].Pressure >= 500 && info1[k].Pressure < 1000) - { - pressurevl = 2; - pen.Width = 2; - } - else if (info1[k].Pressure >= 1000 && info1[k].Pressure < 1500) - { - pressurevl = 3; - pen.Width = 3; - } - else if (info1[k].Pressure >= 1500 && info1[k].Pressure < 2048) - { - pressurevl = 4; - pen.Width = 4; - } - else - { - pressurevl = 0; - pen.Width = 1; - } - } - else - { - //抬笔 - pressurevl = 0; - - lastpointx[0] = -1; - lastpointy[0] = -1; - lastpointx[1] = -1; - lastpointy[1] = -1; - lastpointx[2] = -1; - lastpointy[2] = -1; - continue; - } - - if (info1[k].Pressure > 10) //有画线宽度 + status = FiveInchDll.OpenComDevice(DevGetTouchNumber); + if (status == -1) { - lastpointx[2] = x; - lastpointy[2] = y; - - - if (lastpointx[2] != -1) + status = FiveInchDll.OpenComDevice(DevGetTouchNumber); + Console.WriteLine("OpenComDevice:" + status); + //清空界面 + // GetTouchNumber(2); + if (status == 0) { - if (lastpointx[1] != -1 && lastpointx[0] != -1) + //关闭报点 + int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint); + if (true) { - //float dx = Math.Abs(lastpointx[2] - beginPos.X); - //float dy = Math.Abs(endPos.Y - beginPos.Y); - - dx = Math.Abs(lastpointx[2] - lastpointx[1]); - dy = Math.Abs(lastpointy[2] - lastpointy[1]); - if ((dx != 0) && (dy != 0)) - { - - if (lastpointy[1] != -1 && lastpointy[2] != -1) //y轴相同的点不画,直接跳过 - { - if (lastpointx[1] != -1 && lastpointx[2] != -1) //第3个点和第二个点比较是否x坐标在同一个位置,不是就执行画第一个点到第二个点的线 - { - //painter->drawLine(frontPos, beginPos); //画线 - //g.DrawLine(pen, lastpointx[0], lastpointy[0], lastpointx[1], lastpointy[1]); - //painter->drawPoint(beginPos); //画点 - //frontPos = beginPos; - //beginPos = endPos; - lastpointx[0] = lastpointx[1]; - lastpointy[0] = lastpointy[1]; - lastpointx[1] = lastpointx[2]; - lastpointy[1] = lastpointy[2]; - } - else - { - //是就执行画第一个点到第三个点的线 - //painter->drawLine(frontPos, endPos); - //g.DrawLine(pen, lastpointx[0], lastpointy[0], lastpointx[2], lastpointy[2]); - //frontPos = endPos; //第三个点赋值第一个点 - //beginPos = QPointF(0, 0); //第二个点置空 - //beginPos.X = -1; - //beginPos.Y = -1; - lastpointx[0] = lastpointx[2]; - lastpointy[0] = lastpointy[2]; - lastpointx[1] = -1; - lastpointy[1] = -1; - } - } - } - }// - else + string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\adv_ui.jpg"; + int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile); + Console.WriteLine("ComSendAdvantageImage:" + ret1); + FiveInchDll.ComSetBackGroundAdv(); + } + + if (true) { - if (lastpointx[1] != -1) //不为空在赋值,防止丢弃点时赋空值 - { - lastpointx[0] = lastpointx[1]; - lastpointy[0] = lastpointy[1]; - } - lastpointx[1] = lastpointx[2]; - lastpointy[1] = lastpointy[2]; + string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg"; + int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile); + Console.WriteLine("ComSetSignBackgroundImage:" + ret1); } } - } else { - dx = dy = 0; - lastpointx[0] = -1; - lastpointy[0] = -1; - lastpointx[1] = -1; - lastpointy[1] = -1; - lastpointx[2] = -1; - lastpointy[2] = -1; - - } - } - } - - //打开签字版 - public static int OpenComDevice() - { - try - { - status = FiveInchDll.OpenComDevice(GetTouchNumber); - Console.WriteLine("OpenComDevice:" + status); - if (status == 0) - { - //关闭报点 - int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint); - if (true) + //清空界面 + //GetTouchNumber(2); + if (status == 0) { - string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\adv_ui.jpg"; - int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile); - Console.WriteLine("ComSendAdvantageImage:" + ret1); - FiveInchDll.ComSetBackGroundAdv(); - } + //关闭报点 + int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint); + if (true) + { + string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\adv_ui.jpg"; + int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile); + Console.WriteLine("ComSendAdvantageImage:" + ret1); + FiveInchDll.ComSetBackGroundAdv(); + } - if (true) - { - string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg"; - int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile); - Console.WriteLine("ComSetSignBackgroundImage:" + ret1); + if (true) + { + string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg"; + int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile); + Console.WriteLine("ComSetSignBackgroundImage:" + ret1); + } } } + } - catch(Exception ex) { Log.Info(ex.Message); } + catch { } finally { } return status; } @@ -272,7 +313,7 @@ namespace DevicesService.Devices } //保存签字版数据 - public static string ComSetPictureSavePath() + public string ComSetPictureSavePath() { try { @@ -303,9 +344,9 @@ namespace DevicesService.Devices 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); diff --git a/DevicesService/DevicesService.csproj b/DevicesService/DevicesService.csproj index a403bb9..aa454b0 100644 --- a/DevicesService/DevicesService.csproj +++ b/DevicesService/DevicesService.csproj @@ -1,4 +1,4 @@ - + Exe @@ -14,20 +14,22 @@ true AnyCPU + False true AnyCPU + False - True + False - True + False diff --git a/DevicesService/Program.cs b/DevicesService/Program.cs index 1332bb2..62fe3c7 100644 --- a/DevicesService/Program.cs +++ b/DevicesService/Program.cs @@ -34,7 +34,6 @@ namespace DevicesService FileProvider = new PhysicalFileProvider(pathToFiles), RequestPath = "/wwwroot" }); - // 处理文件未找到的情况 app.Use((context, next) => {