public virtual int Salvar(NotaFiscalEntity notaFiscalEntity, string xml)
 {
     try
     {
         if (notaFiscalEntity.Status != (int)Status.CANCELADA)
         {
             notaFiscalEntity.XmlPath = XmlFileHelper.SaveXmlFile(notaFiscalEntity, xml);
         }
         return(Salvar(notaFiscalEntity));
     }
     catch (Exception e)
     {
         log.Error(e);
         try
         {
             XmlFileHelper.DeleteXmlFile(notaFiscalEntity);
             throw;
         }
         catch (Exception ex)
         {
             log.Error(ex);
             throw new Exception("Não foi possível remover o xml de nota fiscal: " + e.Message);
         }
     }
 }
        public void ExcluirNota(string chave, Ambiente ambiente)
        {
            var notaFiscalEntity = GetNotaFiscalByChave(chave, (int)ambiente + 1);

            ExcluirNota(notaFiscalEntity.Numero, notaFiscalEntity.Serie, notaFiscalEntity.Modelo);

            try
            {
                XmlFileHelper.DeleteXmlFile(notaFiscalEntity);
            }
            catch (Exception e)
            {
                log.Error(e);
                throw new Exception("Não foi possível remover o xml de nota fiscal: " + e.Message);
            }
        }
 public virtual void Salvar(NotaInutilizadaTO notaInutilizada, string xml)
 {
     try
     {
         notaInutilizada.XmlPath = XmlFileHelper.SaveXmlFile(notaInutilizada, xml);
         _notaInutilizadaRepository.Salvar((NotaInutilizadaEntity)notaInutilizada);
     }
     catch (Exception e)
     {
         log.Error(e);
         try
         {
             XmlFileHelper.DeleteXmlFile(notaInutilizada);
         }
         catch (Exception ex)
         {
             log.Error(ex);
             throw new Exception("Não foi possível remover o xml de nota fiscal: " + e.Message);
         }
     }
 }
Esempio n. 4
0
 public virtual void Salvar(EventoEntity eventoEntity)
 {
     try
     {
         eventoEntity.XmlPath = XmlFileHelper.SaveXmlFile(eventoEntity, eventoEntity.Xml);
         _eventoRepository.Salvar(eventoEntity);
     }
     catch (Exception e)
     {
         log.Error(e);
         try
         {
             XmlFileHelper.DeleteXmlFile(eventoEntity);
         }
         catch (Exception ex)
         {
             log.Error(ex);
             throw new Exception("Não foi possível remover o xml de evento: " + e.Message);
         }
     }
 }