public void TestarArquivoExistente()
        {
            //Given
            ArquivoBO arquivoBO   = new ArquivoBO();
            Arquivo   arquivo     = new Arquivo();
            string    nomeArquivo = "Horario GDS";

            //When
            arquivo = arquivoBO.BuscarArquivoPorNome(nomeArquivo);

            //Then
            Assert.AreEqual(nomeArquivo, arquivo.Nome);
        }
        public void Execute(IJobExecutionContext context)
        {
            ArquivoDAO arquivoDAO    = new ArquivoDAO();
            ArquivoBO  arquivoBO     = null;
            Arquivo    arquivo       = null;
            string     message       = "";
            int        idAgendamento = 0;
            bool       sucesso       = false;

            try
            {
                //DateTime dataTeste = DateTime.Parse("2017-03-12");
                JobDataMap jobDataMap = context.JobDetail.JobDataMap;
                idAgendamento = jobDataMap.GetInt("idAgendamento");
                arquivo       = new Arquivo();
                arquivoBO     = new ArquivoBO(arquivo);
                string nomeArquivoNaElo = LocalizaNomeArquivoElo(DateTime.Now); //datetime.nom
                if (nomeArquivoNaElo == "")
                {
                    throw new Exception("Nenhum arquivo recepcionado com o nome especificado.");
                }
                if ((arquivo = arquivoDAO.BuscarPorLayout(1, DateTime.Now)) == null) //dateTime.now.date
                {
                    int idEmissor = new EmissorDAO().Buscar("CBSS").IdEmissor;
                    arquivo = arquivoBO.GerarArquivo(1, idEmissor, nomeArquivoNaElo);
                }
                arquivoBO.Arquivo = arquivoDAO.Buscar(arquivo.IdArquivo);
                arquivoBO.Importar();
                message = "Liquidação Nacional Elo. Arquivo importado.";
                sucesso = true;
                Logger.Info(this.ToString(), message, "QuartzJob");
            }
            catch (Exception ex)
            {
                message = "Erro ao executar importação automática do arquivo de Liquidação Nacional Elo. " + ex.GetAllMessages();
                sucesso = false;
                Logger.Warn(this.ToString(), message, "QuartzJob");
                throw ex;
            }
            finally
            {
                new ExecucaoAgendamentoBO().SalvarExecucaoAgendamento(idAgendamento, DateTime.Now, message, sucesso);
            }
        }
Ejemplo n.º 3
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNome.Text))
            {
                MessageBox.Show("Informe o Nome do Método", "Atenção!");
                return;
            }

            if (ValidaCamposObrigatorios())
            {
                string nmMetodo      = txtNome.Text;
                string urlWebService = txtUrl.Text;
                string contentType   = txtContent.Text;
                string userAgent     = txtAgent.Text;
                string body          = rtbBody.Text;
                string keyA          = txtHeaderKeyA.Text;
                string valueA        = txtHeaderValueA.Text;
                string keyB          = txtHeaderKeyB.Text;
                string valueB        = txtHeaderValueB.Text;
                string metodo        = cmbMetodo.Text;

                bool isSemAutent = rdbSemAutenticacao.Checked ? true : false;
                bool isComAutent = rdbUserPass.Checked ? true : false;
                bool isBasic     = rdbBasic.Checked ? true : false;
                bool isHeader    = rdbHeader.Checked ? true : false;

                Arquivo arquivo = new ArquivoBO().GerarArquivo(nmMetodo, urlWebService, metodo, isSemAutent, isComAutent, isBasic, isHeader, keyA, valueA, keyB, valueB, contentType, userAgent, body);
                string  retorno = new ArquivoBO().GravarArquivo(arquivo);

                nomesMetodosConsulta = new List <string>();
                nomesMetodosConsulta = new ArquivoBO().BuscarNomeArquivosGravados();
                PreencherTelaMetoodosWebService(nomesMetodosConsulta);

                MessageBox.Show(retorno, "Atenção!");
            }
        }
Ejemplo n.º 4
0
 private void RemoverArquivo(DirectEventArgs e)
 {
     try
     {
         ArquivoVO arquivo = new ArquivoBO().SelectById(e.ExtraParams["id"].ToInt32());
         new ArquivoBO(arquivo).DeleteUpdate();
         LoadPagina();
         btnRemover.Disabled = btnEditar.Disabled = true;
     }
     catch (Exception ex)
     {
         base.MostrarMensagem("Erro", "Erro ao tentar remover arquivo.", "");
     }
 }
Ejemplo n.º 5
0
        private void PreencherCamposArquivo(DirectEventArgs e)
        {
            ArquivoSelecionado = new ArquivoBO().SelectById(e.ExtraParams["id"].ToInt32());
            TipoSelecionado = ArquivoSelecionado.Tipo;
            CarregarTipos(TipoSelecionado);

            txtNomeArquivo.Text = ArquivoSelecionado.Nome;
            txtDescricaoArquivo.Text = ArquivoSelecionado.Descricao;
            cboTipo.SetValue(TipoSelecionado.Id);
            fufArquivo.Disabled = true;
            fufArquivo.AllowBlank = true;
        }
Ejemplo n.º 6
0
 private void DownloadArquivo(DirectEventArgs e)
 {
     ArquivoVO arquivo = new ArquivoBO().SelectById(e.ExtraParams["id"].ToInt32());
     String caminho = Path.Combine(Server.MapPath("~/BancoArquivos"), arquivo.Id + arquivo.Extensao);
     FileInfo file = new FileInfo(caminho);
     if (file.Exists)
     {
         Response.Clear();
         Response.ContentType = "application/octet-stream";
         Response.AddHeader("Content-Disposition", "attachment;filename=" + arquivo.NomeOriginal);
         Response.AddHeader("Content-Length", file.Length.ToString());
         Response.Flush();
         Response.WriteFile(caminho);
     }
 }
Ejemplo n.º 7
0
        private void dgvMetodos_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && dgvMetodos.Rows[e.RowIndex].Cells["coluna1"].Value != null)
            {
                ArquivoBO arquivoBO = new ArquivoBO();
                Arquivo   arquivo   = new Arquivo();

                string nomeMetodo = dgvMetodos.Rows[e.RowIndex].Cells["coluna1"].Value.ToString();

                arquivo = arquivoBO.BuscarArquivoPorNome(nomeMetodo);

                if (arquivo != null)
                {
                    txtNome.Text   = arquivo.Nome;
                    txtUrl.Text    = arquivo.Url_Conexao;
                    cmbMetodo.Text = arquivo.Tipo_Requisicao;

                    if (arquivo.Tipo_Requisicao == MetodosWebService.POST.ToString())
                    {
                        lblBody.Visible = true;
                        rtbBody.Visible = true;
                    }
                    else
                    {
                        lblBody.Visible = false;
                        rtbBody.Visible = false;
                    }

                    if (arquivo.Sem_Autenticacao)
                    {
                        rdbSemAutenticacao.Checked = true;

                        txtHeaderKeyA.Enabled   = false;
                        txtHeaderValueA.Enabled = false;
                        txtHeaderKeyB.Visible   = false;
                        txtHeaderValueB.Visible = false;

                        txtHeaderKeyA.Text   = "";
                        txtHeaderValueA.Text = "";
                    }
                    else if (arquivo.Com_Autenticacao)
                    {
                        rdbUserPass.Checked = true;

                        txtHeaderKeyA.Enabled   = true;
                        txtHeaderValueA.Enabled = true;
                        txtHeaderKeyB.Visible   = false;
                        txtHeaderValueB.Visible = false;

                        txtHeaderKeyA.Text   = arquivo.User_0;
                        txtHeaderValueA.Text = arquivo.Password_0;
                    }
                    else if (arquivo.Autenticacao_Basic)
                    {
                        rdbBasic.Checked = true;

                        txtHeaderKeyA.Enabled   = true;
                        txtHeaderValueA.Enabled = true;
                        txtHeaderKeyB.Visible   = false;
                        txtHeaderValueB.Visible = false;

                        txtHeaderKeyA.Text   = arquivo.User_0;
                        txtHeaderValueA.Text = arquivo.Password_0;
                    }
                    else
                    {
                        rdbHeader.Checked = true;

                        txtHeaderKeyA.Enabled   = true;
                        txtHeaderValueA.Enabled = true;

                        txtHeaderKeyB.Visible   = true;
                        txtHeaderValueB.Visible = true;
                        txtHeaderKeyB.Enabled   = true;
                        txtHeaderValueB.Enabled = true;

                        txtHeaderKeyA.Text   = arquivo.User_0;
                        txtHeaderValueA.Text = arquivo.Password_0;

                        if (!string.IsNullOrEmpty(arquivo.User_1) && !string.IsNullOrEmpty(arquivo.Password_1))
                        {
                            txtHeaderKeyB.Text   = arquivo.User_1;
                            txtHeaderValueB.Text = arquivo.Password_1;
                        }
                    }

                    txtContent.Text = arquivo.Content_Type;
                    txtAgent.Text   = arquivo.User_Agent;

                    this.BuscarDadosWebService();
                }
            }
        }