public bool GetScanners(out short numberOfScanners, out List <ScannerInfo> scannerInfoList, out string outXml, out string status) { int scannerCount = 0, zStatus; int[] connectedScannerIdArray; ScannerInfo[] scannerInfoArray; LogWrapper.log(MethodBase.GetCurrentMethod()); numberOfScanners = 0; outXml = string.Empty; scannerInfoList = new List <ScannerInfo>(); connectedScannerIdArray = new int[MAX_NUM_DEVICES]; try { if (_IsOpen == false) { status = "Scanner is closed"; return(false); } _CoreScanner.GetScanners(out numberOfScanners, connectedScannerIdArray, out outXml, out zStatus); if (STATUS_SUCCESS == zStatus) { if (numberOfScanners < 1) { status = "No Scanners Were Found"; return(false); } scannerInfoArray = new ScannerInfo[MAX_NUM_DEVICES]; for (int i = 0; i < MAX_NUM_DEVICES; i++) { scannerInfoArray[i] = new ScannerInfo(); } scannerInfoList = parseScannerXml <ScannerData>(outXml); //_Xml.ReadXmlstring_GetScanners(outXml, scannerInfoArray, numberOfScanners, out scannerCount, out status); for (int i = 0; i < scannerCount; i++) { scannerInfoList.Add(scannerInfoArray[i]); } status = "OK"; return(true); } else { status = decodeStatusMessage(zStatus); return(false); } } catch (Exception ex) { status = ex.Message; return(false); } }
public static List <ScannerInfo> parseScannerXml <T>(string outXml) where T : IFixable { List <ScannerInfo> ret = new List <ScannerInfo>(); StringBuilder sb = new StringBuilder(); XmlReaderSettings xrs = new XmlReaderSettings(); XmlSerializer xs; //XmlDeserializationEvents xde; T myObj; object anObj; using (StringReader sr = new StringReader(outXml)) { xrs.ValidationEventHandler += Xrs_ValidationEventHandler; xrs.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings; using (XmlReader xr = XmlReader.Create(sr, xrs)) { try { xs = new XmlSerializer(typeof(ScannerData)); //xs. //anObj = xs.Deserialize(xr, new XmlDeserializationEvents) //xde = new XmlDeserializationEvents(); //xs.OnUnknownAttribute = unknownAttribute; //xde.OnUnknownElement = unknownElement; //xde.OnUnknownNode = unknownNode; //xde.OnUnreferencedObject = unrefObj; //anObj = xs.Deserialize(xr, xde); xs.UnknownAttribute += foundUnknownAttribute; xs.UnknownElement += foundUnknownElement; xs.UnknownNode += foundUnknownNode; xs.UnreferencedObject += foundUnrefObj; anObj = xs.Deserialize(xr); if (anObj != null) { myObj = (T)anObj; myObj.fixup(); //anObj. } System.Diagnostics.Trace.WriteLine("here"); } catch (Exception ex) { LogWrapper.log(MethodBase.GetCurrentMethod(), ex); } } } return(ret); }
public bool open(short[] scannerTypesArray, out string status) { int zStatus; LogWrapper.logInfo(string.Format("Open()")); if (_IsOpen) { LogWrapper.logWarning(string.Format("Open() Zebra Scanner is already open")); status = "OK"; return(true); } int appHandle = 0; try { short sizeOfScannerTypesArray = 1; scannerTypesArray[0] = SCANNER_TYPES_ALL; zStatus = STATUS_FAIL; _CoreScanner.Open(appHandle, scannerTypesArray, sizeOfScannerTypesArray, out zStatus); if (STATUS_SUCCESS == zStatus) { _IsOpen = true; if (RegisterForEvents(out status) == false) { LogWrapper.logError(string.Format("RegisterForEvents() FAILED: {0}", status)); _IsOpen = false; return(false); } status = "OK"; return(true); } else { status = decodeStatusMessage(zStatus); LogWrapper.logError(string.Format("_CoreScanner.Open() FAILED: {0}", status)); return(false); } } catch (Exception ex) { status = ex.Message; LogWrapper.logError(string.Format("Open() FAILED: {0}", status)); return(false); } }
void tsmiTest_Click(object sender, EventArgs e) { short nscanners; string zzz, status; List <ScannerInfo> info1; #if USE_COLT3 List <Colt3.ZebraScanner.ScannerInfo> info; var ret = _scanner.GetScanners(out nscanners, out info, out zzz, out status); #else var ret = _scanner.GetScanners(out nscanners, out info, out zzz, out status); #endif if (ret) { //ZebraWrapper.parseScannerXml(zzz); ZebraWrapper.parseScannerXml <ScannerData>(zzz); } LogWrapper.log(MethodBase.GetCurrentMethod()); //_scanner. }
void formLoad(object sender, EventArgs ea) { string status; #if USE_COLT3 _scanner = new Colt3.ZebraScanner.ZScanner(); #else _scanner = new ZebraWrapper(); #endif if (_scanner.Initialize( OnZebraPlugAndPlayEventDelegate, OnZebraBarcodeEventDelegate, test1, test2, OnZebraScannerNotificationEventDelegate, OnZebraDisplayMessageDelegate, out status) == false) { LogWrapper.logError(CL.makeSig(MethodBase.GetCurrentMethod()) + " " + status); return; } LogWrapper.log(MethodBase.GetCurrentMethod(), "scanner initialized...."); short[] scannerTypeArray = new short[10]; #if USE_COLT3 if (_scanner.Open(scannerTypeArray, out status) == false) { LogWrapper.logError(CL.makeSig(MethodBase.GetCurrentMethod()) + " " + status); return; } #else //_scanner.Open () if (_scanner.open(scannerTypeArray, out status) == false) { LogWrapper.logError(CL.makeSig(MethodBase.GetCurrentMethod()) + " " + status); return; } #endif LogWrapper.log(MethodBase.GetCurrentMethod(), "scanner opened OK"); }
void OnVideoEvent(short eventType, int size, ref object sfvideoData, ref string pScannerData) { LogWrapper.log(MethodBase.GetCurrentMethod()); }
public bool SetDeviceSwitchHostMode(string mode, bool silent, bool permanent, out string status, int scannerId = 1) { LogWrapper.log(MethodBase.GetCurrentMethod()); status = null; return(false); }
void OnZebraDisplayMessageDelegate(string msg) { LogWrapper.log(MethodBase.GetCurrentMethod(), "MSG=" + msg); }
void test1(long size, short imageFormat, byte[] frameBuffer) { LogWrapper.log(MethodBase.GetCurrentMethod()); }
void OnZebraScannerNotificationEventDelegate(short notificationType, ref string scannerData) { LogWrapper.log("NOTIFYTYPE=" + notificationType); }
static void unknownElement(object sender, XmlElementEventArgs e) { LogWrapper.log(MethodBase.GetCurrentMethod(), " found: " + e.Element.Name); }
static void Xrs_ValidationEventHandler(object sender, ValidationEventArgs e) { LogWrapper.log(MethodBase.GetCurrentMethod()); }
static void unrefObj(object sender, UnreferencedObjectEventArgs e) { LogWrapper.log(MethodBase.GetCurrentMethod()); }
void OnScannerNotification(short notificationType, ref string pScannerData) { LogWrapper.log(MethodBase.GetCurrentMethod()); }
public delegate void OnZebraDisplayMessageDelegate(string msg); internal void Close() { LogWrapper.log(MethodBase.GetCurrentMethod()); //throw new NotImplementedException(); }
void OnZebraPlugAndPlayEventDelegate(bool attached) { LogWrapper.log("attached=" + attached); }
void OnZebraBarcodeEventDelegate(string barcode) { LogWrapper.log("barcode=" + barcode); }
static void unknownNode(object sender, XmlNodeEventArgs e) { LogWrapper.log(MethodBase.GetCurrentMethod(), e.ObjectBeingDeserialized.GetType().Name + ": have " + e.NodeType + " called " + e.Name); }
void OnImageEvent(short eventType, int size, short imageFormat, ref object sfImageData, ref string pScannerData) { LogWrapper.log(MethodBase.GetCurrentMethod()); }
static void unknownAttribute(object sender, XmlAttributeEventArgs e) { LogWrapper.log(MethodBase.GetCurrentMethod()); }
void OnBarcodeEventSdk(short eventType, ref string pscanData) { LogWrapper.log(MethodBase.GetCurrentMethod()); }
void OnPNPEvent(short eventType, ref string ppnpData) { LogWrapper.log(MethodBase.GetCurrentMethod()); }
void test2(byte[] frameBuffer) { LogWrapper.log(MethodBase.GetCurrentMethod()); }