tijian_tieying/web/dccdc.Selfhelp/frm_main_xg.cs
2025-02-20 12:14:39 +08:00

507 lines
23 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using LabLed.Components;
using log4net;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Apache.NMS;
using System.Net;
using System.Threading;
using System.Speech.Synthesis;
using System.Reflection;
using System.IO;
using System.Collections.Specialized;
namespace dccdc.Selfhelp
{
public partial class frm_main_xg : Form
{
ICollection<string> setting = extend.Config.AppSettings.Settings.AllKeys as ICollection<string>;
public frm_main_xg()
{
InitializeComponent();
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(DateTime.Now.ToString() + "初始化窗口成功");
}
private void frm_main_ym_Load(object sender, EventArgs e)
{
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(DateTime.Now.ToString() + "执行LOAd");
if (extend.Config.AppSettings.Settings["min"].Value == "true")
{
this.WindowState = FormWindowState.Minimized;
}
else
{
TopMost = true;
TopLevel = true;
btn_pdjh.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
btn_pdjh.FlatAppearance.BorderSize = 0;
btn_pdjh.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent;
btn_pdjh.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent;
btn_pdjh.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
//btn_pdjh.FlatAppearance.BorderSize = 0;
//btn_zzjf.FlatAppearance.BorderSize = 0;
btn_zzjf.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
btn_zzjf.FlatAppearance.BorderSize = 0;
btn_zzjf.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent;
btn_zzjf.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent;
btn_zzjf.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
timer1.Enabled = true;
timer2.Enabled = true;
}
}
frm_yypd pd = new Selfhelp.frm_yypd();
private void btn_pdjh_Click(object sender, EventArgs e)
{
//
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(DateTime.Now.ToString() + "开始查询有无身份证!");
var dn = DateTime.Now;
timer1.Enabled = false;
Status ss = new Selfhelp.Status("正在查询您的预约信息信息请稍后……", false);
ss.Owner = this;
ss.TopLevel = true;
IDCardInfo info = new IDCardInfo();
string errmsg = "";
int iPort = 1001;
int iIfOpen = 1;
byte[] byCHMsg = new byte[256 + 1]; //个人基本信息
uint uiCHMsgSize = 0; //个人基本信息字节数
byte[] byPHMsg = new byte[1024 + 1]; //照片信息
uint uiPHMsgSize = 0; //照片信息字节数
byte[] byFPMsg = new byte[1024 + 1]; //指纹信息
uint uiFPMsgSize = 0; //指纹信息字节数
int iIsSaveToBmp = 0;
byte[] byBgrBuffer = new byte[38556]; //解码后图片BGR编码值
byte[] byRgbBuffer = new byte[38808]; //解码后图片RGB编码值
byte[] byBmpBuffer = new byte[38862]; //解码后图片RGB编码值
// uint uiDevBaud = 0;
//uint uiCurBaud = 0;
StringBuilder strSAMID = new StringBuilder(64 + 1);
//获得设备SAM模块ID。
//PS SAM模块ID为二代证设备唯一标志ID
//PS2此函通常用来数来区分设备或判断设备是否连接正常若只读卡信息的话无需添加此函数。
int iResult = extend.SDT_GetSAMIDToStr(1001, strSAMID, 1);
if (0x90 != iResult)
{
errmsg = String.Format("获取SAMID号失败错误代码{0:D}", iResult);
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(DateTime.Now.ToString() + errmsg);
//MessageBox.Show(strMsg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
Status sss = new Status(errmsg);
sss.ShowDialog();
return;
}
byte[] byManaID = new byte[8];
//寻卡
iResult = extend.SDT_StartFindIDCard(iPort, byManaID, iIfOpen);
if (0x9F != iResult)
{
errmsg = String.Format("寻卡失败,错误代码:{0:D}", iResult);
//Status s = new Status(errmsg);
//s.ShowDialog();
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(DateTime.Now.ToString() + "没有找到身份证!" + errmsg);
Status sss = new Status("没有找到身份证!");
sss.ShowDialog();
return;
}
//选卡
byManaID.Initialize();
iResult = extend.SDT_SelectIDCard(iPort, byManaID, iIfOpen);
if (0x90 != iResult)
{
errmsg = String.Format("选卡失败,错误代码:{0:D}", iResult);
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(DateTime.Now.ToString() + errmsg);
//MessageBox.Show(strMsg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
Status sss = new Status(errmsg);
sss.ShowDialog();
return;
}
//读取身份证个人基本信息、照片信息和指纹信息;
//PS指纹信息需要专门的指纹比对设备这里只获取加密的原始数据。
iResult = extend.SDT_ReadBaseFPMsg(iPort, byCHMsg, ref uiCHMsgSize, byPHMsg, ref uiPHMsgSize, byFPMsg, ref uiFPMsgSize, iIfOpen);
if (0x21 == iResult)//0501模块(一种老模块)无法读取指纹信息,会返回0x21错误这里进行兼容处理这种模块早就不用了实际可以不做处理。
{
iResult = extend.SDT_ReadBaseMsg(iPort, byCHMsg, ref uiCHMsgSize, byPHMsg, ref uiPHMsgSize, iIfOpen);//采用只读卡信息和照片,不读指纹信息的接口
}
if (0x90 != iResult)
{
errmsg = String.Format("读取身份信息失败,错误代码:{0:D}", iResult);
log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).Info(DateTime.Now.ToString() + errmsg);
Status sss = new Status(errmsg);
sss.ShowDialog();
return;
}
//解码照片数据获得BGR格式数据
//iIsSaveToBmp = 1; //调用解码库unpack函数后由接口自动生成名为zp.bmp的图片文件该BMP文件可直接打开不用B、R转换
//截取个人信息数据。信息采用UNICODE存储具体格式参可见《二代证机读信息说明.doc》
byte[] byName = new byte[30];
byte[] bySex = new byte[2];
byte[] byRace = new byte[4];
byte[] byBirth = new byte[16];
byte[] byAddress = new byte[70];
byte[] byID = new byte[36];
byte[] byCompany = new byte[30];
byte[] byBeginDate = new byte[16];
byte[] byEndDate = new byte[16];
Array.Copy(byCHMsg, 0, byName, 0, 30);
Array.Copy(byCHMsg, 30, bySex, 0, 2);
Array.Copy(byCHMsg, 32, byRace, 0, 4);
Array.Copy(byCHMsg, 36, byBirth, 0, 16);
Array.Copy(byCHMsg, 52, byAddress, 0, 70);
Array.Copy(byCHMsg, 122, byID, 0, 36);
Array.Copy(byCHMsg, 158, byCompany, 0, 30);
Array.Copy(byCHMsg, 188, byBeginDate, 0, 16);
Array.Copy(byCHMsg, 204, byEndDate, 0, 16);
//显示结果
/*
strIDBase = "读卡成功.\r\n\r\n";
strIDBase += "姓名: " + Encoding.Unicode.GetString(byName).Trim() + "\r\n\r\n";
strIDBase += "性别: " + Encoding.Unicode.GetString(bySex).Trim() + "\r\n\r\n";
strIDBase += "民族: " + Encoding.Unicode.GetString(byRace).Trim() + "\r\n\r\n";
strIDBase += "出生日期: " + Encoding.Unicode.GetString(byBirth).Trim() + "\r\n\r\n";
strIDBase += "居住地址: " + Encoding.Unicode.GetString(byAddress).Trim() + "\r\n\r\n";
strIDBase += "公民身份证号: " + Encoding.Unicode.GetString(byID).Trim() + "\r\n\r\n";
strIDBase += "签发机关: " + Encoding.Unicode.GetString(byCompany).Trim() + "\r\n\r\n";
strIDBase += "有效起始日期: " + Encoding.Unicode.GetString(byBeginDate).Trim() + "\r\n\r\n";
strIDBase += "有效截止日期: " + Encoding.Unicode.GetString(byEndDate).Trim() + "\r\n\r\n";
*/
info.Name = Encoding.Unicode.GetString(byName).Trim().Replace("\0", "");
//info.Nation = Encoding.Default.GetString(personInfo.nation).Trim().Replace("\0", "");
info.IDCardNo = Encoding.Unicode.GetString(byID).Trim().Replace("\0", "");
//info.GrantDept = CardMsg.GrantDept;
string csrq = Encoding.Unicode.GetString(byBirth).Trim().Replace("\0", "");
info.Born = csrq.Substring(0, 4) + "-" + csrq.Substring(4, 2) + "-" + csrq.Substring(6, 2).Replace("\0", "");
info.Address = Encoding.Unicode.GetString(byAddress).Trim().Replace("\0", "");
//info.UserLifeEnd = CardMsg.UserLifeEnd;
//info.UserLifeBegin = CardMsg.UserLifeBegin;
info.Sex = Encoding.Unicode.GetString(bySex).Trim().Replace("\0", "");
//info.reserved = CardMsg.reserved;
//info.PhotoFileName = zpf;
//info.FPInfo = zpf;
//info.FPInfo = info.FPInfo.Replace("\0", "");
WebClient wc = new WebClient();
wc.Encoding = System.Text.Encoding.UTF8;
string jsonData = wc.DownloadString(extend.URL + "zzj/getxgyyxx?id=" + info.IDCardNo);
OperationResult or = Newtonsoft.Json.JsonConvert.DeserializeObject<OperationResult>(jsonData);
if (or.State == 0)
{
Status sss = new Status(or.Message);
sss.ShowDialog();
return;
}
dccdc.Models.xg_yyxx yy = Newtonsoft.Json.JsonConvert.DeserializeObject<dccdc.Models.xg_yyxx>(or.Tag);
if (yy.djzt == 1)
{
Status sss = new Status("今日已登记不能重复登记!");
sss.ShowDialog();
return;
}
NameValueCollection nvc = new NameValueCollection();
//sfzh: $("#f_sfzh").val(), xm: $("#f_xm").val(), sjh: $("#f_sjh").val(), cks: scks
nvc.Add("sfzh", yy.sfzh);
nvc.Add("xm", yy.xm);
nvc.Add("sjh", yy.sjh);
string cks = "";
foreach (var mx in yy.yymx)
{
cks += mx.xmid + ",";
}
nvc.Add("cks", cks);
byte[] result = wc.UploadValues(extend.URL + "xg/xgdj", nvc);
var dj = Newtonsoft.Json.JsonConvert.DeserializeObject<djxx>(System.Text.Encoding.UTF8.GetString(result));
try
{
string jsonData1 = wc.DownloadString(extend.URL + "xg/xgtm?id=" + dj.id);
DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(jsonData1);
FastReport.Report re = new FastReport.Report();
re.Load(Application.StartupPath+"\\xgtm.frx");
re.RegisterData(dt, "bg");
string _tm_dyj = System.Configuration.ConfigurationManager.AppSettings["tmprint"];
//re.PrintSettings.ShowDialog = false;
try
{
if (!string.IsNullOrEmpty(_tm_dyj))
re.PrintSettings.Printer = _tm_dyj;
re.PrintSettings.ShowDialog = false;
re.Print();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Status s = new Status("登记成功!");
s.ShowDialog();
}
LedCommon LEDSender = new LedCommon();
private const int WM_LED_NOTIFY = 1025;
private int dev = -1;
private int dev1 = -1;
private int dev2 = -1;
private int dev3 = -1;
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
LedCommon.DEVICEPARAM param = new LedCommon.DEVICEPARAM();
GetDeviceParam(ref param);
dev = LEDSender.LED_Open(ref param, LedCommon.NOTIFY_EVENT, (int)Handle, WM_LED_NOTIFY);
//dev = LEDSender.LED_Open(ref param, LedCommon.NOTIFY_NONE, (int)Handle, WM_LED_NOTIFY);
if (dev == -1)
{
//MessageBox.Show( "打开通讯设备失败");
}
else
{
//MessageBox.Show("打开通讯设备成功");
}
}
private void GetDeviceParam(ref LedCommon.DEVICEPARAM param)
{
param.devType = (uint)LedCommon.eDevType.DEV_UDP;
param.ComPort = (uint)Convert.ToInt16(1);
param.Speed = (uint)LedCommon.eBaudRate.SBR_57600;
param.locPort = 9999;
param.rmtPort = 6666;
}
private void OnLEDNotify(UInt32 msg, UInt32 wParam, UInt32 lParam)
{
ILog loger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().GetType());
LedCommon.NotifyMessage notify = new LedCommon.NotifyMessage();
LEDSender.LED_GetDeviceNotifyMessage(dev, ref notify);
//LEDSender.LED_GetNotifyMessage(ref notify);
switch (notify.Message)
{
case (int)LedCommon.eResponseMessage.LM_TX_COMPLETE:
loger.Info("发送完成");
//MessageBox.Show( "发送完成");
break;
case (int)LedCommon.eResponseMessage.LM_TIMEOUT:
loger.Info("命令执行超时");
//MessageBox.Show("命令执行超时");
break;
case (int)LedCommon.eResponseMessage.LM_RESPOND:
switch (notify.Command)
{
case LedCommon.PKC_GET_POWER:
if (notify.Status == 1)
loger.Info("读取电源状态完成,当前电源状态为打开状态");
//MessageBox.Show( Text = "读取电源状态完成,当前电源状态为打开状态");
else
loger.Info("读取电源状态完成,当前电源状态为打开状态");
//Text = "读取电源状态完成,当前电源状态为关闭状态";
break;
case LedCommon.PKC_SET_POWER:
loger.Info("读取电源状态完成,当前电源状态为打开状态");
//Text = "设置电源完成";
break;
case LedCommon.PKC_GET_BRIGHT:
loger.Info("当前亮度为" + notify.Status);
//Text = "当前亮度为" + notify.Status;
break;
case LedCommon.PKC_GET_LEAF:
case LedCommon.PKC_SET_LEAF:
loger.Info("当前页面为" + notify.Status);
// Text = "当前页面为" + notify.Status;
break;
case LedCommon.PKC_SET_BRIGHT:
loger.Info("设置亮度完成");
//Text = "设置亮度完成";
break;
case LedCommon.PKC_ADJUST_TIME:
loger.Info("校正控制卡时间完成");
//Text = "校正控制卡时间完成";
break;
case LedCommon.PKC_SET_AUTO_POWER:
loger.Info("设置自动开关屏时间完成");
// Text = "设置自动开关屏时间完成";
break;
}
break;
}
}
protected override void DefWndProc(ref System.Windows.Forms.Message m)
{
switch (m.Msg)
{
case WM_LED_NOTIFY:
OnLEDNotify((UInt32)m.Msg, (UInt32)m.WParam, (UInt32)m.LParam);
break;
default:
base.DefWndProc(ref m);//调用基类函数处理非自定义消息。
break;
}
}
private void timer2_Tick(object sender, EventArgs e)
{
timer2.Enabled = false;
sendtoLED(null);
}
private void btn_zzjf_Click(object sender, EventArgs e)
{
frm_sjdj zzjf = new frm_sjdj();
zzjf.Location = new Point(240,380);
zzjf.TopMost = true;
zzjf.TopLevel = true;
zzjf.ShowDialog();
}
private void sendtoLED(pdxx pd)
{
LedCommon.RECT r;
if (dev >= 0 && LEDSender.LED_GetDeviceStatus(dev) == 0)
{
//LEDSender.MakeRootEx(LedCommon.eRootType.ROOT_PLAY, LedCommon.eScreenType.SCREEN_COLOR, 5);
//LEDSender.AddLeaf(86400000);
//r.left = 40;
//r.top = 1;
//r.right = 50;
//r.bottom = 16;
//LEDSender.AddText("德城区疾病预防控制中心数字化门诊", ref r, 0, 1, 1, "宋体", 16, 255, 0);
//LEDSender.LED_SendToScreen(dev, 0, "192.168.18.99", 6666);
//Text = "正在发送节目...";
LEDSender.MakeRootEx(LedCommon.eRootType.ROOT_PLAY, LedCommon.eScreenType.SCREEN_COLOR, 5);
LEDSender.AddLeaf(86400000);
r.left = 64;
r.top = 0;
r.right = 448;
r.bottom = 32;
LEDSender.AddText("德城区疾控中心数字化门诊", ref r, 1, 1, 1, "宋体", 20, 255, 0);
r.left = 0;
r.top = 32;
r.right = 448;
r.bottom = 48;
LEDSender.AddText("-------------------------------------------------------------------------------------------------", ref r, 1, 1, 1, "宋体", 8, 255, 0);
r.left = 0;
r.top = 224;
r.right = 448;
r.bottom = 240;
LEDSender.AddText("-------------------------------------------------------------------------------------------------", ref r, 1, 1, 1, "宋体", 8, 255, 0);
r.left = 144;
r.top = 208;
r.right = 448;
r.bottom = 224;
LEDSender.AddText("请小朋友接种完成后,留观半小时。", ref r, 1, 1, 1, "宋体", 10, 255, 0);
r.left = 144;
r.top = 240;
r.right = 234;
r.bottom = 256;
LEDSender.AddDateTime(ref r, 1, "宋体", 10, 255, LedCommon.eTimeFormat.DF_W, 0);
r.left = 224;
r.top = 240;
r.right = 320;
r.bottom = 256;
LEDSender.AddDateTime(ref r, 1, "宋体", 10, 255, LedCommon.eTimeFormat.DF_HNS, 0);
r.left = 320;
r.top = 240;
r.right = 448;
r.bottom = 256;
LEDSender.AddText("联系电话 2267131", ref r, 1, 1, 1, "宋体", 10, 255, 0);
//LEDSender.LED_SendToScreen(dev, (byte)Convert.ToInt16(eAddress.Text), eRemoteHost.Text, 6666);
//LEDSender.AddDateTime(ref r, 1, "宋体", 12, 0xff00, LedCommon.eTimeFormat.DF_HNS, 0);
//r.left = 32;
//r.top = 64;
//r.right = 448;
//r.bottom = 128;
//LEDSender.AddText("大家好,欢迎大家!", ref r, 1, 1, 1, "宋体", 28, 255, 0);
//LEDSender.LED_SendToScreen(dev, 0, "192.168.18.99", 6666);
if (pd != null)
{
//LEDSender.AddLeaf(5000);
r.left = 16;
r.top = 48;
r.right = 448;
r.bottom = 192;
StringBuilder sb = new StringBuilder();
int i = 0;
i = pd.jhs.Count - 8;
if (i < 0)
i = 0;
for (; i < pd.jhs.Count; i++)
{
sb.Append("请" + pd.jhs[i].hm.ToString("D4") + "号小朋友的家长到" + pd.jhs[i].jhckmc.Replace(" ", "") + "登记");
if (i < pd.jhs.Count - 1)
{
sb.Append("\r\n");
}
}
LEDSender.AddTextEx(sb.ToString(), ref r, 1, 1, 1, "宋体", 12, 255, 0, 0);
}
else
{
//LEDSender.AddLeaf(5000);
//r.left = 16;
//r.top = 48;
//r.right = 224;
//r.bottom = 144;
//LEDSender.AddTextEx("于兴海请到1号窗口登记\r\n于兴海请到2号窗口登记\r\n于兴海请到3号窗口登记", ref r, 1, 1, 1, "宋体", 10, 255, 0, 0);
}
LEDSender.LED_SendToScreen(dev, 0, "192.168.18.99", 6666);
//LEDSender.UserCanvas_Draw_Line(0, 33, 447, 33,10,255);
}
else
{
//MessageBox.Show("失败!");
}
}
}
public class djxx
{
public int State { get; set; }
public string Message { get; set; }
public int id { get; set; }
}
}