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()); } }
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()); }
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()); }
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); }
public void ConvertUrisToBinaries(string expectedTag, string uri) { string hex = EpcTag.FromUri(uri).ToBinary(); Assert.AreEqual(expectedTag, hex); }
public void ConvertBinariesToUris(string binaryTag, string tagUri, string idUri) { var uri = EpcTag.FromBinary(binaryTag).ToString(); Assert.AreEqual(tagUri, uri); }