Example #1
0
        /// <summary>
        /// Get cref="ScannerAttribute" object list from CoreScanner output XML
        /// </summary>
        /// <param name="outXml">Output XML received from CoreScanner</param>
        /// <returns>List of cref="ScannerAttribute" objects</returns>
        private List <ScannerAttribute> GetAttributesFromOutXml(string outXml)
        {
            if (String.IsNullOrEmpty(outXml))
            {
                throw new ArgumentException(INCORRECT_ARGUMENT);
            }
            List <ScannerAttribute> scannerAttributes = new List <ScannerAttribute>();

            try
            {
                XmlTextReader xmlRead = new XmlTextReader(new StringReader(outXml));
                xmlRead.WhitespaceHandling = WhitespaceHandling.Significant;
                ScannerAttribute scannerAttribute = null;
                string           elementName = String.Empty, elementValue = String.Empty;
                while (xmlRead.Read())
                {
                    switch (xmlRead.NodeType)
                    {
                    case XmlNodeType.Element:
                        elementName = xmlRead.Name;
                        break;

                    case XmlNodeType.Text:
                        elementValue = xmlRead.Value;
                        switch (elementName)
                        {
                        case Scanner.TAG_ATTR_ID:
                            scannerAttribute    = new ScannerAttribute();
                            scannerAttribute.Id = Convert.ToInt32(elementValue);
                            break;

                        case Scanner.TAG_ATTR_TYPE:
                            scannerAttribute.Type = elementValue;
                            break;

                        case Scanner.TAG_ATTR_PROPERTY:
                            scannerAttribute.Permission = elementValue;
                            break;

                        case Scanner.TAG_ATTR_VALUE:
                            scannerAttribute.Value = elementValue;
                            scannerAttributes.Add(scannerAttribute);
                            break;
                        }
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(scannerAttributes);
        }
Example #2
0
        /// <summary>
        /// Get status last RFID operation
        /// </summary>
        /// <returns></returns>
        private int GetRfidCommandStatus()
        {
            List <ScannerAttribute> attributes = GetAttributes(new List <int> {
                ATTRIBUTE_RFID_CMD_STATUS
            });

            if (attributes != null)
            {
                ScannerAttribute commandStatusAttribute = attributes[0];
                if (commandStatusAttribute.Id == ATTRIBUTE_RFID_CMD_STATUS)
                {
                    return(Convert.ToInt32(commandStatusAttribute.Value));
                }
            }
            return(-1);
        }
Example #3
0
        /// <summary>
        /// Get value of ATTRIBUTE_RFID_DATA attribute
        /// </summary>
        /// <returns>Value of ATTRIBUTE_RFID_DATA attribute. Empty string on failures. </returns>
        private string GetRfidData()
        {
            List <ScannerAttribute> attributes = GetAttributes(new List <int> {
                ATTRIBUTE_RFID_DATA
            });

            if (attributes != null)
            {
                ScannerAttribute commandStatusAttribute = attributes[0];
                if (commandStatusAttribute.Id == ATTRIBUTE_RFID_DATA)
                {
                    var data = (string)commandStatusAttribute.Value;
                    if (data.StartsWith(RFID_HEX_PREFIX))
                    {
                        data = data.Substring(10, (data.Length - 10));
                    }
                    return(data);
                }
            }
            return(String.Empty);
        }