Beispiel #1
0
        public ActionResult OnGet(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            try
            {
                client.Headers["Content-type"] = "application/json";
                Stream       data   = client.OpenRead(Program.Baseurl + "/LPT/Experimento/" + id);
                StreamReader reader = new StreamReader(data);
                string       s      = reader.ReadToEnd();
                MemoryStream ms     = new MemoryStream(Encoding.Unicode.GetBytes(s));
                experimento = ser.ReadObject(ms) as Experimento;
                data.Close();
                reader.Close();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
                experimento = new Experimento();
            }

            if (experimento.IdExperimento == 0)
            {
                return(NotFound());
            }

            Page_Title = id + " - Alterar Experimento ";
            return(Page());
        }
 public static void Salvar(Experimento experimento)
 {
     AbstractService.Salvar <Experimento>(experimento, TABELA_Experimento,
                                          $"INSERT INTO {TABELA_Experimento} (Nome, IdLinhaDeBase, Instrucao) VALUES (@Nome, @IdLinhaDeBase, @Instrucao)",
                                          $"UPDATE {TABELA_Experimento} SET Nome = @Nome, IdLinhaDeBase = @IdLinhaDeBase, Instrucao = @Instrucao");
     ExperimentoParaCondicaoService.CreateByExperimento(experimento);
 }
        private async void btnIniciarExperimento_Click(object sender, EventArgs e)
        {
            if (experimentoRealizado.Experimento == null)
            {
                MessageBox.Show("Por favor, selecione um Experimento antes de começar!", "Advertência");
                return;
            }

            experimentoRealizado.NomeParticipante  = textNomeParticipante.Text;
            experimentoRealizado.IdadeParticipante = Convert.ToInt32(numericIdadeParticipante.Value);
            experimentoRealizado.Grupo             = textGrupoParticipante.Text;
            experimentoRealizado.CabineUtilizada   = textCabineUtilizada.Text;

            TelaMensagem telaMensagem = new TelaMensagem("Toque nessa mensagem para iniciar o experimento", false);

            telaMensagem.Show();
            await telaMensagem.GetTask().Task;

            telaMensagem.AlterarPropriedades(experimentoRealizado.Experimento.Instrucao, true);
            telaMensagem.Show();
            await telaMensagem.GetTask().Task;

            telaMensagem.AlterarPropriedades("", false);

            new ExperimentoView(experimentoRealizado).ShowDialog();
            Experimento experimentoAnterior = experimentoRealizado.Experimento;

            experimentoRealizado             = new ExperimentoRealizado();
            experimentoRealizado.Experimento = experimentoAnterior;

            telaMensagem.AlterarPropriedades("Experimento finalizado! Por favor, chamar o(a) experimentador(a).", false);
            telaMensagem.ShowDialog();
            telaMensagem.Close();
        }
Beispiel #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Experimento experimento = db.Experimentos.Find(id);

            db.Experimentos.Remove(experimento);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #5
0
        public static Experimento Map(Experimento experimento, ExperimentDto experimentDto)
        {
            experimento.Id   = experimentDto.Id;
            experimento.Meio = experimentDto.Middle;
            experimento.BOD  = experimentDto.BOD;
            experimento.Lote = experimentDto.Lot;

            return(experimento);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Experimento experimento = await db.Experimentos.FindAsync(id);

            db.Experimentos.Remove(experimento);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Beispiel #7
0
 public ActionResult Edit([Bind(Include = "ID,Nombre,Objetivo")] Experimento experimento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(experimento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(experimento));
 }
 public IActionResult Update(int IdExperimento, [FromBody] Experimento newObject)
 {
     try {
         var c = repositorio.Update(IdExperimento, newObject);
         return(this.Ok(c));
     }
     catch (Exception ex) {
         Console.WriteLine(ex.Message);
         return(BadRequest());
     }
 }
Beispiel #9
0
        public ICommandResult HandlerCreate(CriarExperimentoCommand command)
        {
            try
            {
                AddNotifications(command.Notifications);
                command.Validated();

                //Validar os commands
                if (Invalid)
                {
                    return(new CommandResult(Notifications));
                }

                //Criar os VOs
                var nomeExperimento = new Nome(command.Nome);

                //Criar as entidades
                var experimento = new Experimento(nomeExperimento, command.QtdRepeticao);
                foreach (var tratamentoCommand in command.Tratamento)
                {
                    var tratamento = _tratamentoRepository.GetByIdTracking(Guid.Parse(tratamentoCommand.Id));
                    if (tratamento != null)
                    {
                        experimento.AddTratamento(new ExperimentoTramento(experimento, tratamento));
                    }
                }

                if (command.Status.Equals(ECommandStatus.Aberto))
                {
                    experimento.Arquivar();
                }
                else if (command.Status.Equals(ECommandStatus.EmAdamento))
                {
                    experimento.Gerar();
                }


                //Validar entidades e VOs
                AddNotifications(experimento.Notifications);
                if (Invalid)
                {
                    return(new CommandResult(Notifications));
                }

                //Persistir experimento
                _experimentoRepository.Save(experimento);
                //Retornar o resultado para a tela
                return(new CommandResult(new { Id = experimento.Id, Nome = experimento.Nome.ToString(), Status = experimento.Status }));
            }
            catch (Exception e)
            {
                return(new CommandResult(e));
            }
        }
Beispiel #10
0
        public ActionResult Create([Bind(Include = "ID,Nombre,Objetivo")] Experimento experimento)
        {
            if (ModelState.IsValid)
            {
                db.Experimentos.Add(experimento);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(experimento));
        }
        private void btnSelecionarExperimento_Click(object sender, EventArgs e)
        {
            if (listViewExperimento.SelectedItems.Count == 0)
            {
                MessageBox.Show("Nenhum Experimento selecionado!", "Advertência");
                return;
            }
            Experimento experimento = ExperimentoService.GetById(ViewHelper.GetIdSelecionadoInListView(listViewExperimento));

            experimentoRealizado.Experimento = experimento;
            textExperimentoSelecionado.Text  = experimento.Nome;
        }
 public IActionResult Create([FromBody] Experimento t)
 {
     try {
         var c = repositorio.Create(t);
         Console.WriteLine("ok ");
         return(this.Ok(c));
     }
     catch (Exception) {
         Console.WriteLine("erro");
         return(BadRequest());
     }
 }
        public async Task <ActionResult> Create([Bind(Include = "ExperimentoID,Nombre,Objetivo")] Experimento experimento)
        {
            if (ModelState.IsValid)
            {
                db.Experimentos.Add(experimento);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(experimento));
        }
Beispiel #14
0
 public object Read(int IdExperimento)
 {
     try
     {
         Experimento r = (from p in context.Experimento where p.IdExperimento == IdExperimento select p).FirstOrDefault <Experimento>();
         return(r);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
Beispiel #15
0
 public object ReadLast()
 {
     try
     {
         Experimento r = (from p in context.Experimento where p.DataFim == null orderby p.IdExperimento descending select p).FirstOrDefault <Experimento>();
         return(r);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
        public async Task <ExperimentDto> Execute(ExperimentDto dilutionSampleDto)
        {
            Experimento experiment = ExperimentDtoMapToExperimento.Map(new Experimento(), dilutionSampleDto);

            if (experiment == null)
            {
                throw new AppError("Informe uma solicitação válida.");
            }
            _experimentRepository.Save(experiment);
            await _experimentRepository.Commit();

            return(dilutionSampleDto);
        }
        public static Experimento GetById(long id)
        {
            Experimento experimento = AbstractService.GetById <Experimento>(id, TABELA_Experimento);

            if (experimento == null)
            {
                return(null);
            }

            experimento.Condicoes = ExperimentoParaCondicaoService.GetAllCondicoesByExperimento(experimento);

            return(experimento);
        }
        // GET: Experimento/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Experimento experimento = await db.Experimentos.FindAsync(id);

            if (experimento == null)
            {
                return(HttpNotFound());
            }
            return(View(experimento));
        }
Beispiel #19
0
        // GET: Experimentos/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Experimento experimento = db.Experimentos.Find(id);

            if (experimento == null)
            {
                return(HttpNotFound());
            }
            return(View(experimento));
        }
Beispiel #20
0
        public static List <Condicao> GetAllCondicoesByExperimento(Experimento experimento)
        {
            if (experimento == null)
            {
                return(null);
            }

            using (IDbConnection cnn = new SQLiteConnection(GetConnectionString())) {
                List <ExperimentoParaCondicao> experimentoParaCondicoes = cnn.Query <ExperimentoParaCondicao>("SELECT * FROM ExperimentoParaCondicao WHERE IdExperimento = @Id ORDER BY Ordem", experimento).ToList();

                return(experimentoParaCondicoes.Select(it => {
                    return CondicaoService.GetById(it.IdCondicao);
                }).ToList());
            }
        }
Beispiel #21
0
        public void DeveConter3BlocosCom9PlantasQuandoQtdRepeticaoFor10QuandoGerarAreaExperimento()
        {
            _experimento = new Experimento(_nome, 10);
            var pTomate   = new Tratamento(_tomate);
            var pCebola   = new Tratamento(_cebola);
            var pCeneoura = new Tratamento(_cenoura);

            var experimentoPlantaTomante  = new ExperimentoTramento(_experimento.Id, pTomate.Id);
            var experimentoPlantaCeneoura = new ExperimentoTramento(_experimento.Id, pCeneoura.Id);
            var experimentoPlantaCebola   = new ExperimentoTramento(_experimento.Id, pCebola.Id);

            _experimento.AddTratamento(experimentoPlantaTomante);
            _experimento.AddTratamento(experimentoPlantaCeneoura);
            _experimento.AddTratamento(experimentoPlantaCebola);

            _experimento.GerarAreaExperimento();
            Assert.AreEqual(true, _experimento.Blocos.Count == 10);
            Assert.AreEqual(30, _experimento.Blocos.Sum((x1 => x1.BlocoTratamentos.Count)));
        }
Beispiel #22
0
        public static void CreateByExperimento(Experimento experimento)
        {
            DeleteAllByExperimento(experimento);
            List <Condicao> condicoes = experimento.Condicoes;

            for (int i = 0; i < condicoes.Count; i++)
            {
                var condicao = condicoes[i];
                var experimentoParaCondicao = new ExperimentoParaCondicao {
                    IdCondicao    = condicao.Id,
                    IdExperimento = experimento.Id,
                    Ordem         = i
                };

                using (IDbConnection cnn = new SQLiteConnection(GetConnectionString())) {
                    cnn.Execute("INSERT INTO ExperimentoParaCondicao (IdExperimento, IdCondicao, Ordem) VALUES (@IdExperimento, @IdCondicao, @Ordem)", experimentoParaCondicao);
                }
            }
        }
Beispiel #23
0
 public object Create(object p)
 {
     try
     {
         foreach (var item in (from t in context.Experimento where t.DataFim == null && t.DataInicio != ((Experimento)p).DataInicio select t).ToList <Experimento>())
         {
             item.DataFim = DateTime.Now;
             context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         }
         Experimento r = (context.Experimento.Add((Experimento)p)).Entity;
         context.SaveChanges();
         Program.experimentoAtivo = r.IdExperimento;
         return(r);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
Beispiel #24
0
        public ExperimentoTests()
        {
            _nome    = new Nome("Experimento tomate");
            _tomate  = new Nome("tomate");
            _cebola  = new Nome("cebola");
            _cenoura = new Nome("ceneroura");

            _experimento = new Experimento(_nome, 3);
            var pTomate   = new Tratamento(_tomate);
            var pCebola   = new Tratamento(_cebola);
            var pCeneoura = new Tratamento(_cenoura);

            var experimentoPlantaTomante  = new ExperimentoTramento(_experimento.Id, pTomate.Id);
            var experimentoPlantaCeneoura = new ExperimentoTramento(_experimento.Id, pCeneoura.Id);
            var experimentoPlantaCebola   = new ExperimentoTramento(_experimento.Id, pCebola.Id);


            _experimento.AddTratamento(experimentoPlantaTomante);
            _experimento.AddTratamento(experimentoPlantaCeneoura);
            _experimento.AddTratamento(experimentoPlantaCebola);
        }
Beispiel #25
0
        public async Task <IActionResult> CriarExperimentoTemplete(CriarTempleteViewModel modelo)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Experimento experimento = new Experimento()
                    {
                        Nome      = modelo.Nome,
                        Descricao = modelo.Descricao
                    };



                    if (modelo.Caracteristicas != null)
                    {
                        var selecionadas = modelo.Caracteristicas.Where(car => car.IsChecked == true);
                        if (selecionadas.Count() > 0)
                        {
                            var idExperimento = await _repoExperi.AddExperimento(experimento);

                            TempData["msg"] = "1";
                            foreach (var item in selecionadas)
                            {
                                await _repoExperi.AddGrupoDeDadosParaExp(idExperimento, item.CaracteristicaId).ConfigureAwait(false);
                            }

                            return(RedirectToAction("ConsultarExperimento", "TempleteExperimento", new { IdExperimento = idExperimento }));
                        }
                        ViewBag.SemCaracteristica = _localizador["Necessário ao menos uma caracteristica para o experimento!"].ToString();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            ViewBag.CadatroSucesso = false;
            return(View(modelo));
        }
        public async Task <IList <ExperimentDto> > Execute(int?experimentId, int?sampleDilutionId)
        {
            IList <Experimento>   experiments     = new List <Experimento>();
            IList <ExperimentDto> experimentDtos  = new List <ExperimentDto>();
            DiluicaoAmostra       diluicaoAmostra = new DiluicaoAmostra();

            if (sampleDilutionId > 0)
            {
                diluicaoAmostra = await _diluicaoAmostraRepository.GetByID((int)sampleDilutionId);

                experiments = await _experimentoRepository.Get(x => x.fkDiluicaoAmostraId == diluicaoAmostra.Id);

                foreach (Experimento x in experiments)
                {
                    experimentDtos.Add(ExperimentoMapToExperimentDto.Map(new ExperimentDto(), x));
                }

                return(experimentDtos);
            }


            if (experimentId > 0)
            {
                Experimento experiment = await _experimentoRepository.GetByID((int)experimentId);

                if (experiment != null)
                {
                    experiments.Add(experiment);
                }
            }
            else
            {
                experiments = await _experimentoRepository.Get();
            }
            foreach (Experimento x in experiments)
            {
                experimentDtos.Add(ExperimentoMapToExperimentDto.Map(new ExperimentDto(), x));
            }
            return(experimentDtos.OrderBy(e => e.Id).ToList());
        }
        public ExperimentoView(ExperimentoRealizado experimentoRealizado)
        {
            InitializeComponent();

            this.experimentoRealizado = experimentoRealizado;
            experimento = experimentoRealizado.Experimento;

            experimentoRealizado.DateTimeInicio = DateTime.Now;
            experimentoRealizado.RegistrarEvento(new Evento($"Iniciando o experimento de nome '{experimento.Nome}'", "Inicialização"));

            double heightRatio = height / 1080.0;
            double widthRatio  = width / 1920.0;

            ViewUtils.CorrigeTamanhoEPosicao(panel1, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(panel2, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(panel3, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(Borda1, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(Borda2, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(Borda3, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(Quadrado1, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(Quadrado2, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(Quadrado3, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(label1, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(label2, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(label3, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(labelPontosGanhos, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(labelPontosPerdidos, heightRatio, widthRatio);
            ViewUtils.CorrigeTamanhoEPosicao(labelPontosTotais, heightRatio, widthRatio);

            ViewUtils.CorrigeFonte(label1, heightRatio);
            ViewUtils.CorrigeFonte(label2, heightRatio);
            ViewUtils.CorrigeFonte(label3, heightRatio);
            ViewUtils.CorrigeFonte(labelPontosGanhos, heightRatio);
            ViewUtils.CorrigeFonte(labelPontosPerdidos, heightRatio);
            ViewUtils.CorrigeFonte(labelPontosTotais, heightRatio);

            Opacity = 0;
            ApresentarLinhaDeBase(experimento.LinhaDeBase);
        }
Beispiel #28
0
 public object Update(int IdExperimento, object newObject)
 {
     try
     {
         Experimento r = (from p in context.Experimento where p.IdExperimento == IdExperimento select p).FirstOrDefault <Experimento>();
         foreach (var att in ((Experimento)newObject).GetType().GetProperties())
         {
             if (!att.Name.Equals("IdExperimento"))
             {
                 r.GetType().GetProperty(att.Name).SetValue(r, att.GetValue(newObject));
             }
         }
         context.Entry(r).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         context.SaveChanges();
         return(r);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
Beispiel #29
0
        public async Task <ExperimentDto> Execute(ExperimentDto experimentDto, int?dilutionSampleId)
        {
            if (dilutionSampleId <= 0)
            {
                throw new AppError("Informe uma diluição válida.");
            }
            DiluicaoAmostra dilutionSample = await _dilutionSampleRepository.GetByID((int)dilutionSampleId);

            if (dilutionSample == null)
            {
                throw new AppError("Informe uma diluição válida.");
            }

            Experimento experimento = ExperimentDtoMapToExperimento.Map(new Experimento(), experimentDto);

            experimento.fkDiluicaoAmostra   = dilutionSample;
            experimento.fkDiluicaoAmostraId = dilutionSample.Id;

            _experimentoRepository.Insert(experimento);
            await _experimentoRepository.Commit();

            return(experimentDto);
        }
        public ExperimentoCrud(long idExperimento = 0)
        {
            InitializeComponent();
            CarregarListaLinhaDeBase();
            CarregarListaCondicao();

            if (idExperimento == 0)
            {
                experimento = new Experimento();
                Text        = "Criando novo Experimento";
                return;
            }
            else
            {
                experimento = ExperimentoService.GetById(idExperimento);
            }

            Text                 = "Editando Experimento: " + experimento.Nome;
            textNome.Text        = experimento.Nome;
            textLinhaDeBase.Text = experimento.LinhaDeBase?.Nome;
            textInstrucao.Text   = experimento.Instrucao;
            experimento.Condicoes.ForEach(it => AdicionaCondicaoEscolhida(it));
        }