public FpReturn ReadMyKad(string reader, out List <string> strList, out byte[] fp1, out byte[] fp2, out Image img) { FpReturn r = FpReturn.ErrorUnknown; strList = new List <string>(); fp1 = null; fp2 = null; img = null; try { r = ConnectSmartCard(reader); if (r != FpReturn.Success) { throw new Exception(); } r = ReadJPN(out strList, out fp1, out fp2, out img); if (r != FpReturn.Success) { throw new Exception(); } } catch { } finally { DisconnectSmartCard(); } return(r); }
public Data.ProfileInfo ReadFromMyKad() { ProfileInfo pf = null; Image img = null; try { List <string> sList = new List <string>(); byte[] fp1 = null; byte[] fp2 = null; RefreshReaderList(); FpReturn state = FpReturn.ErrorUnknown; //Read mykad using previous working reader state = ReadMyKad(_previousWorkingReader, out sList, out fp1, out fp2, out img); //If failed, try all the readers if (state != FpReturn.Success) { foreach (var rdr in _rdrList) { state = ReadMyKad(rdr, out sList, out fp1, out fp2, out img); if (state == FpReturn.Success) { _previousWorkingReader = rdr; break; } } } if (state != FpReturn.Success) { throw new Exception("Failed to read MyKad"); } pf = new ProfileInfo(); //_photoImage = img; foreach (string s in sList) { if (s.StartsWith("JPN_IDNum")) { string[] ids = s.Split('='); pf.IcNo = ids[1]; } else if (s.StartsWith("JPN_GMPCName")) { string[] ids = s.Split('='); pf.FullName = ids[1]; } else if (s.StartsWith("JPN_Citizenship")) { string[] ids = s.Split('='); pf.Citizenship = ids[1]; } else if (s.StartsWith("JPN_Gender")) { string[] ids = s.Split('='); pf.Gender = ids[1]; } else if (s.StartsWith("JPN_Address1")) { string[] ids = s.Split('='); pf.Address1 = ids[1]; } else if (s.StartsWith("JPN_Address2")) { string[] ids = s.Split('='); pf.Address2 = ids[1]; } else if (s.StartsWith("JPN_Address3")) { string[] ids = s.Split('='); pf.Address3 = ids[1]; } else if (s.StartsWith("JPN_Postcode")) { string[] ids = s.Split('='); pf.Postcode = ids[1]; } else if (s.StartsWith("JPN_City")) { string[] ids = s.Split('='); pf.City = ids[1]; } else if (s.StartsWith("JPN_State")) { string[] ids = s.Split('='); pf.State = ids[1]; } } } catch (Exception ex) { //MessageBox.Show(ex.Message); } //ProfileInfo = new ProfileInfo //{ // FullName = "Fakhrul Azran Bin Nawi", // IcNo = "99999999-99-9999", // //DateOfBirth = new DateTime(1975, 01, 01), // Gender = "Male" //}; return(pf); }