public void CadastrarErroGenerico(int grvId, int usuarioId, string identificadorNota, OrigemErro origemErro, Acao acao, string mensagemErro) { var erro = new NfeWsErroModel { GrvId = grvId, IdentificadorNota = identificadorNota, UsuarioId = usuarioId, Acao = (char)acao, OrigemErro = (char)origemErro, MensagemErro = mensagemErro }; try { int id = new NfeWsErroController().Cadastrar(erro); } catch { } }
private RetornoNotaFiscalEntity ProcessarRetorno(GrvEntity grv, NfeEntity nfe, Consulta identificaoNotaFiscal, string retornoJson) { RetornoNotaFiscalEntity retornoConsulta = new JavaScriptSerializer() { MaxJsonLength = int.MaxValue }.Deserialize <RetornoNotaFiscalEntity>(retornoJson); if (retornoConsulta.status.Trim().Equals("processando_autorizacao", StringComparison.CurrentCultureIgnoreCase)) { return(retornoConsulta); } NfeWsErroModel retornoErro = new NfeWsErroModel(); NfeWsErroController NfeWsErroController = new NfeWsErroController(); if (retornoConsulta.erros != null) { foreach (Erros erro in retornoConsulta.erros) { retornoErro.GrvId = identificaoNotaFiscal.GrvId; retornoErro.IdentificadorNota = identificaoNotaFiscal.IdentificadorNota; retornoErro.UsuarioId = identificaoNotaFiscal.UsuarioId; retornoErro.Acao = (char)Acao.Retorno; retornoErro.OrigemErro = (char)OrigemErro.WebService; retornoErro.Status = retornoConsulta.status.Trim().ToUpper(); if (erro.codigo != null) { retornoErro.CodigoErro = erro.codigo.Replace(" ", " ").Trim().ToUpper(); } if (erro.mensagem != null) { retornoErro.MensagemErro = erro.mensagem.Replace(" ", " ").Trim(); } if (erro.correcao != null) { retornoErro.CorrecaoErro = erro.correcao.Replace(" ", " ").Trim(); } retornoErro.ErroId = NfeWsErroController.Cadastrar(retornoErro); } nfe.Status = 'E'; new NfeController().Atualizar(nfe); return(retornoConsulta); } else { retornoErro.GrvId = identificaoNotaFiscal.GrvId; retornoErro.IdentificadorNota = identificaoNotaFiscal.IdentificadorNota; retornoErro.UsuarioId = identificaoNotaFiscal.UsuarioId; retornoErro.Acao = (char)Acao.Retorno; retornoErro.OrigemErro = (char)OrigemErro.WebService; retornoErro.Status = retornoConsulta.status.Trim().ToUpper(); NfeWsErroController.Cadastrar(retornoErro); } if (!string.IsNullOrWhiteSpace(retornoConsulta.url)) { retornoConsulta.url = retornoConsulta.url.Replace("nfse.aspx", "/NFSE/contribuinte/notaprintimg.aspx"); if (!string.IsNullOrWhiteSpace(retornoConsulta.url)) { retornoConsulta.ImagemNotaFiscal = BaixarImagem(grv.ClienteId, grv.DepositoId, nfe.IdentificadorNota, identificaoNotaFiscal, retornoConsulta.url); } if (identificaoNotaFiscal.BaixarImagemOriginal) { return(retornoConsulta); } nfe.Status = nfe.Status == 'A' ? 'P' : 'T'; new NfeImagemController().Excluir(nfe.NfeId); new NfeImagemController().Cadastrar(nfe.NfeId, retornoConsulta.ImagemNotaFiscal); new NfeController().AtualizarRetornoNotaFiscal(nfe, retornoConsulta); } return(retornoConsulta); }