Example #1
0
        public RetornoProcesso Validar(Mapeamento.Model.Venda venda)
        {
            if (venda.Cliente == null)
                return new RetornoProcesso(false, "Cliente é um campo obrigatório!");

            return new RetornoProcesso(true, "");
        }
Example #2
0
        public RetornoProcesso Remover(Mapeamento.Model.Cliente cliente)
        {
            try
            {
                _repCliente.Excluir(cliente);

                return new RetornoProcesso(true, "Cliente removido com sucesso!");
            }
            catch (Exception ex)
            {
                return new RetornoProcesso(false, ex.Message);
            }
        }
Example #3
0
        public RetornoProcesso Remover(Mapeamento.Model.Produto produto)
        {
            try
            {
                _repProduto.Excluir(produto);

                return new RetornoProcesso(true, "Produto removido com sucesso!");
            }
            catch (Exception ex)
            {
                return new RetornoProcesso(false, ex.Message);
            }
        }
Example #4
0
        public RetornoProcesso Remover(Mapeamento.Model.Base.Animal animal, Vacina vacina)
        {
            try
            {
                animal.Carteirinha.Vacinas.Remove(vacina);
                _repVacina.Excluir(vacina);

                return new RetornoProcesso(true, "Vacina removida com sucesso!");
            }
            catch (Exception ex)
            {
                return new RetornoProcesso(false, ex.Message);
            }
        }
Example #5
0
        public IList<Vacina> Consultar(string descricao, Mapeamento.Model.Base.Animal animal)
        {
            try
            {
                var vacinas =
                    _repVacina.Pesquisar(p => p.Descricao.Contains(!string.IsNullOrWhiteSpace(descricao) ? descricao : p.Descricao) &&
                                              p.Carteirinha.Animal.Id == (animal != null ? animal.Id : p.Carteirinha.Animal.Id))
                              .OrderBy(o => o.Id)
                              .ToList();

                return vacinas;
            }
            catch (Exception)
            {
                return null;
            }
        }
        public RetornoProcesso Alterar(Mapeamento.Model.Funcionario funcionario)
        {
            try
            {
                var validacao = Validar(funcionario);
                if (!validacao.Sucesso)
                    return validacao;

                _repFuncionario.Alterar(funcionario);

                return new RetornoProcesso(true, "Funcionário alterado com sucesso!");
            }
            catch (Exception ex)
            {
                return new RetornoProcesso(false, ex.Message);
            }
        }
Example #7
0
        public RetornoProcesso Inserir(Mapeamento.Model.Cliente cliente)
        {
            try
            {
                var validacao = Validar(cliente);
                if (!validacao.Sucesso)
                    return validacao;

                _repCliente.Incluir(cliente);

                return new RetornoProcesso(true, "Cliente inserido com sucesso!");
            }
            catch (Exception ex)
            {
                return new RetornoProcesso(false, ex.Message);
            }
        }
Example #8
0
        public RetornoProcesso Inserir(Mapeamento.Model.Produto produto)
        {
            try
            {
                var validacao = Validar(produto);
                if (!validacao.Sucesso)
                    return validacao;

                _repProduto.Incluir(produto);

                return new RetornoProcesso(true, "Produto inserido com sucesso!");
            }
            catch (Exception ex)
            {
                return new RetornoProcesso(false, ex.Message);
            }
        }
Example #9
0
        public RetornoProcesso Inserir(Mapeamento.Model.Venda venda)
        {
            try
            {
                var validacao = Validar(venda);
                if (!validacao.Sucesso)
                    return validacao;

                venda.CalcularPreco();
                _repVenda.Incluir(venda);

                return new RetornoProcesso(true, "Venda efetuada com sucesso!");
            }
            catch (Exception ex)
            {
                return new RetornoProcesso(false, ex.Message);
            }
        }
Example #10
0
 public void Faturar(Mapeamento.Model.Venda venda)
 {
     venda.Faturada = true;
     _repVenda.Alterar(venda);
 }
Example #11
0
 public ItemPerdidoControllerTest()
 {
     service    = new ItemPerdidoServiceFake();
     controller = new ItemPerdidoController(service, Mapeamento.Criar());
 }
Example #12
0
        public RetornoProcesso Validar(Mapeamento.Model.Cliente cliente)
        {
            if (string.IsNullOrWhiteSpace(cliente.Nome))
                return new RetornoProcesso(false, "Nome é um campo obrigatório!");

            if (!cliente.DataNascimento.HasValue)
                return new RetornoProcesso(false, "Data de Nascimento é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(cliente.Cep))
                return new RetornoProcesso(false, "CEP é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(cliente.Logradouro))
                return new RetornoProcesso(false, "Logradouro é um campo obrigatório!");

            if (!cliente.Numero.HasValue)
                return new RetornoProcesso(false, "Número é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(cliente.Bairro))
                return new RetornoProcesso(false, "Bairro é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(cliente.Cidade))
                return new RetornoProcesso(false, "Cidade é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(cliente.Estado))
                return new RetornoProcesso(false, "Estado é um campo obrigatório!");

            if ((string.IsNullOrWhiteSpace(cliente.Telefone) || string.Equals(cliente.Telefone, "(__) ____-____")) &&
                (string.IsNullOrWhiteSpace(cliente.Celular) || string.Equals(cliente.Celular, "(__) ____-____")))
                return new RetornoProcesso(false, "Algum telefone para contato deve ser informado!");

            return new RetornoProcesso(true, "");
        }
        public RetornoProcesso Validar(Mapeamento.Model.Funcionario funcionario)
        {
            if (string.IsNullOrWhiteSpace(funcionario.Nome))
                return new RetornoProcesso(false, "Nome é um campo obrigatório!");

            if (!funcionario.DataNascimento.HasValue)
                return new RetornoProcesso(false, "Data de Nascimento é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(funcionario.Cep))
                return new RetornoProcesso(false, "CEP é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(funcionario.Logradouro))
                return new RetornoProcesso(false, "Logradouro é um campo obrigatório!");

            if (!funcionario.Numero.HasValue)
                return new RetornoProcesso(false, "Número é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(funcionario.Bairro))
                return new RetornoProcesso(false, "Bairro é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(funcionario.Cidade))
                return new RetornoProcesso(false, "Cidade é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(funcionario.Estado))
                return new RetornoProcesso(false, "Estado é um campo obrigatório!");

            if ((string.IsNullOrWhiteSpace(funcionario.Telefone) || string.Equals(funcionario.Telefone, "(__) ____-____")) &&
                (string.IsNullOrWhiteSpace(funcionario.Celular) || string.Equals(funcionario.Celular, "(__) ____-____")))
                return new RetornoProcesso(false, "Algum telefone para contato deve ser informado!");

            if (string.IsNullOrWhiteSpace(funcionario.Usuario))
                return new RetornoProcesso(false, "Usuário é um campo obrigatório!");

            if (string.IsNullOrWhiteSpace(funcionario.Senha))
                return new RetornoProcesso(false, "Senha é um campo obrigatório!");

            if (funcionario.Senha.Length < 6)
                return new RetornoProcesso(false, "Senha deve conter no mínimo 6 dígitos!");

            return new RetornoProcesso(true, "");
        }
Example #14
0
 public IHttpActionResult Get()
 {
     return(Ok(Mapeamento.Mapear(_db.Produtos.Where(p => p.EmLeilao).ToList())));
 }
 public ActionResult Index()
 {
     return(View(Mapeamento.Mapear(_db.Produtos.Where(p => p.EmLeilao).ToList())));
 }
Example #16
0
 // GET: Produtos/Create
 public ActionResult Create()
 {
     return(View(Mapeamento.Mapear(new Produto(), db.Categorias.ToList())));
 }
Example #17
0
 // GET: Produtos
 public ActionResult Index()
 {
     throw new Exception("Teste");
     return(View(Mapeamento.Mapear(db.Produtos.ToList())));
 }
Example #18
0
 // GET: Produtos/Delete/5
 public ActionResult Delete(int id)
 {
     return(View(Mapeamento.Mapear(_db.Produtos.Find(id))));
 }
Example #19
0
 // GET: Produtos/Edit/5
 public ActionResult Edit(int id)
 {
     return(View(Mapeamento.Mapear(_db.Produtos.Find(id),
                                   _db.Categorias.ToList())));
 }
        public void Selecionar(Mapeamento.Model.Funcionario funcionario)
        {
            if (!Seguranca.CategoriaUsuarioLogado.Equals(CategoriaFuncionario.Administrador))
                return;

            var cadastroFuncionario = Registro.GetInstance<IFuncionarioViewModel>();
            cadastroFuncionario.SetEntity(funcionario);

            _windowManager.ShowDialog(cadastroFuncionario);
        }
        public RetornoProcesso Remover(Mapeamento.Model.Funcionario funcionario)
        {
            try
            {
                _repFuncionario.Excluir(funcionario);

                return new RetornoProcesso(true, "Funcionário removido com sucesso!");
            }
            catch (Exception ex)
            {
                return new RetornoProcesso(false, ex.Message);
            }
        }
Example #22
0
 // GET: Produtos
 public ActionResult Index()
 {
     return(View(Mapeamento.Mapear(db.Produtos.ToList())));
 }
        public RetornoProcesso ValidarSenha(Mapeamento.Model.Funcionario funcionario, string senhaAtual, string senhaNova)
        {
            if (!funcionario.Senha.Equals(senhaAtual))
                return new RetornoProcesso(false, "Senha atual não confere!");

            if (senhaAtual.Equals(senhaNova))
                return new RetornoProcesso(false, "Senhas idênticas!");

            if (senhaNova.Length < 6)
                return new RetornoProcesso(false, "Senha deve conter no mínimo 6 dígitos!");

            return new RetornoProcesso(true, "");
        }
Example #24
0
        static void Main(string[] args)
        {
            //=== Criar tabela de simbolos
            List <ts> tabela = new List <ts>();

            //Buffer
            string buffer;


            //===== Definir arquivos de entrada
            string[] codigo     = System.IO.File.ReadAllLines(@"codigo.txt");
            string[] afd        = System.IO.File.ReadAllLines(@"AutomatoFinitoEstadoErro.csv");
            string   mapeamento = System.IO.File.ReadAllText(@"mapeamentoEstados.txt");

            //=== Carregar AFD em uma matriz
            List <AFD> afdMatriz = new List <AFD>();

            foreach (String linha in afd)
            {
                AFD afdLin = new AFD();
                buffer = "";
                foreach (char c in linha)
                {
                    if (c == ';')
                    {
                        afdLin.afdCol.Add(buffer);
                        buffer = "";
                    }
                    else
                    {
                        buffer += c;
                    }
                }
                afdMatriz.Add(afdLin);
            }

            //=== Imprimir Matriz do AFD
            foreach (AFD li in afdMatriz)
            {
                foreach (string co in li.afdCol)
                {
                    Console.Write(co + " ");
                }
                Console.WriteLine("");
            }
            //Console.WriteLine("Teste ma[9][4] = " + afdMatriz[9].afdCol[4]);
            //List<int> teste = FindState("L", "6", afdMatriz);
            //Console.WriteLine("Teste ma[L][6] = " + afdMatriz[teste[0]].afdCol[teste[1]]);

            //=== Ler caracter por caracter do codigo e verificar estados no AFD
            string     estado    = afdMatriz[1].afdCol[0]; //Estado atual - inicial
            string     estadoAnt = "";                     //Estado anterior
            List <int> indices   = new List <int> {
                0, 0, 0
            };                                              //Indices da matriz AFD

            buffer = "";
            int pos = 1; //Contador de posição no arquivo, no caso é a linha do codigo onde esta
            ts  tsItem;  //Item da tabela de simbolos

            string Separadores          = "/*+-(){},";
            string SeparadoresSemEstado = " \t \n";

            foreach (String linha in codigo)
            {
                if (linha.Length > 0)
                {
                    foreach (char c in linha)
                    {
                        /*Console.WriteLine(c);
                         * if (SeparadoresSemEstado.Contains(c))    //Separadores sem estado
                         * {
                         *  if (!buffer.Equals(""))
                         *  {
                         *      tsItem = new ts();
                         *      tsItem.estado = estado;
                         *      tsItem.posicao = pos;
                         *      tsItem.rotulo = buffer;
                         *      buffer = "";
                         *      tabela.Add(tsItem);
                         *      estado = afdMatriz[1].afdCol[0]; //Estado atual - inicial
                         *  }
                         * }
                         * else if (Separadores.Contains(c))  //Separadores com estado
                         * {
                         *  //Salvar o que tem antes no buffer (se tiver)
                         *  if (!buffer.Equals(""))
                         *  {
                         *      tsItem = new ts();
                         *      tsItem.estado = estadoAnt;
                         *      tsItem.posicao = pos;
                         *      tsItem.rotulo = buffer;
                         *      tabela.Add(tsItem);
                         *  }
                         *
                         *  //Agora salva o separador
                         *  tsItem = new ts();
                         *  tsItem.estado = estado;
                         *  tsItem.posicao = pos;
                         *  tsItem.rotulo = c.ToString();
                         *  buffer = "";
                         *  tabela.Add(tsItem);
                         *  estado = afdMatriz[1].afdCol[0]; //Estado atual - inicial
                         * }
                         * else
                         * {
                         *  indices = FindState(estado, c.ToString(), afdMatriz);
                         *  if (indices == null) Console.WriteLine("Erro ao achar estado: (" + estado + ", " + c.ToString() + ")");
                         *  else
                         *  {
                         *      estadoAnt = estado;
                         *      estado = afdMatriz[indices[0]].afdCol[indices[1]];
                         *  }
                         *  buffer += c;
                         * }*/


                        if (Separadores.Contains(c))
                        {
                            if (buffer != "")
                            {
                                if (FindState(estado, c.ToString(), afdMatriz) != null)
                                {
                                    if (FindState(estado, c.ToString(), afdMatriz)[2] == 1) // se é um estado final
                                    {
                                        tsItem         = new ts();
                                        tsItem.estado  = estado;
                                        tsItem.posicao = pos;
                                        tsItem.rotulo  = buffer;
                                        buffer         = "";
                                        tabela.Add(tsItem);
                                        estado = afdMatriz[1].afdCol[0]; //Estado atual - inicial
                                    }
                                    else
                                    {
                                        buffer += c;
                                    }
                                }
                                else
                                {
                                    {
                                        tsItem         = new ts();
                                        tsItem.estado  = "!";
                                        tsItem.posicao = pos;
                                        tsItem.rotulo  = buffer;
                                        buffer         = "";
                                        tabela.Add(tsItem);
                                        estado = afdMatriz[1].afdCol[0]; //Estado atual - inicial
                                    }
                                }
                            }
                            buffer += c;
                            indices = FindState(estado, c.ToString(), afdMatriz);
                            estado  = afdMatriz[indices[0]].afdCol[indices[1]];
                        }
                        else
                        {
                            if (SeparadoresSemEstado.Contains(c))
                            {
                                if (buffer != "")
                                {
                                    tsItem         = new ts();
                                    tsItem.estado  = estado;
                                    tsItem.posicao = pos;
                                    tsItem.rotulo  = buffer;
                                    buffer         = "";
                                    tabela.Add(tsItem);
                                    estado = afdMatriz[1].afdCol[0]; //Estado atual - inicial
                                }
                            }
                            else
                            {
                                if (FindState(estado, c.ToString(), afdMatriz) != null)
                                {
                                    if (FindState(estado, c.ToString(), afdMatriz)[2] == 1 && (afdMatriz[FindState(estado, c.ToString(), afdMatriz)[0]].afdCol[FindState(estado, c.ToString(), afdMatriz)[1]] == "!"))
                                    {
                                        {
                                            tsItem         = new ts();
                                            tsItem.estado  = estado;
                                            tsItem.posicao = pos;
                                            tsItem.rotulo  = buffer;
                                            buffer         = "";
                                            tabela.Add(tsItem);
                                            estado = afdMatriz[1].afdCol[0]; //Estado atual - inicial
                                        }
                                    }
                                }
                                else
                                {
                                    tsItem         = new ts();
                                    tsItem.estado  = "!";
                                    tsItem.posicao = pos;
                                    tsItem.rotulo  = buffer;
                                    buffer         = "";
                                    tabela.Add(tsItem);
                                    estado = afdMatriz[1].afdCol[0]; //Estado atual - inicial
                                }

                                indices = FindState(estado, c.ToString(), afdMatriz);
                                estado  = afdMatriz[indices[0]].afdCol[indices[1]];

                                buffer += c;
                            }
                        }
                    }


                    if (buffer != "")
                    {
                        //Fim de linha também é separador
                        tsItem         = new ts();
                        tsItem.estado  = estado;
                        tsItem.posicao = pos;
                        tsItem.rotulo  = buffer;
                        buffer         = "";
                        tabela.Add(tsItem);
                        estado = afdMatriz[1].afdCol[0]; //Estado atual - inicial
                    }
                }
                pos++;
            }

            tsItem         = new ts();
            tsItem.estado  = estado;
            tsItem.posicao = pos;
            tsItem.rotulo  = "EOF";
            tabela.Add(tsItem);


            //=== Imprimir tabela de simbolos
            foreach (ts item in tabela)
            {
                Console.WriteLine("Linha:" + item.posicao + " Estado:" + item.estado + " Rotulo:" + item.rotulo);
            }

            //=== Imprimir em arquivo CSV
            ImprimirCSV(tabela, "FitaDeSaida.csv");



            //====================== ANÁLISE SINTÁTICA =====================================================================================================


            //=== importa o XML do GOLD Parse
            string    xmlData  = @"GramaticaTeste.xml";
            XDocument doc      = XDocument.Load(xmlData);
            string    jsonText = JsonConvert.SerializeXNode(doc);
            dynamic   Tables   = JsonConvert.DeserializeObject <dynamic>(jsonText);

            //=== Define as estruturas
            List <Symbol>     colecaoSimbolos  = new List <Symbol>();
            List <Estado>     colecaoEstados   = new List <Estado>();
            List <Production> colecaoProducoes = new List <Production>();
            List <LALRState>  colecaoLALRState = new List <LALRState>();


            //============= Importa os Simbolos do XML

            foreach (var m_Symbol in Tables.Tables.m_Symbol)
            {
                foreach (var Symbols in m_Symbol)
                {
                    if (Symbols.Type == Newtonsoft.Json.Linq.JTokenType.Array)
                    {
                        foreach (var Symbol in Symbols)
                        {
                            Symbol novoSimbolo = new Symbol();

                            foreach (var propriedade in Symbol)
                            {
                                if (propriedade.Name == "@Index")
                                {
                                    string teste = propriedade.Value;
                                    novoSimbolo.Index = Int32.Parse(teste);
                                }
                                if (propriedade.Name == "@Name")
                                {
                                    novoSimbolo.Name = propriedade.Value;
                                }
                            }
                            colecaoSimbolos.Add(novoSimbolo);
                        }
                    }
                }
            }

            //============== Importa os Estados do XML


            foreach (var DFAState in Tables.Tables.DFATable)
            {
                foreach (var estados in DFAState)
                {
                    if (estados.Type == Newtonsoft.Json.Linq.JTokenType.Array)
                    {
                        foreach (var estadoAceitacao in estados)
                        {
                            Estado novoEstado = new Estado();
                            foreach (var propriedade in estadoAceitacao)
                            {
                                if (propriedade.Name == "@AcceptSymbol")
                                {
                                    string valor = propriedade.Value;
                                    novoEstado.AcceptSymbol = GetSymbol(Int32.Parse(valor), colecaoSimbolos);
                                }
                                if (propriedade.Name == "@Index")
                                {
                                    novoEstado.Index = propriedade.Value;
                                }
                            }
                            colecaoEstados.Add(novoEstado);
                        }
                    }
                }
            }

            //=============== Importa as Produções do XML

            foreach (var m_Production in Tables.Tables.m_Production)
            {
                foreach (var Productions in m_Production)
                {
                    if (Productions.Type == Newtonsoft.Json.Linq.JTokenType.Array)
                    {
                        foreach (var Production in Productions)
                        {
                            Production novaProducao = new Production();
                            foreach (var propriedade in Production)
                            {
                                if (propriedade.Name == "@Index")
                                {
                                    string valor = propriedade.Value;
                                    novaProducao.Index = Int32.Parse(valor);
                                }
                                if (propriedade.Name == "@NonTerminalIndex")
                                {
                                    string valor = propriedade.Value;
                                    novaProducao.NonTerminalIndex = GetSymbol(Int32.Parse(valor), colecaoSimbolos);
                                }
                                if (propriedade.Name == "@SymbolCount")
                                {
                                    string valor = propriedade.Value;
                                    novaProducao.SymbolCount = Int32.Parse(valor);
                                }
                                if (propriedade.Name == "ProductionSymbol")
                                {
                                    foreach (var ProductionofProduction in propriedade)
                                    {
                                        foreach (var Producao in ProductionofProduction)
                                        {
                                            foreach (var propriedadeInterna in Producao)
                                            {
                                                ProductionSymbol producao = new ProductionSymbol();
                                                string           valor    = propriedadeInterna.Value;
                                                producao.Symbol = GetSymbol(Int32.Parse(valor), colecaoSimbolos);
                                                novaProducao.ProductionSymbol.Add(producao);
                                            }
                                        }
                                    }
                                }
                            }
                            colecaoProducoes.Add(novaProducao);
                        }
                    }
                }
            }

            //=============== Importa tabela LALR do XML

            foreach (var LALRStates in Tables.Tables.LALRTable)
            {
                foreach (var LALRStatesPropertie in LALRStates)
                {
                    if (LALRStatesPropertie.Type == Newtonsoft.Json.Linq.JTokenType.Array)
                    {
                        foreach (var LALRStateProperties in LALRStatesPropertie)
                        {
                            LALRState novoLALRState = new LALRState();
                            foreach (var LALRStatePropertie in LALRStateProperties)
                            {
                                if (LALRStatePropertie.Name == "@Index")
                                {
                                    string valor = LALRStatePropertie.Value;
                                    novoLALRState.Index = Int32.Parse(valor);
                                }
                                if (LALRStatePropertie.Name == "@ActionCount")
                                {
                                    string valor = LALRStatePropertie.Value;
                                    novoLALRState.ActionCount = Int32.Parse(valor);
                                }
                                if (LALRStatePropertie.Name == "LALRAction")
                                {
                                    if (novoLALRState.ActionCount > 1)
                                    {
                                        foreach (var LALRActions in LALRStatePropertie)
                                        {
                                            foreach (var LALRAction in LALRActions)
                                            {
                                                LALRAction novoLALRAction = new LALRAction();
                                                foreach (var LALRActionPropertie in LALRAction)
                                                {
                                                    if (LALRActionPropertie.Name == "@SymbolIndex")
                                                    {
                                                        string valor = LALRActionPropertie.Value;
                                                        novoLALRAction.SymbolIndex = GetSymbol(Int32.Parse(valor), colecaoSimbolos);
                                                    }
                                                    if (LALRActionPropertie.Name == "@Action")
                                                    {
                                                        string valor = LALRActionPropertie.Value;
                                                        novoLALRAction.Action = Int32.Parse(valor);
                                                    }
                                                    if (LALRActionPropertie.Name == "@Value")
                                                    {
                                                        string valor = LALRActionPropertie.Value;
                                                        novoLALRAction.Value = Int32.Parse(valor);
                                                    }
                                                }
                                                novoLALRState.LALRAction.Add(novoLALRAction);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        foreach (var LALRActionProperties in LALRStatePropertie)
                                        {
                                            LALRAction novoLALRAction = new LALRAction();
                                            foreach (var LALRActionPropertie in LALRActionProperties)
                                            {
                                                if (LALRActionPropertie.Name == "@SymbolIndex")
                                                {
                                                    string valor = LALRActionPropertie.Value;
                                                    novoLALRAction.SymbolIndex = GetSymbol(Int32.Parse(valor), colecaoSimbolos);
                                                }
                                                if (LALRActionPropertie.Name == "@Action")
                                                {
                                                    string valor = LALRActionPropertie.Value;
                                                    novoLALRAction.Action = Int32.Parse(valor);
                                                }
                                                if (LALRActionPropertie.Name == "@Value")
                                                {
                                                    string valor = LALRActionPropertie.Value;
                                                    novoLALRAction.Value = Int32.Parse(valor);
                                                }
                                            }
                                            novoLALRState.LALRAction.Add(novoLALRAction);
                                        }
                                    }
                                }
                            }
                            colecaoLALRState.Add(novoLALRState);
                        }
                    }
                }
            }


            //========== Faz o mapeamento dos estados com a fita de saida
            Mapeamento mapeamentoEstados = JsonConvert.DeserializeObject <Mapeamento>(mapeamento);

            foreach (var ts in tabela)
            {
                foreach (var Simbolo in colecaoSimbolos)
                {
                    if (Simbolo.Name == ts.rotulo)
                    {
                        ts.simbolo = Simbolo;
                        break;
                    }
                }
                var temMapeamento = 0;

                if (ts.simbolo == null)
                {
                    foreach (var map in mapeamentoEstados.Data)
                    {
                        if (ts.estado.Substring(0, 1) == map.Estado)
                        {
                            foreach (var Simbolo in colecaoSimbolos)
                            {
                                if (Simbolo.Name == map.Aceita)
                                {
                                    ts.simbolo = Simbolo;
                                    break;
                                }
                            }

                            temMapeamento = 1;
                        }
                    }
                }



                foreach (var Estado in colecaoEstados)
                {
                    if (Estado.AcceptSymbol == ts.simbolo)
                    {
                        ts.estadoGLC = Estado;
                        break;
                    }
                }
            }



            Pilha pilha = new Pilha()
            {
            };

            pilha.item.Add("0");

            var aceita  = 0;
            int posicao = 0;
            int erro    = 1;

            while (aceita == 0)
            {
                erro = 1;
                foreach (var LALRState in colecaoLALRState)
                {
                    if (LALRState.Index == Int32.Parse(pilha.item[pilha.item.Count - 1]))
                    {
                        foreach (var LALRAction in LALRState.LALRAction)
                        {
                            if (LALRAction.SymbolIndex.Index == tabela[posicao].simbolo.Index)
                            {
                                erro = 0;
                                switch (LALRAction.Action)
                                {
                                case 1:     // Salto
                                    pilha.item.Add(tabela[posicao].rotulo);
                                    pilha.item.Add(LALRAction.Value.ToString());
                                    posicao++;
                                    Console.WriteLine(pilha.ToString());
                                    break;

                                case 2:     // Reducao
                                    // busca o tamanho da producao


                                    var ProducaoDaReducao  = LALRAction.Value;
                                    var SimboloNaoTerminal = colecaoProducoes[ProducaoDaReducao].NonTerminalIndex;

                                    var tamanho = colecaoProducoes[ProducaoDaReducao].SymbolCount * 2;

                                    pilha.item.RemoveRange(pilha.item.Count - tamanho, tamanho);

                                    foreach (var LALRStateAux in colecaoLALRState)
                                    {
                                        if (LALRStateAux.Index == Int32.Parse(pilha.item[pilha.item.Count - 1]))
                                        {
                                            foreach (var LALRActionAux in LALRStateAux.LALRAction)
                                            {
                                                if (LALRActionAux.SymbolIndex == SimboloNaoTerminal)
                                                {
                                                    pilha.item.Add(SimboloNaoTerminal.Name);
                                                    pilha.item.Add(LALRActionAux.Value.ToString());
                                                    break;
                                                }
                                            }
                                            break;
                                        }
                                    }
                                    Console.WriteLine(pilha.ToString());
                                    break;

                                case 3:     // Empilhamento
                                    pilha.item.Add(tabela[posicao].simbolo.Name);
                                    pilha.item.Add(LALRAction.Value.ToString());
                                    posicao++;
                                    Console.WriteLine(pilha.ToString());
                                    break;

                                case 4:
                                    /*                                       ProducaoDaReducao = LALRAction.Value;
                                     *                                     SimboloNaoTerminal = colecaoProducoes[ProducaoDaReducao].NonTerminalIndex;
                                     */
                                    aceita = 1;

                                    /*                                       tamanho = 2;
                                     *
                                     *                                     pilha.item.RemoveRange(pilha.item.Count - tamanho, tamanho);
                                     *                                     posicao++;
                                     *                                     Console.WriteLine(pilha.ToString());*/
                                    break;
                                }
                                break;
                            }
                        }
                        break;
                    }
                }
                if (erro == 1)
                {
                    Console.WriteLine("O Analisador sintático encontrou um erro na linha: " + tabela[posicao].posicao);
                    break;
                }
            }

            if (erro == 0)
            {
                Console.WriteLine("Análise Léxica concluída com sucesso!");
            }


            //===================== ANALISADOR SEMÂNTICO ==============================
        }
Example #25
0
 public void SetEntity(Mapeamento.Model.Venda venda)
 {
     throw new NotImplementedException();
 }
        public void SetEntity(Mapeamento.Model.Cliente cliente)
        {
            _cliente = cliente;
            Id = cliente.Id;
            Nome = cliente.Nome;
            DataNascimento = cliente.DataNascimento;
            Cep = cliente.Cep.FormatarCep();
            Logradouro = cliente.Logradouro;
            Numero = cliente.Numero;
            Bairro = cliente.Bairro;
            Cidade = cliente.Cidade;
            Estado = cliente.Estado;
            Telefone = cliente.Telefone.FormatarTelefone();
            Celular = cliente.Celular.FormatarTelefone();
            Animais = cliente.Animais ?? new List<AnimalCliente>();

            Refresh();
        }
Example #27
0
        public void GerarNovaTemporada()
        {
            var assinatura = new Assinatura(1657);

            string assinaturas = "";

            Mapeamento.ForEach(delegate(MapeamentoInfo info)
            {
                assinaturas += info.AnteriorID + ",";
            });

            assinaturas = assinaturas.Substring(0, assinaturas.Length - 1);

            string sql = @"SELECT
                        tAssinaturaCliente.*
                        FROM tAssinatura(NOLOCK)
                        INNER JOIN tAssinaturaAno (NOLOCK) ON tAssinaturaAno.AssinaturaID = tAssinatura.ID
                        INNER JOIN tASsinaturaCliente (NOLOCK) ON tAssinaturaAno.ID = tAssinaturaCliente.AssinaturaAnoID
                        WHERE 
                        tAssinatura.Nome NOT LIKE '%eleazar%' AND
                        ASsinaturaTipoID = " + TipoID + " AND Ano = " + this.TemporadaAnterior + @" AND tAssinaturaCliente.Status IN ('R', 'N', 'T') AND StatusImportacao = ''
                        AND tAssinatura.ID IN (" + assinaturas + ")";

            BD bd    = new BD();
            BD bdAno = new BD();

            bd.Consulta(sql);

            var assinaturaID     = 0;
            var novaAssinaturaID = 0;


            try
            {
                while (bd.Consulta().Read())
                {
                    try
                    {
                        assinaturaID = bd.LerInt("AssinaturaID");

                        var n = Mapeamento.Where(c => c.AnteriorID.Equals(assinaturaID));
                        if (n == null)
                        {
                            continue;
                        }
                        else
                        {
                            novaAssinaturaID = n.FirstOrDefault().NovoID;
                        }


                        var anoID = Convert.ToInt32(bdAno.ConsultaValor("SELECT ID FROM tAssinaturaAno(NOLOCK) WHERE Ano = " + TemporadaNova + " AND AssinaturaID = " + novaAssinaturaID));
                        if (anoID == 0)
                        {
                            continue;
                        }

                        var assinaturaBloqueioID = Convert.ToInt32(bdAno.ConsultaValor("SELECT BloqueioID FROM tAssinatura(NOLOCK) WHERE ID = " + novaAssinaturaID));
                        if (assinaturaBloqueioID == 0)
                        {
                            continue;
                        }



                        EstruturaAssinaturaBloqueio item = new EstruturaAssinaturaBloqueio
                        {
                            ClienteID            = bd.LerInt("ClienteID"),
                            AssinaturaID         = novaAssinaturaID,
                            LugarID              = bd.LerInt("LugarID"),
                            AssinaturaAnoID      = anoID,
                            SetorID              = bd.LerInt("SetorID"),
                            AssinaturaBloqueioID = assinaturaBloqueioID
                        };



                        var lista = new List <EstruturaAssinaturaBloqueio>();
                        lista.Add(item);
                        assinatura.Associar(bd.LerInt("ClienteID"), lista, novaAssinaturaID, anoID);

                        bdAno.Executar("UPDATE tAssinaturaCliente SET StatusImportacao = 'Importado' WHERE ID = " + bd.LerInt("ID"));
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                bd.Fechar();
                bdAno.Fechar();
            }
        }
        public void SetEntity(Mapeamento.Model.Produto produto)
        {
            _produto = produto;
            Id = produto.Id;
            Descricao = produto.Descricao;
            PrecoCusto = produto.PrecoCusto;
            PrecoVenda = produto.PrecoVenda;
            QuantidadeEstoque = produto.QuantidadeEstoque;

            Refresh();
        }
Example #29
0
        public RetornoProcesso Validar(Mapeamento.Model.Produto produto)
        {
            if (string.IsNullOrWhiteSpace(produto.Descricao))
                return new RetornoProcesso(false, "Descrição é um campo obrigatório!");

            if (!produto.PrecoCusto.HasValue)
                return new RetornoProcesso(false, "Preço Custo é um campo obrigatório!");

            if (!produto.PrecoVenda.HasValue)
                return new RetornoProcesso(false, "Preço Venda é um campo obrigatório!");

            if (!produto.QuantidadeEstoque.HasValue)
                return new RetornoProcesso(false, "Qtde. Estoque é um campo obrigatório!");

            return new RetornoProcesso(true, "");
        }
Example #30
0
        // GET: Produtos
        public ActionResult Index()
        {
            throw new Exception("Erro na listagem de produtos.");

            return(View(Mapeamento.Mapear(db.Produtos.ToList())));
        }
        public void Selecionar(Mapeamento.Model.Cliente cliente)
        {
            if (!Seguranca.CategoriaUsuarioLogado.Equals(CategoriaFuncionario.Administrador) &&
                !Seguranca.CategoriaUsuarioLogado.Equals(CategoriaFuncionario.Secretaria))
                return;

            var cadastroCliente = Registro.GetInstance<IClienteViewModel>();
            cadastroCliente.SetEntity(cliente);

            _windowManager.ShowDialog(cadastroCliente);
        }
        public void SetEntity(Mapeamento.Model.Funcionario funcionario)
        {
            _funcionario = funcionario;
            Id = funcionario.Id;
            Nome = funcionario.Nome;
            DataNascimento = funcionario.DataNascimento;
            Cep = funcionario.Cep.FormatarCep();
            Logradouro = funcionario.Logradouro;
            Numero = funcionario.Numero;
            Bairro = funcionario.Bairro;
            Cidade = funcionario.Cidade;
            Estado = funcionario.Estado;
            Telefone = funcionario.Telefone.FormatarTelefone();
            Celular = funcionario.Celular.FormatarTelefone();
            Usuario = funcionario.Usuario;
            Senha = funcionario.Senha;
            CategoriaFuncionario = funcionario.CategoriaFuncionario;

            Refresh();
        }