public override bool CloseShsCard(out int p_ret) { byte abuf = 0x42; int num2 = 0; int num3 = 0x226b; int num4 = 0x2702; bool flag = false; this.StopRead(); UCommand1 command = (UCommand1)DLLWrapper.GetFunctionAddress(this.hModule, "UCommand1", typeof(UCommand1)); if ((p_ret = command(ref abuf, ref num2, ref num3, ref num4)) == 0xf2db) { flag = true; } this.FreeIdCard(); this.hModule = -1; return(flag); }
public bool InitShsIdCard(out int p_ret) { byte abuf = 0x41; int num2 = 0; int num3 = 0x226b; int num4 = 0x2702; bool flag = false; this.hModule = DLLWrapper.LoadLibrary("RdCard.dll"); if (this.hModule == 0) { p_ret = -99; base.IsOk = false; return(false); } try { UCommand1 command = (UCommand1)DLLWrapper.GetFunctionAddress(this.hModule, "UCommand1", typeof(UCommand1)); if ((p_ret = command(ref abuf, ref num2, ref num3, ref num4)) != 0xf2db) { return(flag); } this.timerReadCard.Elapsed += new ElapsedEventHandler(this.timerReadCard_Elapsed); byte[] sn = new byte[0x40]; if (((GetSAMIDToStr)DLLWrapper.GetFunctionAddress(this.hModule, "GetSAMIDToStr", typeof(GetSAMIDToStr)))(sn) == 1) { base.RdCardSN = Encoding.Default.GetString(sn).Trim(); } flag = true; } catch (Exception exception) { p_ret = -99; flag = false; ErrorLog.WriterLog("身份证初始化错误:" + exception.Message); LogHelper.LogError(exception); } return(flag); }
public void shsIdCard() { byte abuf = 0x43; int num2 = 0; int num3 = 0x226b; int num4 = 0x2702; ReadIdentifyEventArgs e = new ReadIdentifyEventArgs(); UCommand1 command = (UCommand1)DLLWrapper.GetFunctionAddress(this.hModule, "UCommand1", typeof(UCommand1)); int num5 = command(ref abuf, ref num2, ref num3, ref num4); if (num5 == 0xf2db) { new RecordsBaseInfoModel(); byte num6 = 0x44; int num7 = command(ref num6, ref num2, ref num3, ref num4); if (num7 == 0xf2db) { string str9; byte[] buffer = new byte[0x24]; ((GetIDNum)DLLWrapper.GetFunctionAddress(this.hModule, "GetIDNum", typeof(GetIDNum)))(buffer); string str = Encoding.Default.GetString(buffer).Trim(new char[1]).Trim(); DateTime today = DateTime.Today; string str2 = ""; byte[] namebyte = new byte[30]; ((GetName)DLLWrapper.GetFunctionAddress(this.hModule, "GetName", typeof(GetName)))(namebyte); string str3 = Encoding.Default.GetString(namebyte).Trim(new char[1]).Trim().TrimEnd(new char[1]); byte[] sexbyte = new byte[2]; ((GetSex)DLLWrapper.GetFunctionAddress(this.hModule, "GetSexGB", typeof(GetSex)))(sexbyte); string str4 = Encoding.Default.GetString(sexbyte).Trim(new char[1]).Trim(); string str5 = !(str4 == "男") ? (!(str4 == "女") ? "0" : "2") : "1"; byte[] addbyte = new byte[70]; ((GetAddr)DLLWrapper.GetFunctionAddress(this.hModule, "GetAddr", typeof(GetAddr)))(addbyte); string str6 = Encoding.Default.GetString(addbyte).Trim(new char[1]).Trim().TrimEnd(new char[1]); byte[] birthbyte = new byte[0x10]; ((GetBirth)DLLWrapper.GetFunctionAddress(this.hModule, "GetBirth", typeof(GetBirth)))(birthbyte); string str7 = Encoding.GetEncoding("gb2312").GetString(birthbyte).Trim(new char[1]).Trim(); bool flag = true; if (!DateTime.TryParse(str7.Trim().Insert(4, "-").Insert(7, "-").Trim(), out today)) { flag = false; } byte[] folkbyte = new byte[0x10]; ((GetFolk)DLLWrapper.GetFunctionAddress(this.hModule, "GetFolkGB", typeof(GetFolk)))(folkbyte); string str8 = Encoding.Default.GetString(folkbyte).ToString().Trim(new char[1]).Trim().TrimEnd(new char[1]); if (str8 == "汉族") { str9 = "1"; } else { str2 = str8; str9 = "2"; } byte[] newAddr = new byte[70]; ((GetNewAddr)DLLWrapper.GetFunctionAddress(this.hModule, "GetNewAddr", typeof(GetNewAddr)))(newAddr); Encoding.Default.GetString(newAddr).Trim(new char[1]).Trim(); e.Name = str3.Trim(); e.Idcard = str; e.Addr = str6.Trim(); e.Birthday = today; e.Nation = str9.Trim(); e.Sex = str5; e.Minority = str2.Trim(); e.ReadResult = 0; if (string.IsNullOrEmpty(e.Idcard)) { e.ErrorInfo = "读取身份证号码为空!"; e.ReadResult = -4; } if (string.IsNullOrEmpty(e.Name)) { ReadIdentifyEventArgs args2 = e; string str10 = args2.ErrorInfo + "读取身份证姓名为空!"; args2.ErrorInfo = str10; e.ReadResult = -4; } if (!flag) { ReadIdentifyEventArgs args3 = e; string str11 = args3.ErrorInfo + "获取身份证生日失败!"; args3.ErrorInfo = str11; e.ReadResult = -4; } if (string.IsNullOrEmpty(e.Nation)) { ReadIdentifyEventArgs args4 = e; string str12 = args4.ErrorInfo + "获取身份证民族失败!"; args4.ErrorInfo = str12; e.ReadResult = -4; } if (string.IsNullOrEmpty(e.Sex)) { ReadIdentifyEventArgs args5 = e; string str13 = args5.ErrorInfo + "获取身份证性别失败!"; args5.ErrorInfo = str13; e.ReadResult = -4; } if (e.ReadResult == 0) { this.StopRead(); } } else { this.timerReadCard.Enabled = false; e.ReadResult = -2; if (this.readCount > 50) { e.ReadResult = -1; e.ErrorInfo = "身份证信息读取错误,关闭程序重新读取:" + num7; this.readCount = 0; } this.readCount++; this.timerReadCard.Enabled = true; } if (base.readCardEvent == null) { throw new Exception("readCardEvent 为NULL"); } base.readCardEvent(this, e); } else { e.ReadResult = -3; e.ErrorInfo = "卡验证失败:" + num5; } }