public MainForm() { using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) { key.SetValue("nKid Reader", "\"" + Application.ExecutablePath + "\""); } InitializeComponent(); frmNFCUpConfirm = new NFCCardIdUpload(); //Load camera availableVideoInputDevices = new List <DsDevice>(); getAvailableVideoInputDevices(); //Load reader //Magnetic stripe reader: VID_6352 PID_213A //Semnox NFC reader: VID_08FF PID_0009 //Default optText = 00000 //This is demo, load mrs: scan(ConfigurationManager.AppSettings["mrs_vid"], ConfigurationManager.AppSettings["mrs_pid"]); // Or semnox :) scan(ConfigurationManager.AppSettings["semnox_vid"], ConfigurationManager.AppSettings["semnox_pid"]); ReadCSVFile(); }
private void CardScanCompleteEventHandle(object sender, EventArgs e) { string cardNumber; CardListener listener = (CardListener)sender; if (e is CardReaderScannedEventArgs) { CardReaderScannedEventArgs checkScannedEvent = e as CardReaderScannedEventArgs; cardNumber = checkScannedEvent.Message; logger.Debug("Card number: " + cardNumber); // NFC if (listener.dInfo.deviceName.Contains("VID_08FF&PID_0009")) { nfcID = cardNumber.ToLower(); if (updateNFCIDToolStripMenuItem.Checked) { frmNFCUpConfirm.getNFCCode(nfcID); } else if (manualToolStripMenuItem.Checked) { bool foundMRS = false; foreach (CsvData data in cardList) { if (data.mrsId == magneticCardID) { data.nfcId = nfcID; foundMRS = true; break; } } if (!foundMRS) { cardList.Add(new CsvData(magneticCardID, nfcID)); } // Write to CSV using (CsvFileWriter writer = new CsvFileWriter(csvFilePath)) { for (int i = 0; i < cardList.Count; i++) { CsvRow row = new CsvRow(); row.Add(cardList[i].mrsId); row.Add(cardList[i].nfcId); writer.WriteRow(row); } } } detectCardIDMethod(cardNumber); } // MRS else if (listener.dInfo.deviceName.Contains("VID_6352&PID_213A")) { magneticCardID = cardNumber; if (updateNFCIDToolStripMenuItem.Checked) { if (frmNFCUpConfirm.Visible) { frmNFCUpConfirm.Close(); } string result = serviceHandle.makeRequest(magneticCardID); if (result == "NFC not found") { frmNFCUpConfirm = new NFCCardIdUpload(magneticCardID, notifyReader); frmNFCUpConfirm.BackColor = Color.FromArgb(255, 211, 183); frmNFCUpConfirm.passControl = new NFCCardIdUpload.PassControl(serviceHandle.uploadNFCCode); frmNFCUpConfirm.Show(); detectCardIDMethod(cardNumber); } else { notifyReader.BalloonTipText = result; notifyReader.ShowBalloonTip(100); } } } } }