Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
        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.
        }
Esempio n. 5
0
        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");
        }
Esempio n. 6
0
 void OnVideoEvent(short eventType, int size, ref object sfvideoData, ref string pScannerData)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
 }
Esempio n. 7
0
 public bool SetDeviceSwitchHostMode(string mode, bool silent, bool permanent, out string status, int scannerId = 1)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
     status = null;
     return(false);
 }
Esempio n. 8
0
 void OnZebraDisplayMessageDelegate(string msg)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod(), "MSG=" + msg);
 }
Esempio n. 9
0
 void test1(long size, short imageFormat, byte[] frameBuffer)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
 }
Esempio n. 10
0
 void OnZebraScannerNotificationEventDelegate(short notificationType, ref string scannerData)
 {
     LogWrapper.log("NOTIFYTYPE=" + notificationType);
 }
Esempio n. 11
0
 static void unknownElement(object sender, XmlElementEventArgs e)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod(), " found: " + e.Element.Name);
 }
Esempio n. 12
0
 static void Xrs_ValidationEventHandler(object sender, ValidationEventArgs e)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
 }
Esempio n. 13
0
 static void unrefObj(object sender, UnreferencedObjectEventArgs e)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
 }
Esempio n. 14
0
 void OnScannerNotification(short notificationType, ref string pScannerData)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
 }
Esempio n. 15
0
 public delegate void OnZebraDisplayMessageDelegate(string msg); internal void Close()
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
     //throw new NotImplementedException();
 }
Esempio n. 16
0
 void OnZebraPlugAndPlayEventDelegate(bool attached)
 {
     LogWrapper.log("attached=" + attached);
 }
Esempio n. 17
0
 void OnZebraBarcodeEventDelegate(string barcode)
 {
     LogWrapper.log("barcode=" + barcode);
 }
Esempio n. 18
0
 static void unknownNode(object sender, XmlNodeEventArgs e)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod(), e.ObjectBeingDeserialized.GetType().Name + ": have " + e.NodeType + " called " + e.Name);
 }
Esempio n. 19
0
 void OnImageEvent(short eventType, int size, short imageFormat, ref object sfImageData, ref string pScannerData)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
 }
Esempio n. 20
0
 static void unknownAttribute(object sender, XmlAttributeEventArgs e)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
 }
Esempio n. 21
0
 void OnBarcodeEventSdk(short eventType, ref string pscanData)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
 }
Esempio n. 22
0
 void OnPNPEvent(short eventType, ref string ppnpData)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
 }
Esempio n. 23
0
 void test2(byte[] frameBuffer)
 {
     LogWrapper.log(MethodBase.GetCurrentMethod());
 }