private string RetornarConteudoTag(string TAG)
{
///
/// "§B14|cUF|AAMM|CNPJ|Mod|serie|nNF"); //ok
///
/// se a tag a ser consulta é CNPJ, então é verificada no layout quantos pipes existem até ela.
/// neste caso no comando abaixo será retornado "§B14|cUF|AAMM|" existindo 3 pipes para pegar
/// o valor do retorno
///
if (!layout.StartsWith(prefix)) layout = prefix + layout;
if (!layout.EndsWith("|")) layout += "|";
string fValue = layout.Substring(0, layout.ToUpper().IndexOf("|" + TAG.ToUpper().Trim() + "|") + 1);
if (fValue == "")
throw new Exception("Segmento: " + this.FSegmento + " - Tag: " + TAG + " não encontrada");
string[] pipes = fValue.Split(new char[] { '|' });
int j = pipes.GetLength(0) - 1;
if (j >= 0)
{
///
/// qual a posicao do conteudo do registro lido
///
string[] dados = this.Registro.Split(new char[] { '|' });
try
{
return dados[j/* + 1*/].TrimStart().TrimEnd();
}
catch
{
return "";
}
}
else
return "";
}