public bool Converter(string cArquivo, string cFolderDestino)//, string cFolderRetorno)
{
cRetorno.Clear();
if (this.CarregarArquivo(cArquivo))
{
this.LinhaLida = 0;
foreach (List<string> content in this.xConteudoArquivo.Values)
{
NFe = null;
NFe = new NFe();
bool houveErro = false;
foreach (string xContent in content)
{
houveErro = false;
++this.LinhaLida;
try
{
///
/// processa o TXT
///
this.LerRegistro(xContent);
}
catch(Exception ex)
{
houveErro = true;
this.cMensagemErro += "Layout: " + this.layout.Replace(prefix, "") + Environment.NewLine;
this.cMensagemErro += "Linha lida: " + (this.LinhaLida+1).ToString()+ Environment.NewLine+
"Conteudo: " + xContent.Substring(1) + Environment.NewLine +
ex.Message + Environment.NewLine;
}
}
if (!houveErro && this.cMensagemErro == "")
{
NFeW nfew = new NFeW();
try
{
nfew.cMensagemErro = this.cMensagemErro;
///
/// gera o XML da nota
///
nfew.GerarXml(NFe, cFolderDestino);//cFolderRetorno);
if (nfew.cFileName != "")
{
///
/// Adiciona o XML na lista de arquivos convertidos
///
this.cRetorno.Add(new txtTOxmlClassRetorno(nfew.cFileName, NFe.infNFe.ID, NFe.ide.nNF, NFe.ide.serie));
}
}
catch (Exception ex)
{
nfew.cMensagemErro += ex.Message;
}
this.cMensagemErro = nfew.cMensagemErro;
}
if (this.cMensagemErro != "")
{
///
/// exclui os arquivos gerados
///
foreach (txtTOxmlClassRetorno txtClass in this.cRetorno)
{
string dArquivo = txtClass.XMLFileName;
if (File.Exists(dArquivo))
{
FileInfo fi = new FileInfo(dArquivo);
fi.Delete();
}
}
}
}
return string.IsNullOrEmpty(this.cMensagemErro);
}
return false;
}