胡超1 1 year ago
parent
commit
15eb5f307b
  1. 20
      DevicesService/Commen/COMUtils.cs
  2. 18
      DevicesService/Commen/ScriptCallbackObject.cs
  3. 61
      DevicesService/Commen/TcpServer.cs
  4. 4
      DevicesService/Devices/HScamera.cs
  5. 263
      DevicesService/Devices/SignDll.cs

20
DevicesService/Commen/COMUtils.cs

@ -58,7 +58,7 @@ namespace DevicesService.Common
timer.Elapsed += OnTimedEvent; timer.Elapsed += OnTimedEvent;
timer.AutoReset = true;//重复执行 timer.AutoReset = true;//重复执行
timer.Enabled = true;//启动定时器 timer.Enabled = true;//启动定时器
//Log.Info("硬件服务启动成功"); ////Log.Info("硬件服务启动成功");
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -87,7 +87,7 @@ namespace DevicesService.Common
{ {
indata = _json + indata; indata = _json + indata;
string result = Util.Base64str2(indata); string result = Util.Base64str2(indata);
//Log.Info("接收到COM口传来数据:" + result); ////Log.Info("接收到COM口传来数据:" + result);
if (!string.IsNullOrEmpty(result)) if (!string.IsNullOrEmpty(result))
{ {
JObject jo = (JObject)JsonConvert.DeserializeObject(result); JObject jo = (JObject)JsonConvert.DeserializeObject(result);
@ -106,8 +106,8 @@ namespace DevicesService.Common
joparam = (JObject)JsonConvert.DeserializeObject(param); joparam = (JObject)JsonConvert.DeserializeObject(param);
data = joparam["data"].ToString(); data = joparam["data"].ToString();
resultback = scriptCallback.IDCardRead(data, callback); resultback = scriptCallback.IDCardRead(data, callback);
//Console.WriteLine(resultback); Console.WriteLine(resultback);
Log.Info("读取身份证 返回数据:" + resultback); //Log.Info("读取身份证 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendData(base64); SendData(base64);
@ -122,7 +122,7 @@ namespace DevicesService.Common
string qrcode = joparam["qrcode"].ToString(); string qrcode = joparam["qrcode"].ToString();
string ywmc = joparam["ywmc"].ToString(); string ywmc = joparam["ywmc"].ToString();
resultback = scriptCallback.SendByPrint(ph, ddrs, qrcode, ywmc, callback); resultback = scriptCallback.SendByPrint(ph, ddrs, qrcode, ywmc, callback);
//Log.Info("打印排队票据 返回数据:" + resultback); ////Log.Info("打印排队票据 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendData(base64); SendData(base64);
@ -135,7 +135,7 @@ namespace DevicesService.Common
string content = joparam["content"].ToString(); string content = joparam["content"].ToString();
string phone = joparam["phone"].ToString(); string phone = joparam["phone"].ToString();
resultback = scriptCallback.SendSSM(content, phone, callback); resultback = scriptCallback.SendSSM(content, phone, callback);
//Log.Info("发送短信 返回数据:" + resultback); ////Log.Info("发送短信 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendData(base64); SendData(base64);
@ -147,7 +147,7 @@ namespace DevicesService.Common
joparam = (JObject)JsonConvert.DeserializeObject(param); joparam = (JObject)JsonConvert.DeserializeObject(param);
data = joparam["url"].ToString(); data = joparam["url"].ToString();
resultback = scriptCallback.openCamera(data, callback); resultback = scriptCallback.openCamera(data, callback);
//Log.Info("打开高拍仪并且进行快速扫描文件 返回数据:" + resultback); ////Log.Info("打开高拍仪并且进行快速扫描文件 返回数据:" + resultback);
//base64 = Util.str2Base64(resultback); //base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendData(resultback); SendData(resultback);
@ -159,7 +159,7 @@ namespace DevicesService.Common
joparam = (JObject)JsonConvert.DeserializeObject(param); joparam = (JObject)JsonConvert.DeserializeObject(param);
data = joparam["data"].ToString(); data = joparam["data"].ToString();
resultback = scriptCallback.OpenSign(data, callback); resultback = scriptCallback.OpenSign(data, callback);
//Log.Info("打开签字版数据 返回数据:" + resultback); ////Log.Info("打开签字版数据 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendData(base64); SendData(base64);
@ -171,7 +171,7 @@ namespace DevicesService.Common
joparam = (JObject)JsonConvert.DeserializeObject(param); joparam = (JObject)JsonConvert.DeserializeObject(param);
data = joparam["data"].ToString(); data = joparam["data"].ToString();
resultback = scriptCallback.CloseSign(data, callback); resultback = scriptCallback.CloseSign(data, callback);
//Log.Info("关闭签字版数据 返回数据:" + resultback); ////Log.Info("关闭签字版数据 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendData(base64); SendData(base64);
@ -213,7 +213,7 @@ namespace DevicesService.Common
{ {
resultback = Util.str2Base64("400"); resultback = Util.str2Base64("400");
} }
//Log.Info("获取签字版数据 返回数据:" + resultback); ////Log.Info("获取签字版数据 返回数据:" + resultback);
// base64 = Util.str2Base64(resultback); // base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendData(resultback); SendData(resultback);

18
DevicesService/Commen/ScriptCallbackObject.cs

@ -228,7 +228,7 @@ namespace DevicesService.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
//Log.Info("扫描仪异常:" + ex.Message); ////Log.Info("扫描仪异常:" + ex.Message);
return Util.str2Base64("400"); return Util.str2Base64("400");
} }
} }
@ -344,7 +344,7 @@ namespace DevicesService.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
//Log.Info("获取签字版数据异常:" + ex.Message); ////Log.Info("获取签字版数据异常:" + ex.Message);
return Util.str2Base64("400"); return Util.str2Base64("400");
} }
} }
@ -467,7 +467,7 @@ namespace DevicesService.Common
{ {
string filename = Path.GetFileName(srpath); string filename = Path.GetFileName(srpath);
string path = ConfigurationManager.AppSettings["rootPath"].ToString() + "Record/" + filename; string path = ConfigurationManager.AppSettings["rootPath"].ToString() + "Record/" + filename;
//Log.Info("结束录音上传文件" + path); ////Log.Info("结束录音上传文件" + path);
return path; return path;
} }
else if (isopen)//开始录音 else if (isopen)//开始录音
@ -547,7 +547,7 @@ namespace DevicesService.Common
if (string.IsNullOrEmpty(url)) if (string.IsNullOrEmpty(url))
{ {
player.Play(); player.Play();
//Log.Info("恢复播放"); ////Log.Info("恢复播放");
return "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "恢复播放" + "\"}"; return "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "恢复播放" + "\"}";
} }
else else
@ -578,7 +578,7 @@ namespace DevicesService.Common
if (string.IsNullOrEmpty(url)) if (string.IsNullOrEmpty(url))
{ {
player.Pause(); player.Pause();
//Log.Info("暂停播放"); ////Log.Info("暂停播放");
return "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "暂停播放" + "\"}"; return "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "暂停播放" + "\"}";
} }
else else
@ -589,7 +589,7 @@ namespace DevicesService.Common
audioFileReader.Dispose(); audioFileReader.Dispose();
player = null; player = null;
File.Delete(WaveOutPath); File.Delete(WaveOutPath);
//Log.Info("停止播放"); ////Log.Info("停止播放");
return "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放" + "\"}"; return "{\"callback\":\"" + callback + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放" + "\"}";
} }
} }
@ -654,7 +654,7 @@ namespace DevicesService.Common
} }
} }
} }
//Log.Info("开始播放"); ////Log.Info("开始播放");
} }
/// <summary> /// <summary>
@ -672,11 +672,11 @@ namespace DevicesService.Common
audioFileReader.Dispose(); audioFileReader.Dispose();
player = null; player = null;
File.Delete(WaveOutPath); File.Delete(WaveOutPath);
//Log.Info("播放完成"); ////Log.Info("播放完成");
} }
catch (Exception ex) catch (Exception ex)
{ {
//Log.Info("播放完成,清除本地文件异常" + ex.Message); ////Log.Info("播放完成,清除本地文件异常" + ex.Message);
} }
} }

61
DevicesService/Commen/TcpServer.cs

@ -38,7 +38,7 @@ namespace DevicesService.Commen
while (true) while (true)
{ {
TcpClient client = listener.AcceptTcpClient(); TcpClient client = listener.AcceptTcpClient();
Console.WriteLine("客户端已连接:{0}", client.Client.RemoteEndPoint); Console.WriteLine("客户端已连接:{0}", client.Client.RemoteEndPoint);
clients.Add(client); clients.Add(client);
// 启动线程,接收客户端消息 // 启动线程,接收客户端消息
ThreadPool.QueueUserWorkItem(ReceiveMessage, client); ThreadPool.QueueUserWorkItem(ReceiveMessage, client);
@ -88,7 +88,7 @@ namespace DevicesService.Commen
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("向客户端 {0} 发送消息失败:{1}", client.Client.RemoteEndPoint, ex.Message); Console.WriteLine("向客户端 {0} 发送消息失败:{1}", client.Client.RemoteEndPoint, ex.Message);
clients.Remove(client); clients.Remove(client);
break; break;
} }
@ -122,20 +122,20 @@ namespace DevicesService.Commen
if (bytesRead < messageSize) if (bytesRead < messageSize)
{ {
Console.WriteLine("无法读取消息,可能是连接断开:{0}", client.Client.RemoteEndPoint); Console.WriteLine("无法读取消息,可能是连接断开:{0}", client.Client.RemoteEndPoint);
clients.Remove(client); clients.Remove(client);
break; break;
} }
string message = Encoding.UTF8.GetString(buffer, 0, bytesRead); string message = Encoding.UTF8.GetString(buffer, 0, bytesRead);
if (!message.Contains("heartbeatClient") || message != "keepAlive") if (!message.Contains("heartbeatClient") || message != "keepAlive")
{ {
Console.WriteLine("收到客户端消息:{0}", message); Console.WriteLine("收到客户端消息:{0}", message);
string indata = message; string indata = message;
if (!string.IsNullOrEmpty(indata)) if (!string.IsNullOrEmpty(indata))
{ {
string result = Util.Base64str2(indata); string result = Util.Base64str2(indata);
//Log.Info("接收到COM口传来数据:" + result); ////Log.Info("接收到COM口传来数据:" + result);
if (!string.IsNullOrEmpty(result)) if (!string.IsNullOrEmpty(result))
{ {
JObject jo = (JObject)JsonConvert.DeserializeObject(result); JObject jo = (JObject)JsonConvert.DeserializeObject(result);
@ -156,8 +156,8 @@ namespace DevicesService.Commen
joparam = (JObject)JsonConvert.DeserializeObject(param); joparam = (JObject)JsonConvert.DeserializeObject(param);
data = joparam["data"].ToString(); data = joparam["data"].ToString();
resultback = scriptCallback.IDCardRead(data, callback); resultback = scriptCallback.IDCardRead(data, callback);
//Console.WriteLine(resultback); Console.WriteLine(resultback);
Log.Info("读取身份证 返回数据:" + resultback); //Log.Info("读取身份证 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendDataWithHeader(client, base64); SendDataWithHeader(client, base64);
@ -181,7 +181,7 @@ namespace DevicesService.Commen
string qrcode = joparam["qrcode"].ToString(); string qrcode = joparam["qrcode"].ToString();
string ywmc = joparam["ywmc"].ToString(); string ywmc = joparam["ywmc"].ToString();
resultback = scriptCallback.SendByPrint(ph, ddrs, qrcode, ywmc, callback); resultback = scriptCallback.SendByPrint(ph, ddrs, qrcode, ywmc, callback);
//Log.Info("打印排队票据 返回数据:" + resultback); ////Log.Info("打印排队票据 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendDataWithHeader(client, base64); SendDataWithHeader(client, base64);
@ -203,8 +203,8 @@ namespace DevicesService.Commen
data = joparam["text"].ToString(); data = joparam["text"].ToString();
bool ispaye = Convert.ToBoolean(joparam["ispaye"].ToString()); bool ispaye = Convert.ToBoolean(joparam["ispaye"].ToString());
resultback = scriptCallback.payleText(data, ispaye, callback); resultback = scriptCallback.payleText(data, ispaye, callback);
//Console.WriteLine(resultback); Console.WriteLine(resultback);
Log.Info("文字语音播报 返回数据:" + resultback); //Log.Info("文字语音播报 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendDataWithHeader(client, base64); SendDataWithHeader(client, base64);
@ -226,7 +226,7 @@ namespace DevicesService.Commen
string content = joparam["content"].ToString(); string content = joparam["content"].ToString();
string phone = joparam["phone"].ToString(); string phone = joparam["phone"].ToString();
resultback = scriptCallback.SendSSM(content, phone, callback); resultback = scriptCallback.SendSSM(content, phone, callback);
//Log.Info("发送短信 返回数据:" + resultback); ////Log.Info("发送短信 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendDataWithHeader(client, base64); SendDataWithHeader(client, base64);
@ -247,7 +247,7 @@ namespace DevicesService.Commen
joparam = (JObject)JsonConvert.DeserializeObject(param); joparam = (JObject)JsonConvert.DeserializeObject(param);
data = joparam["url"].ToString(); data = joparam["url"].ToString();
resultback = scriptCallback.openCamera(data, callback); resultback = scriptCallback.openCamera(data, callback);
//Log.Info("打开高拍仪并且进行快速扫描文件 返回数据:" + resultback); ////Log.Info("打开高拍仪并且进行快速扫描文件 返回数据:" + resultback);
//base64 = Util.str2Base64(resultback); //base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendDataWithHeader(client, resultback); SendDataWithHeader(client, resultback);
@ -268,7 +268,7 @@ namespace DevicesService.Commen
joparam = (JObject)JsonConvert.DeserializeObject(param); joparam = (JObject)JsonConvert.DeserializeObject(param);
data = joparam["data"].ToString(); data = joparam["data"].ToString();
resultback = scriptCallback.OpenSign(data, callback); resultback = scriptCallback.OpenSign(data, callback);
//Log.Info("打开签字版数据 返回数据:" + resultback); ////Log.Info("打开签字版数据 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendDataWithHeader(client, base64); SendDataWithHeader(client, base64);
@ -289,7 +289,7 @@ namespace DevicesService.Commen
joparam = (JObject)JsonConvert.DeserializeObject(param); joparam = (JObject)JsonConvert.DeserializeObject(param);
data = joparam["data"].ToString(); data = joparam["data"].ToString();
resultback = scriptCallback.CloseSign(data, callback); resultback = scriptCallback.CloseSign(data, callback);
//Log.Info("关闭签字版数据 返回数据:" + resultback); ////Log.Info("关闭签字版数据 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendDataWithHeader(client, base64); SendDataWithHeader(client, base64);
@ -308,7 +308,7 @@ namespace DevicesService.Commen
try try
{ {
resultback = scriptCallback.GetSignData(data, callback); resultback = scriptCallback.GetSignData(data, callback);
//Log.Info("获取签字版数据 返回数据:" + resultback); ////Log.Info("获取签字版数据 返回数据:" + resultback);
//base64 = Util.str2Base64(resultback); //base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendDataWithHeader(client, resultback); SendDataWithHeader(client, resultback);
@ -332,7 +332,7 @@ namespace DevicesService.Commen
string url = joparam["url"].ToString(); string url = joparam["url"].ToString();
bool isopen = Convert.ToBoolean(joparam["isopen"].ToString()); bool isopen = Convert.ToBoolean(joparam["isopen"].ToString());
resultback = scriptCallback.SoundRecording(isopen, url, callback); resultback = scriptCallback.SoundRecording(isopen, url, callback);
Log.Info("开始录音、取消录音、结束录音 返回数据:" + resultback); //Log.Info("开始录音、取消录音、结束录音 返回数据:" + resultback);
base64 = Util.str2Base64(resultback); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendDataWithHeader(client, base64); SendDataWithHeader(client, base64);
@ -365,7 +365,7 @@ namespace DevicesService.Commen
if (message == "keepAlive") if (message == "keepAlive")
{ {
// 客户端发送心跳指令,关闭连接 // 客户端发送心跳指令,关闭连接
Console.WriteLine("客户端发送了心跳指令,关闭连接:{0}", client.Client.RemoteEndPoint); Console.WriteLine("客户端发送了心跳指令,关闭连接:{0}", client.Client.RemoteEndPoint);
clients.Remove(client); clients.Remove(client);
client.Close(); client.Close();
break; break;
@ -428,6 +428,33 @@ namespace DevicesService.Commen
catch { return -1; } catch { return -1; }
finally { } finally { }
} }
/// <summary>
/// 回传签字图片
/// </summary>
/// <param name="Message"></param>
public static void SendImages(string Message)
{
try
{
foreach (TcpClient client in clients)
{
try
{
SendDataWithHeader(client, Message);
}
catch (Exception ex)
{
Console.WriteLine("向客户端 {0} 发送消息失败:{1}", client.Client.RemoteEndPoint, ex.Message);
clients.Remove(client);
break;
}
}
}
catch { }
finally { }
}
} }
} }

4
DevicesService/Devices/HScamera.cs

@ -143,7 +143,7 @@ namespace DevicesService.Devices
} }
catch (Exception ex) catch (Exception ex)
{ {
//Log.Info("扫描图片旋转异常1:" + ex.Message); ////Log.Info("扫描图片旋转异常1:" + ex.Message);
return ""; return "";
} }
} }
@ -190,7 +190,7 @@ namespace DevicesService.Devices
} }
catch (Exception ex) catch (Exception ex)
{ {
//Log.Info("扫描图片旋转异常:" + ex.Message); ////Log.Info("扫描图片旋转异常:" + ex.Message);
return ex.Message; return ex.Message;
} }
} }

263
DevicesService/Devices/SignDll.cs

@ -9,50 +9,26 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
//0816加实时报点
[StructLayout(LayoutKind.Sequential)]
public struct TOUCH_INFO public struct TOUCH_INFO
{ {
public int X;
public int Y;
public int Pressure;
public int SN;
public int btnID;//5寸 确定 重签 取消按钮 public int btnID;//5寸 确定 重签 取消按钮
} }
namespace DevicesService.Devices namespace DevicesService.Devices
{ {
public class SignDll 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; public static int status = -1;
private static Bitmap bitmap = new Bitmap(594, 392);
public SignDll() public SignDll()
{ {
try try
{ {
endPos = new PointF(-1F, -1f); status = FiveInchDll.OpenComDevice(DevGetTouchNumber);
beginPos = new PointF(-1F, -1f); Console.WriteLine("OpenComDevice:" + status);
frontPos = new PointF(-1F, -1f); }
lastpointx[0] = -1; catch (Exception ex)
lastpointy[0] = -1; {
lastpointx[1] = -1; Log.Error(ex.Message);
lastpointy[1] = -1;
lastpointx[2] = -1;
lastpointy[2] = -1;
xypointcount = 0;
} }
catch (Exception ex) { Log.Info(ex.Message); }
finally { } finally { }
} }
@ -60,29 +36,29 @@ namespace DevicesService.Devices
{ {
try try
{ {
Console.WriteLine(number); Console.WriteLine(number);
//1 签字确定按钮 2签字取消按钮 3 签字重签按钮(清空界面) //1 签字确定按钮 2签字取消按钮 3 签字重签按钮(清空界面)
if (number == 1) if (number == 1)
{ {
int ret = FiveInchDll.ComSignOK(); int ret = FiveInchDll.ComSignOK();
Console.WriteLine("ComSignOK:" + ret); Console.WriteLine("ComSignOK:" + ret);
FiveInchDll.ComSetBackGroundAdv(); FiveInchDll.ComSetBackGroundAdv();
Task.Run(() =>
{
ScriptCallbackObject script = new ScriptCallbackObject();
string str = script.GetSignData("", "'");
str = "@" + str;
TcpServer.SendImages(str);
});
} }
else if (number == 3) else if (number == 3)
{ {
string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg"; string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg";
int ret = FiveInchDll.ComSetSignBackgroundImage(UIFile); int ret = FiveInchDll.ComSetSignBackgroundImage(UIFile);
Console.WriteLine("ComSetSignBackgroundImage:" + ret); Console.WriteLine("ComSetSignBackgroundImage:" + ret);
} }
else else
{ {
lastpointx[0] = -1;
lastpointy[0] = -1;
lastpointx[1] = -1;
lastpointy[1] = -1;
lastpointx[2] = -1;
lastpointy[2] = -1;
FiveInchDll.ComSetBackGroundAdv(); FiveInchDll.ComSetBackGroundAdv();
} }
} }
@ -94,163 +70,65 @@ namespace DevicesService.Devices
public static void GetTouchPoint(TOUCH_INFO[] info1) public static void GetTouchPoint(TOUCH_INFO[] info1)
{ {
return; return;
int x = 0, y = 0; }
int pressurevl;
int dx = 0, dy = 0;
for (int k = 0; k < 80; k++) //打开签字版
public static int OpenComDevice()
{
try
{ {
if (status == -1)
x = info1[k].X;
y = info1[k].Y;
//落笔
if (info1[k].Pressure > 0)
{ {
if (info1[k].Pressure > 0 && info1[k].Pressure < 500) status = FiveInchDll.OpenComDevice(DevGetTouchNumber);
{ Console.WriteLine("OpenComDevice:" + status);
pressurevl = 1; if (status == 0)
pen.Width = 1;
}
else if (info1[k].Pressure >= 500 && info1[k].Pressure < 1000)
{ {
pressurevl = 2; //关闭报点
pen.Width = 2; int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint);
} if (true)
else if (info1[k].Pressure >= 1000 && info1[k].Pressure < 1500) {
{ string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\adv_ui.jpg";
pressurevl = 3; int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile);
pen.Width = 3; Console.WriteLine("ComSendAdvantageImage:" + ret1);
} FiveInchDll.ComSetBackGroundAdv();
else if (info1[k].Pressure >= 1500 && info1[k].Pressure < 2048) }
{
pressurevl = 4; if (true)
pen.Width = 4; {
} string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg";
else int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile);
{ Console.WriteLine("ComSetSignBackgroundImage:" + ret1);
pressurevl = 0; }
pen.Width = 1;
} }
} }
else else
{ {
//抬笔 if (status == 0)
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) //关闭报点
int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint);
if (true)
{ {
//float dx = Math.Abs(lastpointx[2] - beginPos.X); string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\adv_ui.jpg";
//float dy = Math.Abs(endPos.Y - beginPos.Y); int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile);
Console.WriteLine("ComSendAdvantageImage:" + ret1);
dx = Math.Abs(lastpointx[2] - lastpointx[1]); FiveInchDll.ComSetBackGroundAdv();
dy = Math.Abs(lastpointy[2] - lastpointy[1]); }
if ((dx != 0) && (dy != 0))
{
if (lastpointy[1] != -1 && lastpointy[2] != -1) //y轴相同的点不画,直接跳过 if (true)
{
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) //不为空在赋值,防止丢弃点时赋空值 string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg";
{ int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile);
lastpointx[0] = lastpointx[1]; Console.WriteLine("ComSetSignBackgroundImage:" + ret1);
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;
}
} }
} catch (Exception ex)
//打开签字版
public static int OpenComDevice()
{
try
{ {
status = FiveInchDll.OpenComDevice(GetTouchNumber); Log.Error(ex.Message);
Console.WriteLine("OpenComDevice:" + status);
if (status == 0)
{
//关闭报点
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);
}
}
} }
catch(Exception ex) { Log.Info(ex.Message); }
finally { } finally { }
return status; return status;
} }
@ -274,35 +152,6 @@ namespace DevicesService.Devices
finally { } finally { }
return ret; return ret;
} }
//保存签字版数据
public string ComSetPictureSavePath()
{
try
{
DateTime dateTime = DateTime.Now;
string time = DateTime.Now.ToString(
"yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
var dirpath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "Sign");
FileExt.MakeSureDirExist(dirpath);
var filepath = Path.Combine(dirpath, time);
string SignFile = dirpath + "\\" + time + ".png";
string sourcepaht = Environment.CurrentDirectory + "\\fiveInch.png";
int ret = FiveInchDll.ComSignOK();
if (ret == 0)
{
return SignFile;
}
else
{
return "";
}
}
catch (Exception ex)
{
return "";
}
}
} }
class FiveInchDll class FiveInchDll

Loading…
Cancel
Save