Ejemplo n.º 1
0
        private Pasta GetPastaProjeto(Solucao solucao)
        {
            var pasta = new Pasta(this.NomeProjeto);

            pasta.AddArquivo(new ArquivoVbProj(this));
            return(pasta);
        }
Ejemplo n.º 2
0
    protected void btnGravarSolucao_Click(object sender, EventArgs e)
    {
        bool podeGravar = true;

        if (txtTitulo.Value.Equals(""))
        {
            formTitulo.Attributes["class"] = "form-group has-error";
            helpBlockTitulo.InnerText      = "Título é preenchimento obrigatório";
            podeGravar = false;
        }
        if (txtDescricao.Value.Equals(""))
        {
            formDescricao.Attributes["class"] = "form-group has-error";
            helpBlockDescricao.InnerText      = "Descrição é preenchimento obrigatório";
            podeGravar = false;
        }

        if (podeGravar)
        {
            Solucao solucao = new Solucao();
            solucao.Nome       = txtTitulo.Value;
            solucao.Descricao  = txtDescricao.Value;
            solucao.Link       = txtUrl.Value;
            solucao.IdProblema = int.Parse(selProblema.SelectedValue);
            if (solucao.Inserir())
            {
                alerta.Attributes["class"] = "alert alert-success bottom20"; alerta.InnerText = "Solução Cadastrada com Sucesso."; txtTitulo.Value = ""; txtDescricao.Value = ""; txtUrl.Value = ""; carregarSolucoes(solucao.IdProblema);
            }
            else
            {
                alerta.Attributes["class"] = "alert alert-danger bottom20"; alerta.InnerText = solucao.message;
            }
        }
    }
        public bool delete(string id)
        {
            Solucao tmp = new Solucao();

            tmp.id = id;
            return(daoSolucao.delete(tmp));
        }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int     codigoSolucao;
        int     codigoProblema;
        Solucao solucao = new Solucao();

        try
        {
            codigoSolucao      = int.Parse(Request["s"]);
            codigoProblema     = int.Parse(Request["p"]);
            solucao.Id         = codigoSolucao;
            solucao.IdProblema = codigoProblema;
            if (solucao.apagar())
            {
                solucao.message = "DEL-SOL-OK";
                //agora que apagou a solucao, tem que apagar os arquivos também
                string caminho = Server.MapPath("~/img/problemas/" + solucao.IdProblema + "/" + solucao.Id);
                if (System.IO.Directory.Exists(caminho))
                {
                    foreach (string arquivoImagem in System.IO.Directory.GetFiles(caminho))
                    {
                        System.IO.File.Delete(arquivoImagem);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            solucao.message = ex.Message;
        }
        Response.Write(solucao.message);
    }
Ejemplo n.º 5
0
    private void carregarSolucoes(int codigoProblema)
    {
        sectionSolucoes.Controls.Clear();
        List <Solucao> solucoes = Solucao.carregarSolucoes(codigoProblema);

        foreach (Solucao solucao in solucoes)
        {
            Panel panel  = new Panel();
            Panel coluna = new Panel();
            HtmlGenericControl header = new HtmlGenericControl("h3");
            HtmlGenericControl texto  = new HtmlGenericControl("p");
            HyperLink          link   = new HyperLink();

            header.InnerText = solucao.Nome;
            texto.InnerText  = solucao.Descricao;
            link.NavigateUrl = solucao.Link;
            link.Text        = solucao.Link;

            panel.CssClass            = "col-md-3 text-center bottom20";
            coluna.CssClass           = "col-md-12 caixaFancy";
            texto.Attributes["class"] = "lead";

            coluna.Controls.Add(header);
            coluna.Controls.Add(texto);
            coluna.Controls.Add(link);
            panel.Controls.Add(coluna);

            sectionSolucoes.Controls.Add(panel);
        }
    }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            int numeroDeExecucoes = 50;

            for (int i = 0; i < numeroDeExecucoes; i++)
            {
                AlgoritmoGeneticoImpl ga = new AlgoritmoGeneticoImpl();

                for (int j = 0; j < ga.NUMERO_GERACOES; j++)
                {
                    ga.ProximaGeracao();
                    ga.RealizaCruzamento();
                    ga.RealizaMutacao();
                }

                /*
                 * Trecho de código para imprimir solução da execução
                 *
                 * **/
                Solucao melhorSolucao = ga.Populacao[0];

                ga.Populacao.ForEach(x =>
                {
                    if (melhorSolucao.Fitness < x.Fitness)
                    {
                        melhorSolucao = x;
                    }
                });
                Console.WriteLine(String.Format("Execução {0}: {1}", i + 1, melhorSolucao.ToString()));
            }

            Console.ReadKey();
        }
Ejemplo n.º 7
0
    private void carregarSolucoes(int codigoProblema)
    {
        //mostra todas as soluções do problema
        sectionSolucoes.Controls.Clear();
        List <Solucao> solucoes = Solucao.carregarSolucoes(codigoProblema);

        foreach (Solucao solucao in solucoes)
        {
            Panel panel  = new Panel();
            Panel coluna = new Panel();
            HtmlGenericControl header = new HtmlGenericControl("h3");
            HtmlGenericControl texto  = new HtmlGenericControl("p");
            HyperLink          link   = new HyperLink();

            header.InnerText = solucao.Nome;
            texto.InnerText  = solucao.Descricao;
            link.NavigateUrl = solucao.Link;
            link.Text        = solucao.Link;

            panel.CssClass            = "col-md-3 text-center bottom20";
            coluna.CssClass           = "col-md-12 caixaFancy";
            texto.Attributes["class"] = "lead";

            coluna.Controls.Add(header);
            coluna.Controls.Add(texto);
            coluna.Controls.Add(link);
            panel.Controls.Add(coluna);

            sectionSolucoes.Controls.Add(panel);

            //aproveita para carregar o dropdownlist também
            selSolucoes.Items.Add(new ListItem(solucao.Nome, solucao.Id.ToString()));
        }
    }
Ejemplo n.º 8
0
    public static List <Solucao> carregarSolucoes(int codigoProblema)
    {
        List <Solucao> solucoes = new List <Solucao>();

        try
        {
            string        conexao = System.Configuration.ConfigurationManager.AppSettings["conexao"];
            SqlConnection conn    = new SqlConnection(conexao);
            conn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection  = conn;
            cmd.CommandText = "select s.id_solucao , s.nome, s.link_acesso, s.descricao_solucao from tbl_problema_solucao ps inner join tbl_solucao s on s.id_solucao = ps.id_solucao where ps.id_problema = " + codigoProblema + " order by s.id_solucao ";
            SqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                Solucao solucao = new Solucao();
                solucao.Id        = reader.GetInt32(0);
                solucao.Nome      = reader.GetString(1);
                solucao.Link      = reader.GetString(2);
                solucao.Descricao = reader.GetString(3);
                solucoes.Add(solucao);
            }
            reader.Close();
            cmd.Dispose();
            conn.Close();
        }
        catch
        {
        }
        return(solucoes);
    }
Ejemplo n.º 9
0
        public async Task <IActionResult> PutSolucao(int id, Solucao solucao)
        {
            if (id != solucao.Id)
            {
                return(BadRequest());
            }

            _context.Entry(solucao).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SolucaoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 10
0
        public async Task <ActionResult <Solucao> > PostSolucao(Solucao solucao)
        {
            _context.Solucoes.Add(solucao);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSolucao", new { id = solucao.Id }, solucao));
        }
Ejemplo n.º 11
0
 public IActionResult CadastrarSolucao([FromBody] Solucao solucao)
 {
     _solucaoDao.Save(solucao);
     return(Json(
                new {
         Status = "ok",
         Mensagem = "Empresa cadastrada com sucesso!"
     }));
 }
Ejemplo n.º 12
0
        // GET: Solucoes/Delete/5
        public ActionResult Eliminar(int id, int desafio)
        {
            Solucao solucao  = db.Solucoes.Find(id);
            var     desafioQ = db.Votos.RemoveRange(db.Votos.Where(d => d.solucao.SolucaoId == id));

            db.SaveChanges();
            db.Solucoes.Remove(solucao);
            db.SaveChanges();
            return(RedirectToAction("Details", "Desafios", new { id = solucao.DesafioId }));
        }
Ejemplo n.º 13
0
        public Solucao GetSolucao(ParametrosGeracao parametrosGeracao)
        {
            var solucao = new Solucao(parametrosGeracao.ConfigSolucao);

            solucao.Entidades = DefinirTiposAtributos(parametrosGeracao);
            solucao.Projetos.Add(GetProjetoBD(parametrosGeracao, solucao));
            solucao.Projetos.Add(GetProjetoDAL(parametrosGeracao, solucao));
            solucao.Projetos.Add(GetProjetoWeb(parametrosGeracao, solucao));
            return(solucao);
        }
Ejemplo n.º 14
0
        public ProjetoBD(Solucao solucao)
        {
            this.NomeProjeto     = solucao.GetNomeSolucao() + ".BD";
            this.ExtensaoProjeto = ".sqlproj";
            this.GuIdTipoProjeto = "00D1A9C2-B5F0-4AF3-8072-F6C62B433612";
            this.GuIdProjeto     = Guid.NewGuid().ToString();

            this.Pastas = new List <Pasta>();
            this.Pastas.Add(this.GetPastaProjeto(solucao));
        }
Ejemplo n.º 15
0
        private Pasta GetPastaProjeto(Solucao solucao)
        {
            var pasta = new Pasta(this.NomeProjeto);

            pasta.AddSubPasta(this.GetPastaTabelas(solucao));
            pasta.AddSubPasta(this.GetPastaProcedure(solucao));

            pasta.AddArquivo(new ArquivoSqlProj(this));
            return(pasta);
        }
Ejemplo n.º 16
0
        public ProjetoDAL(Solucao solucao)
        {
            this.NomeProjeto     = solucao.GetNomeSolucao() + ".DAL";
            this.ExtensaoProjeto = ".vbproj";
            this.GuIdTipoProjeto = "F184B08F-C81C-45F6-A57F-5ABD9991F28F";
            this.GuIdProjeto     = Guid.NewGuid().ToString();

            this.Pastas = new List <Pasta>();
            this.Pastas.Add(this.GetPastaProjeto(solucao));
        }
Ejemplo n.º 17
0
        private Pasta GetPastaProcedure(Solucao solucao)
        {
            var pasta = new Pasta("Procedures");

            foreach (var entidade in solucao.Entidades)
            {
                pasta.AddSubPasta(this.GetPastaProceduresEntidade(entidade));
            }

            return(pasta);
        }
Ejemplo n.º 18
0
        private Pasta GetPastaTabelas(Solucao solucao)
        {
            var pasta = new Pasta("Tabelas");

            foreach (var entidade in solucao.Entidades)
            {
                pasta.AddArquivo(new ArquivoTabela(entidade));
            }

            return(pasta);
        }
Ejemplo n.º 19
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            OrdemDeLiberacao.Config(modelBuilder);
            Perfil.Config(modelBuilder);
            Projeto.Config(modelBuilder);
            ProjetoAfetado.Config(modelBuilder);
            Requisicao.Config(modelBuilder);
            Solucao.Config(modelBuilder);
            Usuario.Config(modelBuilder);

            Seed(modelBuilder);
        }
Ejemplo n.º 20
0
        public IActionResult CadastrarSolucaoPorEmpresa([FromBody] Empresa empresa, Solucao solucao)
        {
            EmpresaSolucao empresaSolucao = new EmpresaSolucao();

            empresaSolucao.Empresa = empresa;
            empresaSolucao.Solucao = solucao;

            _empsolDao.Save(empresaSolucao);

            return(Json(
                       new { Status = "Ok", Mensagem = "EmpresaSolucao cadastrada!" }));
        }
Ejemplo n.º 21
0
        private Projeto GetProjetoWeb(ParametrosGeracao parametrosGeracao, Solucao solucao)
        {
            if (parametrosGeracao.LinguagemGeracao == LinguagemGeracao.CSharp)
            {
            }

            if (parametrosGeracao.LinguagemGeracao == LinguagemGeracao.VisualBasic)
            {
                var projeto = new Domain.VisualBasic.ProjetoWeb.ProjetoWeb(solucao);
                return(projeto);
            }

            return(null);
        }
Ejemplo n.º 22
0
        public ActionResult Create(SolucaoDesafio SolucaoDesafio, HttpPostedFileBase file)
        {
            string extensao = Path.GetExtension(file.FileName);

            if (file == null)
            {
                ModelState.AddModelError("ErroFicheiro2", "Tem que Submeter pelo menos um ficheiro");
            }

            if (file != null)
            {
                int indexOf = file.ContentType.IndexOf("zip");
                if (extensao != ".zip")
                {
                    ModelState.AddModelError("Zip2", "Compacte os ficheiros e envie em formato .Zip");
                }
            }

            if (ModelState.IsValid)
            {
                var Solucao = new Solucao();
                Solucao.DesafioId         = SolucaoDesafio.IdDesafio;
                Solucao.Descricao         = SolucaoDesafio.DescricaoSolucao;
                Solucao.SolucaoTitulo     = SolucaoDesafio.NomeSolucao;
                Solucao.ApplicationUserId = User.Identity.GetUserId();
                Solucao.DataCriacao       = DateTime.Now;
                db.Solucoes.Add(Solucao);

                db.SaveChanges();

                #pragma warning disable CS0162 // Unreachable code detected
                if (file.ContentLength > 0)
                {
                    Anexo anexo = new Anexo();

                    string filePath = Path.Combine(HttpContext.Server.MapPath("~/Anexos/"),
                                                   Path.GetFileName(file.FileName));
                    file.SaveAs(filePath);
                    anexo.Caminho      = filePath;
                    anexo.SolucaoId    = Solucao.SolucaoId;
                    anexo.NomeFicheiro = file.FileName;
                    db.Anexos.Add(anexo);

                    db.SaveChanges();

                    return(RedirectToAction("Details", "Desafios", new { id = SolucaoDesafio.IdDesafio }));
                }
            }
            return(View(SolucaoDesafio));
        }
Ejemplo n.º 23
0
        private Pasta GetPastaProjeto(Solucao solucao)
        {
            var pasta = new Pasta(this.NomeProjeto);

            pasta.AddSubPasta(this.GetPastaDelegates());
            pasta.AddSubPasta(this.GetPastaGeral());
            pasta.AddSubPasta(this.GetPastaInterface());

            foreach (var entidade in solucao.Entidades)
            {
                pasta.AddArquivo(new ArquivoEntidade(entidade));
            }

            pasta.AddArquivo(new ArquivoVbProj(this));
            return(pasta);
        }
Ejemplo n.º 24
0
 public bool delete(Solucao modelo)
 {
     if (this.search("id", modelo.id).Count() > 0)
     {
         ConnectionFactory cf    = new ConnectionFactory();
         MySqlConnection   conex = cf.database();
         MySqlCommand      sql   = new MySqlCommand();
         sql.Connection  = conex;
         sql.CommandText = "delete from solucao where id = @id";
         sql.Parameters.AddWithValue("@id", modelo.id);
         return(sql.ExecuteNonQuery() == 1);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 25
0
 void Atualiza()
 {
     ScrollBar.SetActive(Enter);
     Criando.SetActive(!Enter);
     Solucao.SetActive(telas == Telas.Fim);
     Caminhos.SetActive(telas == Telas.Arestas);
     Cidades.SetActive(telas == Telas.Rota);
     Notf.SetActive(NaoChega && telas == Telas.IA);
     if (telas != Telas.Fim)
     {
         janeMatriz = JaneMatriz.Nenhum;
     }
     Matriz.SetActive(janeMatriz == JaneMatriz.MAtriz);
     DistanciaAndada.SetActive(janeMatriz == JaneMatriz.Rota);
     stgAresta      = "para começar\nColoque os caminhos.\nNumero de arestas  " + NumeroAresta + ". Resta(m):  " + (NUmeroMaxAresta - NumeroAresta);
     ArestaTxt.text = stgAresta;
 }
        public void RealizaCruzamento()
        {
            int    numeroDeCruzamentos = (int)((POPULACAO_TAMANHO / 2) * TAXA_REPRODUCAO) * 2;
            double SomatorioFitness    = Populacao.Sum(x => x.Fitness);

            for (int i = 0; i < numeroDeCruzamentos; i += 2)
            {
                int P1 = SelecionarRoleta(SomatorioFitness);
                int P2 = SelecionarRoleta(SomatorioFitness);

                Solucao F1 = null;
                Solucao F2 = null;

                Cruzar(Populacao[P1], Populacao[P2], ref F1, ref F2);
                Descendentes.Add(F1);
                Descendentes.Add(F2);
            }
        }
Ejemplo n.º 27
0
 public bool update(Solucao modelo)
 {
     if (this.search("id", modelo.id).Count() <= 0)
     {
         return(false);
     }
     else
     {
         ConnectionFactory cf    = new ConnectionFactory();
         MySqlConnection   conex = cf.database();
         MySqlCommand      sql   = new MySqlCommand();
         sql.Connection  = conex;
         sql.CommandText = "update solucao set nome = @nome, descricao = @descricao where id = @id";
         sql.Parameters.AddWithValue("@id", modelo.id);
         sql.Parameters.AddWithValue("@nome", modelo.nome);
         sql.Parameters.AddWithValue("@descricao", modelo.descricao);
         return(sql.ExecuteNonQuery() == 1);
     }
 }
Ejemplo n.º 28
0
 public bool add(Solucao modelo)
 {
     if (this.search("id", modelo.id).Count() > 0)
     {
         return(false);
     }
     else
     {
         ConnectionFactory cf    = new ConnectionFactory();
         MySqlConnection   conex = cf.database();
         MySqlCommand      sql   = new MySqlCommand();
         sql.Connection  = conex;
         sql.CommandText = "insert into solucao (id, nome, descricao) values (@id, @nome, @descricao)";
         sql.Parameters.AddWithValue("@id", modelo.id);
         sql.Parameters.AddWithValue("@nome", modelo.nome);
         sql.Parameters.AddWithValue("@descricao", modelo.descricao);
         return(sql.ExecuteNonQuery() == 1);
     }
 }
Ejemplo n.º 29
0
        public List <Solucao> listaSolucao(string problema)
        {
            ConnectionFactory cf    = new ConnectionFactory();
            MySqlConnection   conex = cf.database();
            MySqlCommand      sql   = new MySqlCommand("select solucao from problemaSolucao where problema = @problema", conex);

            sql.Parameters.AddWithValue("@problema", problema);
            DataTable        data = new DataTable();
            MySqlDataAdapter dta  = new MySqlDataAdapter(sql);

            dta.Fill(data);
            List <Solucao>    solucoes = new List <Solucao>();
            SolucaoController solC     = new SolucaoController();

            for (int x = 0; x < data.Rows.Count; x++)
            {
                Solucao solucao = solC.search("id", data.Rows[x]["solucao"].ToString())[0];
                solucoes.Add(solucao);
            }
            return(solucoes);
        }
Ejemplo n.º 30
0
        public List <Solucao> all()
        {
            ConnectionFactory cf    = new ConnectionFactory();
            MySqlConnection   conex = cf.database();
            MySqlCommand      sql   = new MySqlCommand("select * from solucao", conex);
            DataTable         data  = new DataTable();
            MySqlDataAdapter  dta   = new MySqlDataAdapter(sql);

            dta.Fill(data);
            List <Solucao> solucoes = new List <Solucao>();

            for (int x = 0; x < data.Rows.Count; x++)
            {
                string id        = data.Rows[x]["id"].ToString();
                string nome      = data.Rows[x]["nome"].ToString();
                string descricao = data.Rows[x]["descricao"].ToString();

                Solucao solucao = new Solucao(id, nome, descricao);
                solucoes.Add(solucao);
            }
            return(solucoes);
        }