Exemplo n.º 1
0
 /// <summary>
 /// Click no botão ligar
 /// </summary>
 private void Ligar_SimpleButton_Click(object sender, EventArgs e)
 {
     isPause = false;
     if (Context.PreConfigurada == 0)
     {
         if (isPotencia)
         {
             Context.Potencia    = Context.Visor;
             Context             = ModeloController.ValidarPotencia(Context);
             Visor_MemoEdit.Text = Context.Visor;
             Resetar();
         }
         else if (isTempo || int.TryParse(Context.Visor, out int tmpTempo))
         {
             Context.Tempo       = Context.Visor;
             Context             = ModeloController.ValidarTempo(Context);
             Visor_MemoEdit.Text = Context.Visor;
             Resetar();
         }
         else
         {
             Context = ModeloController.Validar(Context);
             Aquecendo();
         }
     }
     else
     {
         Context = ModeloController.ValidarPreConfiguradas(Context);
         Aquecendo();
     }
 }
Exemplo n.º 2
0
        private void Iniciar(string pontuacao = ".", ProgramaModel programa = null)
        {
            try
            {
                var microondas = new MicroondasModel()
                {
                    Bandeja   = txtBandeja.Text,
                    TempoMin  = Decimal.ToInt32(numTempoMin.Value),
                    TempoSeg  = Decimal.ToInt32(numTempoSeg.Value),
                    Potencia  = Decimal.ToInt32(numPotencia.Value),
                    Pontuacao = pontuacao
                };
                numTempoMin.Value = microondas.TempoMinInteger;
                numTempoSeg.Value = microondas.TempoSegInteger;
                numPotencia.Value = microondas.PotenciaInteger;

                //se for programação, verificar a compatibildade do alimento da bandeja
                if (programa != null)
                {
                    this._programaBusiness.ValidaCompativel(microondas, programa);
                }

                this._business.Inicia(microondas);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }
Exemplo n.º 3
0
        public void SetaMicroondas(MicroondasModel microondas)
        {
            this._microondas = microondas;

            //se for arquivo arrumar o conteudo dele antes de validar
            if (this._microondas.Arquivo)
            {
                this.SetaResultado(string.Empty);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Valida dados baseado no Model preenchido
 /// </summary>
 internal static MicroondasModel Validar(MicroondasModel Context)
 {
     if (string.IsNullOrEmpty(Context.Tempo))
     {
         Context.Tempo = "30";
     }
     if (string.IsNullOrEmpty(Context.Potencia))
     {
         Context.Potencia = "8";
     }
     Context.Visor = "AQUECENDO!!!";
     return(Context);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Valida tempo baseado no Model preenchido
 /// </summary>
 internal static MicroondasModel ValidarTempo(MicroondasModel Context)
 {
     Int32.TryParse(Context.Tempo, out int Tempo);
     if (Tempo == 0 || Tempo > 120)
     {
         Context.Tempo = string.Empty;
         Context.Visor = "O tempo não pode ser 0 ou acima de 120!";
         return(Context);
     }
     else
     {
         Context.Visor = "Tempo Salvo!";
         return(Context);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Valida potência baseado no Model preenchidom
 /// </summary>
 internal static MicroondasModel ValidarPotencia(MicroondasModel Context)
 {
     Int32.TryParse(Context.Potencia, out int Potencia);
     if (Potencia == 0 || Potencia > 10)
     {
         Context.Potencia = string.Empty;
         Context.Visor    = "A potência deve ser maior que 0 e menor que 10!";
         return(Context);
     }
     else
     {
         Context.Visor = "Potência Salva!";
         return(Context);
     }
 }
Exemplo n.º 7
0
        public List <ProgramaModel> BuscaCompativel(MicroondasModel microondas)
        {
            this._microondasBusiness.SetaMicroondas(microondas);
            this.Valida(microondas);

            List <ProgramaModel> returnList = new List <ProgramaModel>();

            var querySearch = microondas.Arquivo ? _microondasBusiness.BuscaResultadoLinha1() : microondas.Bandeja;

            var searchList = querySearch.ToLower().Split(' ');

            searchList.ToList().ForEach(search =>
            {
                returnList.AddRange(_data.BuscaTodos().Where(p => p.TagList.Any(t => t == search)));
            });

            return(returnList);
        }
Exemplo n.º 8
0
        public void Valida(MicroondasModel microondas)
        {
            if (string.IsNullOrEmpty(microondas.Bandeja))
            {
                throw new Exception(ResourceStringUtil.BandejaNula);
            }

            //verifica se é arquivo de texto e se arquivo existe
            if (microondas.Arquivo)
            {
                if (!File.Exists(microondas.Bandeja))
                {
                    throw new Exception(ResourceStringUtil.ArquivoNaoEncontrado);
                }

                var alimentoBandeja = _microondasBusiness.BuscaResultadoLinha1();
                if (string.IsNullOrEmpty(alimentoBandeja.Trim()))
                {
                    throw new Exception(ResourceStringUtil.ArquivoBandejaNula);
                }
            }
        }
Exemplo n.º 9
0
        public void ValidaCompativel(MicroondasModel microondas, ProgramaModel programa)
        {
            this._microondasBusiness.SetaMicroondas(microondas);
            this.Valida(microondas);
            bool compativel = false;

            var querySearch = microondas.Arquivo ? _microondasBusiness.BuscaResultadoLinha1() : microondas.Bandeja;

            var searchList = querySearch.ToLower().Split(' ');

            searchList.ToList().ForEach(search =>
            {
                if (programa.TagList.Any(t => t == search))
                {
                    compativel = true;
                }
            });

            if (!compativel)
            {
                throw new Exception(ResourceStringUtil.ProgramaAlimentoNaoCompativel);
            }
        }
Exemplo n.º 10
0
        internal static MicroondasModel ValidarPreConfiguradas(MicroondasModel Context)
        {
            switch (Context.PreConfigurada)
            {
            case (int)Enumerador.PreConfiguradas.Frango:
                Context.Potencia = new PreConfiguradas().PotenciaFrango;
                Context.Tempo    = new PreConfiguradas().TempoFrango;
                break;

            case (int)Enumerador.PreConfiguradas.Lasanha:
                Context.Potencia = new PreConfiguradas().PotenciaLasanha;
                Context.Tempo    = new PreConfiguradas().TempoLasanha;
                break;

            case (int)Enumerador.PreConfiguradas.Pizza:
                Context.Potencia = new PreConfiguradas().PotenciaPizza;
                Context.Tempo    = new PreConfiguradas().TempoPizza;
                break;

            case (int)Enumerador.PreConfiguradas.Arroz:
                Context.Potencia = new PreConfiguradas().PotenciaArroz;
                Context.Tempo    = new PreConfiguradas().TempoArroz;
                break;

            case (int)Enumerador.PreConfiguradas.Batata:
                Context.Potencia = new PreConfiguradas().PotenciaBatata;
                Context.Tempo    = new PreConfiguradas().TempoBatata;
                break;

            case (int)Enumerador.PreConfiguradas.Reaquecer:
                Context.Potencia = new PreConfiguradas().PotenciaReaquecer;
                Context.Tempo    = new PreConfiguradas().TempoReaquecer;
                break;
            }
            Context.Visor = "AQUECENDO!!!";
            return(Context);
        }
Exemplo n.º 11
0
        public void Inicia(MicroondasModel microondas)
        {
            this._tempoCount = 0;
            this.SetaMicroondas(microondas);

            //validar entradas
            if (!this.Valida(microondas))
            {
                return;
            }

            //se não for aquivo seta a bandeja no resultado
            if (!this._microondas.Arquivo)
            {
                this.SetaResultado(microondas.Bandeja);
            }
            else
            {
                this.SetaResultado(this.BuscaResultadoLinha1());
            }

            this._microondas.Status = Entities.Enums.MicroondasStatusEnum.Executando;
            this._tempoMicroondas.Start();
        }
Exemplo n.º 12
0
        public bool Valida(MicroondasModel microondas, bool simples = false)
        {
            if (string.IsNullOrEmpty(microondas.Bandeja))
            {
                ErroEvent(ResourceStringUtil.BandejaNula, EventArgs.Empty);
                return(false);
            }

            //verifica se é arquivo de texto e se arquivo existe
            if (microondas.Arquivo)
            {
                if (!File.Exists(microondas.Bandeja))
                {
                    ErroEvent(ResourceStringUtil.ArquivoNaoEncontrado, EventArgs.Empty);
                    return(false);
                }

                var alimentoBandeja = this.BuscaResultadoLinha1();
                if (string.IsNullOrEmpty(alimentoBandeja.Trim()))
                {
                    ErroEvent(ResourceStringUtil.ArquivoBandejaNula, EventArgs.Empty);
                    return(false);
                }
            }

            //Início rápido ou compatibilidade de programa só precisa da validação acima
            if (simples)
            {
                return(true);
            }

            if (microondas.TempoMin == 0 && microondas.TempoSeg == 0)
            {
                ErroEvent(ResourceStringUtil.TempoCozimentoNulo, EventArgs.Empty);
                return(false);
            }

            if (!ValidaUtil.ValidaInt(microondas.TempoMin) || !ValidaUtil.ValidaInt(microondas.TempoSeg))
            {
                ErroEvent(ResourceStringUtil.TempoCozimentoFracionado, EventArgs.Empty);
                return(false);
            }

            if (microondas.Tempo.TotalSeconds > 120 || microondas.Tempo.TotalSeconds < 1)
            {
                ErroEvent(ResourceStringUtil.TempoCozimentoForaIntervalo, EventArgs.Empty);
                return(false);
            }

            if (microondas.Potencia > 10 || microondas.Potencia < 1)
            {
                ErroEvent(ResourceStringUtil.PotenciaForaIntervalo, EventArgs.Empty);
                return(false);
            }

            if (!ValidaUtil.ValidaInt(microondas.Potencia))
            {
                ErroEvent(ResourceStringUtil.PotenciaFracionada, EventArgs.Empty);
                return(false);
            }

            return(true);
        }