public async Task <Resposta> DeletaArquivoSPLS(int id_visual) { try { var webService = new WebServiceSPLS.Sistema1SoapClient(WebServiceSPLS.Sistema1SoapClient.EndpointConfiguration.Sistema1Soap); await webService.DeletarDadosAsync(id_visual.ToString(), "ald.ws", "ald214409", "ALD"); this.dados.Documento_Fiscal.Remove(this.dados.Documento_Fiscal.SingleOrDefault(x => x.id_visual == id_visual)); this.dados.SaveChanges(); return(this.resposta.SetResposta("Arquivo deletado com sucesso!")); } catch (Exception ex) { return(this.resposta.SetResposta("Erro ao deletar arquivo na SPLS", false, ex)); } }
public async Task UploadArquivoSPLS(Solicitacao_Pagamento solicitacaoPagamento) { WebServiceSPLS.Sistema1SoapClient webService = null; try { var fornecedor = this.dados.ALD_ETL_Fornecedores.Single(x => x.Numero == solicitacaoPagamento.numero_fornecedor); solicitacaoPagamento.Documento_Fiscal = solicitacaoPagamento.Documento_Fiscal.OrderBy(x => x.nf_nr).ToList(); foreach (var Documento_Fiscal in solicitacaoPagamento.Documento_Fiscal.Where(x => x.id == 0)) { var dadosSPLS = new WebServiceSPLS.ArrayOfString { null, //solicitacaoPagamento.id.ToString(), null, //numeroAgreement Documento_Fiscal.nf_nr.ToString(), null, //numeroContrato null, //placa fornecedor.Razao_Social, fornecedor.Nome_fantasia, fornecedor.CNPJ, solicitacaoPagamento.valor_total.ToString(), null, //Número do cliente ALD null, //Nome do cliente ALD null, //Forma de Pagamento, null, //Número da fatura null, //fgRebilSN null, //notaFiscal.mes_fat, solicitacaoPagamento.dt_criacao.ToString(), this.usuarioNegocio.GetUsuario().nome, null, //solicitacaoPagamento.dt_emiss_nf.ToString(), null, //solicitacaoPagamento.dt_venc.ToString(), null //notaFiscal.chave_acesso }; byte[] fileByte = System.Convert.FromBase64String(Documento_Fiscal.arquivo); webService = new WebServiceSPLS.Sistema1SoapClient(WebServiceSPLS.Sistema1SoapClient.EndpointConfiguration.Sistema1Soap); if (Util.ValidaCampo(Documento_Fiscal.id_visual)) { await DeletaArquivoSPLS(Documento_Fiscal.id_visual.Value); if (!this.resposta.Status) { throw this.resposta.Exception; } } var resposta = await webService.InserirDadosEDocumentoAsync("ald.ws", "ald214409", "ALD", "01", "01", fileByte, Documento_Fiscal.nome_arquivo, dadosSPLS); Documento_Fiscal.id_visual = Convert.ToInt32(resposta.Body.InserirDadosEDocumentoResult); Documento_Fiscal.dt_cadastro = DateTime.Now; Documento_Fiscal.usuario = this.usuarioNegocio.GetUsuario().id; } } catch (Exception ex) { throw new NegocioException("Erro ao carregar arquivo na SPLS", ex); } }