/// <summary> /// 寻卡号 /// </summary> /// <param name="com">通讯端口</param> /// <returns>返回卡号</returns> public string ReaderCardNum(string com) { CHDOperate op = new CHDOperate(); op.CHDLogMsg += Op_CHDLogMsg; if (op.ConnectionDevice(com, DeviceType.CHDCardReader, portOrBaud: 9600, isTcp: false)) { string no = ""; if (null != op && !string.IsNullOrWhiteSpace(com)) { no = op.GetCardNum(); } op.DisConnectionDevice(); return(no); } TextMsg?.Invoke(string.Format("门禁主机 {0} 获取卡号失败···", com, DateTime.Now)); return(""); }
private void LoginDevice(object obj) { CHDDoorUseInfo item = obj as CHDDoorUseInfo; CHDOperate op = new CHDOperate(); op.CHDLogMsg += Op_CHDLogMsg; op.CHDEventInfo += Op_CHDEventInfo; serverIsStart = true; bool b = false; for (int i = 0; i < 5; i++) { try { if (!serverIsStart) { return; } b = op.ConnectionDevice(item.DeviceIp, DeviceType.CHD806D2CP, portOrBaud: (int)item.DevicePoint, szSysPwd: item.UserName, szKeyPwd: item.UserPwd); if (b) { opera.Add(op); (new Thread(new ParameterizedThreadStart(LinkOn)) { IsBackground = true }).Start(op); break; } else { Thread.Sleep(20); } } catch (Exception) { } } }