private void DeviceDataHandler(MMM.Readers.Modules.Swipe.SwipeItem swipeItem, object swipeData) { log.DebugFormat("Device data: swipe item [{0}], swipe data [{1}]", swipeItem, swipeData); NotifyListeners(new ScanSourceEvent(swipeItem, swipeData)); if (swipeItem == MMM.Readers.Modules.Swipe.SwipeItem.OCR_CODELINE) { MMM.Readers.CodelineData codeLineData = (MMM.Readers.CodelineData)swipeData; using (LogProvider.OpenNestedContext(codeLineData.Surname)) { log.InfoFormat("CodeLineData ValidationResult [{0}]", codeLineData.CodelineValidationResult); NotifyListeners(codeLineData); } } }
// Thread helper callback to make sure data is received on the correct thread. private void ProcessDataThreadHelper( MMM.Readers.Modules.Swipe.SwipeItem aDataItem, object aData ) { if (_threadHelperControl.InvokeRequired) { _threadHelperControl.Invoke( new MMM.Readers.Modules.Swipe.DataDelegate(ProcessData), new object[] { aDataItem, aData } ); } else { ProcessData(aDataItem, aData); } }
private void DeviceDataHandler(MMM.Readers.Modules.Swipe.SwipeItem aDataItem, object aData) { if (aDataItem == MMM.Readers.Modules.Swipe.SwipeItem.OCR_CODELINE) { MMM.Readers.CodelineData codeLineData = (MMM.Readers.CodelineData)aData; if (codeLineData.CheckDigitDataListCount > 0 && (codeLineData.CodelineValidationResult == MMM.Readers.CheckDigitResult.CDR_Valid || codeLineData.CodelineValidationResult == MMM.Readers.CheckDigitResult.CDR_Warning) ) { log.DebugFormat("CodeLineScanEvent invoke handlers [{0}]", codeLineData); OnCodeLineScanEvent(this, new CodeLineScanEvent(codeLineData)); log.Debug("CodeLineScanEvent handler calls returned"); } else { log.DebugFormat("CodeLineData Ignored [{0}]", codeLineData); } } }
public ScanSourceEvent(MMM.Readers.Modules.Swipe.SwipeItem swipeItem, object swipeData) { EventType = ScanSourceEventType.DATA_EVENT; SwipeItem = swipeItem; SwipeData = swipeData; }
private void ProcessData(MMM.Readers.Modules.Swipe.SwipeItem aDataItem, object aData) { string dataStr = string.Empty; if (aData is int || aData is bool || aData is float || aData is string) { dataStr = aData.ToString(); InsertRow((int)aDataItem, aDataItem.ToString(), 0, dataStr, RowType.Data); } else if (aData is MMM.Readers.CodelineData) { MMM.Readers.CodelineData codeline = (MMM.Readers.CodelineData)aData; InsertRow((int)aDataItem, aDataItem.ToString(), codeline.Data.Length, codeline.Data, RowType.Data); InsertRow((int)aDataItem, "OCR_LINE_1", codeline.Line1.Length, codeline.Line1, RowType.Data); InsertRow((int)aDataItem, "OCR_LINE_2", codeline.Line2.Length, codeline.Line2, RowType.Data); InsertRow((int)aDataItem, "OCR_LINE_3", codeline.Line3.Length, codeline.Line3, RowType.Data); InsertRow((int)aDataItem, "OCR_DOC_ID", codeline.DocId.Length, codeline.DocId, RowType.Data); InsertRow((int)aDataItem, "OCR_DOC_TYPE", codeline.DocType.Length, codeline.DocType, RowType.Data); InsertRow((int)aDataItem, "OCR_SURNAME", codeline.Surname.Length, codeline.Surname, RowType.Data); InsertRow((int)aDataItem, "OCR_FORENAME", codeline.Forename.Length, codeline.Forename, RowType.Data); InsertRow((int)aDataItem, "OCR_SECOND_NAME", codeline.SecondName.Length, codeline.SecondName, RowType.Data); InsertRow((int)aDataItem, "OCR_FORENAMES", codeline.Forenames.Length, codeline.Forenames, RowType.Data); if (codeline.DateOfBirth.Day == -1 && codeline.DateOfBirth.Month == -1 && codeline.DateOfBirth.Year == -1) { InsertRow((int)aDataItem, "OCR_DATE_OF_BIRTH", 0, "", RowType.Data); } else { string lD, lM, lY; if (codeline.DateOfBirth.Day == -1) { lD = "??-"; } else { lD = string.Format("{0:00}-", codeline.DateOfBirth.Day); } if (codeline.DateOfBirth.Month == -1) { lM = "??-"; } else { lM = string.Format("{0:00}-", codeline.DateOfBirth.Month); } if (codeline.DateOfBirth.Year == -1) { lY = "??"; } else { lY = string.Format("{0:00}", codeline.DateOfBirth.Year); } InsertRow((int)aDataItem, "OCR_DATE_OF_BIRTH", 0, (lD + lM + lY), RowType.Data); } if (codeline.ExpiryDate.Day == -1 && codeline.ExpiryDate.Month == -1 && codeline.ExpiryDate.Year == -1) { InsertRow((int)aDataItem, "OCR_EXPIRY_DATE", 0, "", RowType.Data); } else { string lD, lM, lY; if (codeline.ExpiryDate.Day == -1) { lD = "??-"; } else { lD = string.Format("{0:00}-", codeline.ExpiryDate.Day); } if (codeline.ExpiryDate.Month == -1) { lM = "??-"; } else { lM = string.Format("{0:00}-", codeline.ExpiryDate.Month); } if (codeline.ExpiryDate.Year == -1) { lY = "??"; } else { lY = string.Format("{0:00}", codeline.ExpiryDate.Year); } InsertRow((int)aDataItem, "OCR_EXPIRY_DATE", 0, (lD + lM + lY), RowType.Data); } InsertRow((int)aDataItem, "OCR_ISSUING_STATE", codeline.IssuingState.Length, codeline.IssuingState, RowType.Data); InsertRow((int)aDataItem, "OCR_NATIONALITY", codeline.Nationality.Length, codeline.Nationality, RowType.Data); InsertRow((int)aDataItem, "OCR_DOC_NUMBER", codeline.DocNumber.Length, codeline.DocNumber, RowType.Data); InsertRow((int)aDataItem, "OCR_SEX", codeline.Sex.Length, codeline.Sex, RowType.Data); InsertRow((int)aDataItem, "OCR_SHORT_SEX", 1, Convert.ToChar(codeline.ShortSex).ToString(), RowType.Data); #if !DOTNET_11 InsertRow((int)aDataItem, "OCR_OPTIONALDATA1", codeline.OptionalData1.Length, codeline.OptionalData1, RowType.Data); InsertRow((int)aDataItem, "OCR_OPTIONALDATA2", codeline.OptionalData2.Length, codeline.OptionalData2, RowType.Data); #endif } else if (aData is MMM.Readers.Modules.Swipe.MsrData) { MMM.Readers.Modules.Swipe.MsrData msrData = (MMM.Readers.Modules.Swipe.MsrData)aData; InsertRow((int)aDataItem, "MSR_TRACK_1", msrData.Track1.Length, msrData.Track1, RowType.Data); InsertRow((int)aDataItem, "MSR_TRACK_2", msrData.Track2.Length, msrData.Track2, RowType.Data); InsertRow((int)aDataItem, "MSR_TRACK_3", msrData.Track3.Length, msrData.Track3, RowType.Data); } else if (aData is MMM.Readers.Modules.Swipe.SwipeBarcodePDF417Data) { MMM.Readers.Modules.Swipe.SwipeBarcodePDF417Data swipeBarcodeData = (MMM.Readers.Modules.Swipe.SwipeBarcodePDF417Data)aData; InsertRow((int)aDataItem, "BARCODE PDF417", swipeBarcodeData.DataField.Length, swipeBarcodeData.DataField, RowType.Data); } else if (aData is MMM.Readers.Modules.Swipe.SwipeBarcodeCode128Data) { MMM.Readers.Modules.Swipe.SwipeBarcodeCode128Data swipeBarcodeData = (MMM.Readers.Modules.Swipe.SwipeBarcodeCode128Data)aData; InsertRow((int)aDataItem, "BARCODE CODE 128", swipeBarcodeData.DataField.Length, swipeBarcodeData.DataField, RowType.Data); } else if (aData is MMM.Readers.Modules.Swipe.SwipeBarcodeCode39Data) { MMM.Readers.Modules.Swipe.SwipeBarcodeCode39Data swipeBarcodeData = (MMM.Readers.Modules.Swipe.SwipeBarcodeCode39Data)aData; InsertRow((int)aDataItem, "BARCODE CODE 39", swipeBarcodeData.DataField.Length, swipeBarcodeData.DataField, RowType.Data); } else if (aData is MMM.Readers.AAMVAData) { MMM.Readers.AAMVAData AAMVAData = (MMM.Readers.AAMVAData)aData; InsertRow((int)aDataItem, "AAMVA_FULLNAME", AAMVAData.Parsed.FullName.Length, AAMVAData.Parsed.FullName, RowType.Data); InsertRow((int)aDataItem, "AAMVA_FORENAME", AAMVAData.Parsed.Forename.Length, AAMVAData.Parsed.Forename, RowType.Data); InsertRow((int)aDataItem, "AAMVA_SURNAME", AAMVAData.Parsed.Surname.Length, AAMVAData.Parsed.Surname, RowType.Data); InsertRow((int)aDataItem, "AAMVA_LICENCE_NUMBER", AAMVAData.Parsed.LicenceNumber.Length, AAMVAData.Parsed.LicenceNumber, RowType.Data); InsertRow((int)aDataItem, "AAMVA_ADDRESS_STREET", AAMVAData.Parsed.AddressStreet.Length, AAMVAData.Parsed.AddressStreet, RowType.Data); InsertRow((int)aDataItem, "AAMVA_ADDRESS_CITY", AAMVAData.Parsed.AddressCity.Length, AAMVAData.Parsed.AddressCity, RowType.Data); InsertRow((int)aDataItem, "AAMVA_ADDRESS_POSTALCODE", AAMVAData.Parsed.AddressPostalCode.Length, AAMVAData.Parsed.AddressPostalCode, RowType.Data); InsertRow((int)aDataItem, "AAMVA_ADDRESS_STATE", AAMVAData.Parsed.AddressState.Length, AAMVAData.Parsed.AddressState, RowType.Data); InsertRow((int)aDataItem, "AAMVA_ADDRESS_COUNTRY", AAMVAData.Parsed.AddressCountry.Length, AAMVAData.Parsed.AddressCountry, RowType.Data); } else if (aData is MMM.Readers.Modules.Swipe.AtbData) { MMM.Readers.Modules.Swipe.AtbData atbData = (MMM.Readers.Modules.Swipe.AtbData)aData; InsertRow((int)aDataItem, "ATB_TRACK_1_BLOCK_1", atbData.Track1.Block1.Length, atbData.Track1.Block1, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_1_BLOCK_2", atbData.Track1.Block2.Length, atbData.Track1.Block2, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_1_BLOCK_3", atbData.Track1.Block3.Length, atbData.Track1.Block3, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_2_BLOCK_1", atbData.Track2.Block1.Length, atbData.Track2.Block1, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_2_BLOCK_2", atbData.Track2.Block2.Length, atbData.Track2.Block2, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_2_BLOCK_3", atbData.Track2.Block3.Length, atbData.Track2.Block3, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_3_BLOCK_1", atbData.Track3.Block1.Length, atbData.Track3.Block1, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_3_BLOCK_2", atbData.Track3.Block2.Length, atbData.Track3.Block2, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_3_BLOCK_3", atbData.Track3.Block3.Length, atbData.Track3.Block3, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_4_BLOCK_1", atbData.Track4.Block1.Length, atbData.Track4.Block1, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_4_BLOCK_2", atbData.Track4.Block2.Length, atbData.Track4.Block2, RowType.Data); InsertRow((int)aDataItem, "ATB_TRACK_4_BLOCK_3", atbData.Track4.Block3.Length, atbData.Track4.Block3, RowType.Data); } else if (aData is MMM.Readers.Modules.Swipe.RTEQAData) { MMM.Readers.Modules.Swipe.RTEQAData qaData = (MMM.Readers.Modules.Swipe.RTEQAData)aData; InsertRow((int)aDataItem, "QA_CODELINE_COUNT", 0, qaData.CodelineCount.ToString(), RowType.Data); InsertRow((int)aDataItem, "QA_COLUMN_COUNT", 0, qaData.ColumnCount.ToString(), RowType.Data); InsertRow((int)aDataItem, "QA_CLEAR_AREA_PRESENT", 0, Convert.ToBoolean(qaData.ClearAreaPresent).ToString(), RowType.Data); InsertRow((int)aDataItem, "QA_SPOT_COUNT", 0, qaData.SpotCount.ToString(), RowType.Data); ShowQALineData((int)aDataItem, 1, qaData.Line1); ShowQALineData((int)aDataItem, 2, qaData.Line2); ShowQALineData((int)aDataItem, 3, qaData.Line3); } else if (aData is MMM.Readers.Modules.Swipe.RTESwipeData) { MMM.Readers.Modules.Swipe.RTESwipeData rteData = (MMM.Readers.Modules.Swipe.RTESwipeData)aData; InsertRow((int)aDataItem, "RTE_DEVICE_TYPE", 0, rteData.DeviceType.ToString(), RowType.Data); InsertRow((int)aDataItem, "RTE_MESSAGE_TYPE", 0, rteData.MessageType.ToString(), RowType.Data); InsertRow((int)aDataItem, "RTE_BCC", 0, rteData.BCC.ToString(), RowType.Data); InsertRow((int)aDataItem, "RTE_OCR_FLAG_BYTE", 0, rteData.OCRFlagByte.ToString(), RowType.Data); } else if (aData is MMM.Readers.Modules.Swipe.MuseSwipeData) { MMM.Readers.Modules.Swipe.MuseSwipeData museData = (MMM.Readers.Modules.Swipe.MuseSwipeData)aData; InsertRow((int)aDataItem, "MUSE_DEVICE_TYPE", 0, museData.DeviceType.ToString(), RowType.Data); InsertRow((int)aDataItem, "MUSE_CRC_HIGH", 0, museData.CrcHigh.ToString(), RowType.Data); InsertRow((int)aDataItem, "MUSE_CRC_LOW", 0, museData.CrcLow.ToString(), RowType.Data); } else if (aData is MMM.Readers.Modules.Swipe.CuteSwipeData) { MMM.Readers.Modules.Swipe.CuteSwipeData cuteData = (MMM.Readers.Modules.Swipe.CuteSwipeData)aData; InsertRow((int)aDataItem, "CUTE_DEVICE_TYPE", 0, cuteData.DeviceType.ToString(), RowType.Data); } else if (aData is MMM.Readers.Modules.Swipe.MagtekMsrSwipeData) { MMM.Readers.Modules.Swipe.MagtekMsrSwipeData magtekData = (MMM.Readers.Modules.Swipe.MagtekMsrSwipeData)aData; InsertRow((int)aDataItem, "MAGTEK_MSR_CARD_TYPE", 0, magtekData.CardEncodeType.ToString(), RowType.Data); } else if (aData is MMM.Readers.Modules.Swipe.TecsSwipeData) { MMM.Readers.Modules.Swipe.TecsSwipeData tecsData = (MMM.Readers.Modules.Swipe.TecsSwipeData)aData; InsertRow((int)aDataItem, "TECS_DEVICE_TYPE", 0, tecsData.DeviceType.ToString(), RowType.Data); } else if (aData is byte) { byte dataValue = (byte)aData; dataStr = dataValue.ToString("X2"); InsertRow((int)aDataItem, aDataItem.ToString(), 0, dataStr, RowType.Data); } else if (aData is byte[]) { byte[] dataArray = aData as byte[]; if (aDataItem == MMM.Readers.Modules.Swipe.SwipeItem.WHOLE_DATA) { dataStr = ConvertSwipeDataByteArray(dataArray); } else { foreach (byte byteVal in dataArray) { dataStr = string.Concat(dataStr, byteVal.ToString("X2"), " "); } } InsertRow((int)aDataItem, aDataItem.ToString(), 0, dataStr, RowType.Data); } }