public ActionResult <string> Get(string singleTag)
        {
            if (string.IsNullOrWhiteSpace(singleTag))
            {
                return(NotFound());
            }

            try
            {
                Tag tag = _tagProcessor.DecodeEpcTag(singleTag);
                if (tag == null)
                {
                    return(NotFound());
                }
                if (tag.Status != TagStatus.TagOK)
                {
                    return(NotFound(CreateEpcTag(tag)));
                }

                EpcTag epcTag = CreateEpcTag(tag);
                return(Ok(epcTag));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Esempio n. 2
0
        public void ConvertBinaryToTypedTag()
        {
            var tag = EpcTag.FromBinary <Sgtin96Tag>("302D28B329B0F6C000000001");

            Assert.NotNull(tag);
            Assert.AreEqual("urn:epc:tag:sgtin-96:1.311112347.0987.1", tag.ToString());
        }
Esempio n. 3
0
        private int update(EpcTag epcTag)
        {
            EpcTag tag = this.db.EpcTag.Where(p => p.EPC == epcTag.EPC).FirstOrDefault();

            tag.Count += 1;
            this.db.EpcTag.Update(tag);
            return(this.db.SaveChanges());
        }
Esempio n. 4
0
 public int Add(EpcTag epcTag)
 {
     if (this.db.EpcTag.Any(p => p.EPC == epcTag.EPC))
     {
         return(this.update(epcTag));
     }
     this.db.EpcTag.Add(epcTag);
     return(this.db.SaveChanges());
 }
        private EpcTag CreateEpcTag(Tag tag)
        {
            EpcTag epcTag = new EpcTag();

            epcTag.Version   = "2.0.0";
            epcTag.TagStatus = tag.Status.ToString();
            epcTag.Tag       = new EpcTagMetadata()
            {
                EpcHex    = tag.HexStringValue,
                EpcBin    = tag.BitStringValue,
                TagScheme = tag.Type.ToString(),
            };

            epcTag.TagValues = new EpcTagValues()
            {
                Filter          = tag.Filter,
                Partition       = tag.Partition,
                CompanyPrefix   = tag.CompanyPrefix,
                ItemReference   = tag.ItemReference,
                SerialReference = tag.SerialReference
            };
            return(epcTag);
        }
Esempio n. 6
0
        public void ConvertUrisToBinaries(string expectedTag, string uri)
        {
            string hex = EpcTag.FromUri(uri).ToBinary();

            Assert.AreEqual(expectedTag, hex);
        }
Esempio n. 7
0
        public void ConvertBinariesToUris(string binaryTag, string tagUri, string idUri)
        {
            var uri = EpcTag.FromBinary(binaryTag).ToString();

            Assert.AreEqual(tagUri, uri);
        }