/// <summary> /// Método de Decodificação da string binária para valores legíveis /// </summary> /// <param name="linhaBinaria">Descriptografa a string Binária no padrão GS1</param> public void Decript(string linhaBinaria) { int posicaoInicial = 0; this.Header = EpcHeaders.GetName(linhaBinaria.Substring(posicaoInicial, 8)); posicaoInicial += 8; this.Filter = Convert.ToInt32(linhaBinaria.Substring(posicaoInicial, 3), 2).ToString(); posicaoInicial += 3; this.Partition = Convert.ToInt32(linhaBinaria.Substring(posicaoInicial, 3), 2); posicaoInicial += 3; this.CompanyPrefix = Convert.ToInt64(linhaBinaria.Substring(posicaoInicial, GraiPartition.GetCompany(this.Partition)), 2); posicaoInicial += GraiPartition.GetCompany(this.Partition); this.ItemReference = Convert.ToInt64(linhaBinaria.Substring(posicaoInicial, GraiPartition.GetItem(this.Partition)), 2); posicaoInicial += GraiPartition.GetItem(this.Partition); this.SerialNumber = Convert.ToInt64(linhaBinaria.Substring(posicaoInicial, 38), 2); }
/// <summary> /// Método de Codificação segundo o Padrão EPC /// </summary> /// <returns>Objeto Simplicado do padrão</returns> public EPCSimplesDTO Encript() { string Header = EpcHeaders.GetBin(this.Header); string Filter = HelperConverter.fill(Convert.ToString(Convert.ToInt32(this.Filter), 2), 3); string Partition = HelperConverter.fill(Convert.ToString(this.Partition, 2), 3); string CompanyPrefix = HelperConverter.fill(Convert.ToString(this.CompanyPrefix, 2), GraiPartition.GetCompany(this.Partition)); string ItemReference = HelperConverter.fill(Convert.ToString(this.ItemReference, 2), GraiPartition.GetItem(this.Partition)); string SerialNumber = HelperConverter.fill(Convert.ToString(this.SerialNumber, 2), 38); string BinString = $"{Header}{Filter}{Partition}{CompanyPrefix}{ItemReference}{SerialNumber}"; EPCSimplesDTO retorno = new EPCSimplesDTO(); retorno.BarCode = "NAO POSSUI"; retorno.EPCString = EpcTagURI(); retorno.HexadecimalString = HelperConverter.BinaryStringToHexString(BinString); return(retorno); }