Browse Source

预约

master
胡超1 1 year ago
parent
commit
74ec7cec2f
  1. 4
      DevicesService/Commen/COMUtils.cs
  2. 74
      DevicesService/Commen/TcpServer.cs
  3. 224
      DevicesService/Devices/SignDll.cs
  4. 10
      DevicesService/DevicesService.csproj
  5. 1
      DevicesService/Program.cs

4
DevicesService/Commen/COMUtils.cs

@ -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);

74
DevicesService/Commen/TcpServer.cs

@ -33,8 +33,8 @@ namespace DevicesService.Commen
{ {
TcpListener listener = new TcpListener(IPAddress.Any, 1234); TcpListener listener = new TcpListener(IPAddress.Any, 1234);
listener.Start(); listener.Start();
Console.WriteLine("服务器已启动,等待客户端连接..."); Console.WriteLine("服务器已启动,等待客户端连接...");
Timer timer = new Timer(SendHelloMessage, null, TimeSpan.Zero, TimeSpan.FromSeconds(200)); Timer timer = new Timer(SendHelloMessage, null, TimeSpan.Zero, TimeSpan.FromSeconds(20));
while (true) while (true)
{ {
TcpClient client = listener.AcceptTcpClient(); TcpClient client = listener.AcceptTcpClient();
@ -44,10 +44,7 @@ namespace DevicesService.Commen
ThreadPool.QueueUserWorkItem(ReceiveMessage, client); ThreadPool.QueueUserWorkItem(ReceiveMessage, client);
} }
} }
catch (Exception ex) catch (Exception ex) { Console.WriteLine(ex.Message); }
{
Console.WriteLine(ex.Message);
}
finally { } finally { }
} }
@ -71,10 +68,7 @@ namespace DevicesService.Commen
stream.Write(data, 0, data.Length); stream.Write(data, 0, data.Length);
} }
} }
catch (Exception ex) catch (Exception ex) { Console.WriteLine(ex.Message); }
{
Console.WriteLine(ex.Message);
}
finally { } finally { }
} }
@ -162,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);
@ -209,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);
@ -338,30 +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);
//向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); base64 = Util.str2Base64(resultback);
//向com对方发送数据 //向com对方发送数据
SendDataWithHeader(client, base64); SendDataWithHeader(client, base64);
@ -457,33 +428,6 @@ 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 { }
}
} }
} }

224
DevicesService/Devices/SignDll.cs

@ -25,10 +25,35 @@ 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;
public SignDll() { private static Bitmap bitmap = new Bitmap(594, 392);
status = FiveInchDll.OpenComDevice(DevGetTouchNumber); public SignDll()
Console.WriteLine("OpenComDevice:" + status); {
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) { Log.Info(ex.Message); }
finally { }
} }
public static void DevGetTouchNumber(int number) public static void DevGetTouchNumber(int number)
@ -42,12 +67,6 @@ namespace DevicesService.Devices
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)
{ {
@ -57,6 +76,13 @@ namespace DevicesService.Devices
} }
else else
{ {
lastpointx[0] = -1;
lastpointy[0] = -1;
lastpointx[1] = -1;
lastpointy[1] = -1;
lastpointx[2] = -1;
lastpointy[2] = -1;
FiveInchDll.ComSetBackGroundAdv(); FiveInchDll.ComSetBackGroundAdv();
} }
} }
@ -68,63 +94,163 @@ 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)
{
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); lastpointx[2] = x;
Console.WriteLine("OpenComDevice:" + status); lastpointy[2] = y;
//清空界面
// GetTouchNumber(2);
if (status == 0) if (lastpointx[2] != -1)
{ {
//关闭报点 if (lastpointx[1] != -1 && lastpointx[0] != -1)
int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint);
if (true)
{ {
string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\adv_ui.jpg"; //float dx = Math.Abs(lastpointx[2] - beginPos.X);
int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile); //float dy = Math.Abs(endPos.Y - beginPos.Y);
Console.WriteLine("ComSendAdvantageImage:" + ret1);
FiveInchDll.ComSetBackGroundAdv(); dx = Math.Abs(lastpointx[2] - lastpointx[1]);
} dy = Math.Abs(lastpointy[2] - lastpointy[1]);
if ((dx != 0) && (dy != 0))
{
if (true) 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() + "\\sign_ui.jpg"; if (lastpointx[1] != -1) //不为空在赋值,防止丢弃点时赋空值
int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile); {
Console.WriteLine("ComSetSignBackgroundImage:" + ret1); lastpointx[0] = lastpointx[1];
lastpointy[0] = lastpointy[1];
}
lastpointx[1] = lastpointx[2];
lastpointy[1] = lastpointy[2];
} }
} }
} }
else else
{ {
if (status == 0) 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)
{ {
//关闭报点 string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\adv_ui.jpg";
int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint); int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile);
if (true) Console.WriteLine("ComSendAdvantageImage:" + ret1);
{ FiveInchDll.ComSetBackGroundAdv();
string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\adv_ui.jpg"; }
int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile);
Console.WriteLine("ComSendAdvantageImage:" + ret1);
FiveInchDll.ComSetBackGroundAdv();
}
if (true) if (true)
{ {
string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg"; string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg";
int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile); int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile);
Console.WriteLine("ComSetSignBackgroundImage:" + ret1); Console.WriteLine("ComSetSignBackgroundImage:" + ret1);
}
} }
} }
} }
catch { } catch(Exception ex) { Log.Info(ex.Message); }
finally { } finally { }
return status; return status;
} }

10
DevicesService/DevicesService.csproj

@ -14,17 +14,23 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants /> <DefineConstants />
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<Optimize>False</Optimize>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants /> <DefineConstants />
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<Optimize>False</Optimize>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<Optimize>True</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="Commen\COMUtils.cs~RF189d1fe.TMP" /> <None Remove="Commen\COMUtils.cs~RF189d1fe.TMP" />

1
DevicesService/Program.cs

@ -34,7 +34,6 @@ namespace DevicesService
FileProvider = new PhysicalFileProvider(pathToFiles), FileProvider = new PhysicalFileProvider(pathToFiles),
RequestPath = "/wwwroot" RequestPath = "/wwwroot"
}); });
// 处理文件未找到的情况 // 处理文件未找到的情况
app.Use((context, next) => app.Use((context, next) =>
{ {

Loading…
Cancel
Save