Example #1
0
        //Método que verifica as Leituras
        public bool instrucao_leitura(Instrucao_leitura inst_leitura)
        {
            Instrucao_leitura inst_lei = new Instrucao_leitura();

            if (compare("LEIA"))
            {
                index++;
                Identificador ident = new Identificador();
                if (identificador(ref ident))
                {
                    inst_lei.ident = ident;
                    if (compare(";"))
                    {
                        index++;
                        inst_leitura = inst_lei;
                        return(true);
                    }
                    else
                    {
                        throw new System.Exception("Declaracao: \';\' esperado!");
                    }
                }
                else
                {
                    throw new System.Exception("Declaracao: \';\' esperado!");
                }
            }
            return(false);
        }
Example #2
0
        public string ToFixedSizeString()
        {
            var sb = new StringBuilder();

            sb.Append(Identificador.ToString().PadLeft(10, '0'));
            sb.Append('~');
            sb.Append(Entero1.ToString().PadLeft(10, '0'));
            sb.Append('~');
            sb.Append(Entero2.ToString().PadLeft(10, '0'));
            sb.Append('~');
            sb.Append(Entero3.ToString().PadLeft(10, '0'));
            sb.Append('~');

            sb.Append(Cadena1.PadLeft(100, '$'));
            sb.Append('~');
            sb.Append(Cadena2.PadLeft(100, '$'));
            sb.Append('~');
            sb.Append(Cadena3.PadLeft(100, '$'));
            sb.Append('~');

            sb.Append(Tiempo1.PadLeft(25, '$'));
            sb.Append('~');
            sb.Append(Tiempo2.PadLeft(25, '$'));
            sb.Append('~');
            sb.Append(Tiempo3.PadLeft(25, '$'));

            return(sb.ToString());
        }
Example #3
0
        public TablaIdentificador(String[] identificadores, int[] lIdentificadores)
        {
            this.palabras = new Identificador[identificadores.Length];

            //this.palabras[0].reiniciar();
            Identificador.svalor = 401;


            for (int x = 0; x < identificadores.Length; x++)
            {
                if (identificadores[x] != null && !identificadores[x].Equals(""))
                {
                    // Preguntamos si la palabra que llega en el arreglo existe
                    if (existePalabra(identificadores[x]))
                    {
                        // Se crea un appuntador de tipo Identificador para refereciar al objeto ya existente
                        Identificador apuntador = darPalabra(identificadores[x]);

                        // Si la linea actual no existe se concatena las ya existentes
                        if (!apuntador.existeLinea(lIdentificadores[x]))
                        {
                            apuntador.concatenarLinea(lIdentificadores[x]);
                        }
                    }
                    else
                    // Si no existe la palabra, se agraga una nueva con los parametros que lleva en el constructor
                    {
                        palabras[x] = new Identificador(identificadores[x], Convert.ToString(lIdentificadores[x]));
                    }
                }
            }
        }
Example #4
0
        // metodo que reconhece o nao terminal identificadores
        private bool identificadores(ref Identificadores idents)
        {
            int             guarda  = index;
            Identificador_r ident_r = new Identificador_r();

            ident_r.ident1 = new Identificador();

            if (identificador(ref ident_r.ident1))
            {
                if (identificador_r(ref ident_r.ident2))
                {
                    idents = ident_r;
                    return(true);
                }
            }

            index = guarda;

            Identificador ident = new Identificador();

            if (identificador(ref ident))
            {
                idents = ident;
                return(true);
            }

            return(false);
        }
Example #5
0
 internal static ModeloSimplificada importarDec(Identificador ide, Files.DEC_Intermediate dec)
 {
     return(new ModeloSimplificada()
     {
         // Base
         ImpostoDevido = dec.TotaisDeclaracaoSimplificada.VR_ImpDevido,
         BaseCalculo = dec.TotaisDeclaracaoSimplificada.VR_BaseCalc,
         SaldoImpostoPagar = dec.TotaisDeclaracaoSimplificada.VR_ImpPagar,
         ImpostoRestituir = dec.TotaisDeclaracaoSimplificada.VR_ImpRestit,
         RendRecebidoExterior = 0,           //R22.VR_EXTER ?
         TotalRendRecebidosMaisExterior = 0, // ?
         TotalLivroCaixa = 0,                // ?
         TotalDoacoesCampanhasEleitorais = dec.TotaisDeclaracaoSimplificada.VR_DoacoesCampanha,
         // Simples
         RendRecebidoPJTitular = dec.TotaisDeclaracaoSimplificada.VR_TotRendTribPJTitular,
         RendRecebidoPJDependentes = dec.TotaisDeclaracaoSimplificada.VR_RendTribDependente,
         RendRecebidoPFEXT_TIT = dec.TotaisDeclaracaoSimplificada.VR_RendPFExt,
         RendRecebidoPFEXT_DEP = dec.TotaisDeclaracaoSimplificada.VR_RendPFExtDepen,
         ResultadoTributavelAR = dec.TotaisDeclaracaoSimplificada.VR_ResNaoTrib_AR,
         TotalResultadosTributaveis = 0, // ?
         DescontoSimplificado = dec.TotaisDeclaracaoSimplificada.VR_DescImp,
         ImpostoRetidoFonteTitular = dec.TotaisDeclaracaoSimplificada.VR_TotFonteTitular,
         ImpostoRetidoFonteDependentes = dec.TotaisDeclaracaoSimplificada.VR_ImpostoDependente,
         CarneLeao = dec.TotaisDeclaracaoSimplificada.VR_Leao,
         ImpostoComplementar = dec.TotaisDeclaracaoSimplificada.VR_ImpComp,
         ImpostoRetidoFonteLei11033 = dec.TotaisDeclaracaoSimplificada.VR_IRFonteLei11033,
         RendIsentosNaoTributaveis = dec.TotaisDeclaracaoSimplificada.VR_TotIsento,
         RendSujeitoTribExclusiva = dec.TotaisDeclaracaoSimplificada.VR_TotRendExclusTitular,
         BensDireitosExercicioAnterior = dec.TotaisDeclaracaoSimplificada.VR_TotBensAnoBaseAnterior,
         BensDireitosExercicioAtual = dec.TotaisDeclaracaoSimplificada.VR_TotBensAnoBase,
         DividasExercicioAnterior = dec.TotaisDeclaracaoSimplificada.VR_TotDividaAnoBaseAnterior,
         DividasExercicioAtual = dec.TotaisDeclaracaoSimplificada.VR_TotDividaAnoBase,
         TotalImpostoRetidoNaFonte = dec.TotaisDeclaracaoSimplificada.VR_Imposto,
     });
 }
Example #6
0
        /// <summary>
        /// Serializa o registro do arquivo Gcon
        /// </summary>
        /// <param name="writer"></param>
        public void Serializar(System.IO.TextWriter writer, int numRegistro)
        {
            var retorno = "LC1";

            retorno += numRegistro.ToString().FormataNumero("Sequencial", 5, true);
            retorno += "".FormataTexto("Filler", 3, true);
            retorno += 1.ToString().FormataNumero("Modo Lançamento", 1, true);
            retorno += DataLiquidacao.ToShortDateString().Replace("/", "");
            retorno += Identificador.ToString().FormataNumero("Numero do documento", 10, true);
            retorno += "".FormataTexto("Numero do lote", 5, true);
            retorno += "".FormataTexto("Origem do Lançamento", 30, true);
            retorno += "".FormataTexto("Qtde Contas", 3, true);

            var codAcesso  = (int)TipoContabil;
            var codInterno = "";

            if (TipoContabil == TipoContabilEnum.BancoNordeste29053 || TipoContabil == TipoContabilEnum.BancoNordeste30869 ||
                TipoContabil == TipoContabilEnum.BancoNordeste31244 || TipoContabil == TipoContabilEnum.BancoNordeste37942)
            {
                codAcesso  = 11113;
                codInterno = ((int)TipoContabil).ToString();
            }

            if (TipoArquivo == TipoArquivoEnum.Pagar)
            {
                // Chamado 66784
                if (TipoContabil == TipoContabilEnum.Cheque || TipoContabil == TipoContabilEnum.Credito)
                {
                    codAcesso = (int)TipoContabilEnum.Dinheiro;
                }

                retorno += "21201".FormataNumero("Cód Acesso", 5, true);
                retorno += Glass.Formatacoes.RetiraCaracteresEspeciais(CpfCnpj).FormataTexto("CPF/CNPJ", 14, true);
                retorno += "".FormataTexto("C/Custo", 5, true);

                retorno += codAcesso.ToString().FormataNumero("Cód Acesso", 5, true);
                retorno += !string.IsNullOrEmpty(codInterno) ? codInterno.FormataNumero("Cód Interno", 6, true) + "".FormataTexto("", 8, false) : codInterno.FormataTexto("Cód Interno", 14, true);
                retorno += "".FormataTexto("C/Custo", 5, true);
            }
            else
            {
                retorno += codAcesso.ToString().FormataNumero("Cód Acesso", 5, true);
                retorno += !string.IsNullOrEmpty(codInterno) ? codInterno.FormataNumero("Cód Interno", 6, true) + "".FormataTexto("", 8, false) : codInterno.FormataTexto("Cód Interno", 14, true);
                retorno += "".FormataTexto("C/Custo", 5, true);

                retorno += "11202".FormataNumero("Cód Acesso", 5, true);
                retorno += Glass.Formatacoes.RetiraCaracteresEspeciais(CpfCnpj).FormataTexto("CPF/CNPJ", 14, true);
                retorno += "".FormataTexto("C/Custo", 5, true);
            }

            retorno += Math.Round(Valor, 2).ToString().Replace(",", ".").FormataNumero("Valor Lançamento", 16, true);
            retorno += (!string.IsNullOrEmpty(Obs) ? Obs : "Forma Pagto.: " + Colosoft.Translator.Translate(TipoContabil).Format()).FormataTexto("Historico", 240, false);
            retorno += "".FormataTexto("Ind. Conciliação - Deb", 1, false);
            retorno += "".FormataTexto("Ind. Conciliação - Cred", 1, false);
            retorno += "".FormataTexto("Filler", 74, false);

            writer.WriteLine(retorno);
        }
Example #7
0
        // metodo para reconhecer o terminal identificador
        private bool identificador(ref Identificador ident)
        {
            if (tokens[index].nome == ClasseToken.Identificador &&
                !PalavrasReservadas.Contains(tokens[index].valor as string))
            {
                ident.ident = tokens[index].valor.ToString();
                index++;
                return(true);
            }

            return(false);
        }
        public void Ejecutar()
        {
            LoggerConsola logger = new LoggerConsola();
            AuditorArchivo auditor = new AuditorArchivo();
            logger.IniTraza(Nivel.INFO);
            auditor.NombreArchivo = "C:\\Temp\\auditor.log";

            /*Prepara los componentes (objetos) que colaboran en el programa*/
            /* Tipo de señales, adquisidor, procesador y repositorio */
            Adquisidor adquisidor;
            IProcesador procesador;
            IRepositorio repositorio;
            Senial senialAdquirida;
            Senial senialProcesada;

            /*Se crean las instancias de los objetos */
            /*Se utiliza el patron Factory como responsable de la creacion de cada objeto*/
            /*Señales*/
            senialAdquirida = FactorySenial.ObtenerSenial("Pila", 10);
            senialProcesada = FactorySenial.ObtenerSenial("Basica", 0);
            /*Adquisidor*/
            adquisidor = FactoryAdquisidor.ObtenerAdquisidor ("Senoidal", senialAdquirida);
            /*Procesador*/
            procesador = FactoryProcesador.ObtenerProcesador ("Umbral");
            repositorio = FactoryDAO.ObtenerRepositorio("Texto", "C:\\Users\\Victor\\Documents\\GitHub\\Temp");
            /*Se crean los responsables de la entrada y salida de usuario*/
            var identificador = new Identificador ();
            var visualizador = new Visualizador ();
            logger.Trazar("Se prepararon los componentes", Nivel.INFO);

            /*Inicio del proceso pipeline*/
            /*Identifica las señales*/
            identificador.Ingresar (senialAdquirida, "Señal a Adquirir");
            identificador.Ingresar (senialProcesada, "Señal a Procesar");
            logger.Trazar(senialAdquirida.ToString(), Nivel.INFO);
            logger.Trazar(senialProcesada.ToString(), Nivel.INFO);
            auditor.Auditar("EjemploSenial", this.GetType(), "Adquirir");

            /*Ejecuta la cadena de procesos */
            Console.WriteLine ("1. Adquiere");
            adquisidor.LeerSenial ();
            visualizador.MostrarValores (adquisidor.ObtenerSenialAdquirida());

            Console.WriteLine ("2. Procesa");
            procesador.Procesar (senialAdquirida, senialProcesada);
            visualizador.MostrarValores (senialProcesada);

            /*Guarda Señal*/
            Console.WriteLine("3. Guarda");
            repositorio.Guardar(senialProcesada);
            visualizador.MostrarValores(repositorio.Recuperar(senialProcesada.Id));
        }
Example #9
0
        private void btnGerarAssembly_Click(object sender, EventArgs e)
        {
            string caminho = txtCaminho.Text.Replace(@"\", @"/") + @"\CodigoAssembly.asm";

            arquivo = new Arquivo(caminho);

            string calculo = txtCalculo.Text;

            var identificador = new Identificador();

            //Coloca em um vetor todos os números separados das operações
            var operandos = identificador.IdentificarOperandos(calculo);

            identificador.EscreverCodigo(operandos, arquivo);

            arquivo.FecharArquivo();
        }
Example #10
0
        }                           // Serialização

        internal static ModeloCompleta importarDec(Identificador ide, Files.DEC_Intermediate dec)
        {
            return(new ModeloCompleta()
            {
                // Base
                ImpostoDevido = dec.TotaisDeclaracao.VR_ImpDev,
                BaseCalculo = dec.TotaisDeclaracao.VR_BaseCalc,
                SaldoImpostoPagar = dec.TotaisDeclaracao.VR_ImpPagar,
                ImpostoRestituir = dec.TotaisDeclaracao.VR_ImpRest,
                RendRecebidoExterior = 0,                          // ?
                TotalRendRecebidosMaisExterior = 0,                // ?
                TotalLivroCaixa = dec.TotaisDeclaracao.VR_LivCaix, // ?
                TotalDoacoesCampanhasEleitorais = dec.TotaisDeclaracao.VR_DoacoesCampanha,
                // Completa
                // TODO terminar
            });
        }
Example #11
0
	/*
	 * Esta parte la podriamos cambiar a un JSON o algo parecido para parsear la data mas facil
	 */
	public Paquete(string dataStream)
	{

		XmlSerializer serializer = new XmlSerializer (typeof(Paquete));
		StringReader reader = new StringReader (dataStream);
		Paquete p = (Paquete)serializer.Deserialize(reader);

		/*Debug.Log ("Jugador: "+p.jugador);
		for (int i =0; i<p.bullets.Count; i++) {
			Debug.Log("Bala: "+p.bullets[i].id);
		}*/
		this.jugador = p.jugador;
		this.bullets = p.bullets;
		this.identificadorPaquete = p.identificadorPaquete;


		

	}
 private bool MethodValidaDatos()
 {
     if (CollectionSelectESGR_Mesa.Count == 0)
     {
         CmpMessageBox.Show(SGRMessage.BusquedaMesaDisponible, SGRMessageContent.ContentSelecedtNull + "Guardar Mesa", CmpButton.Aceptar);
         return(true);
     }
     else if (Identificador.Trim().Length == 0)
     {
         CmpMessageBox.Show(SGRMessage.BusquedaMesaDisponible, "Debe ingresar un nombre de Mesa", CmpButton.Aceptar);
         return(true);
     }
     else if (!Reservado && NumPersonas == 0)
     {
         CmpMessageBox.Show(SGRMessage.BusquedaMesaDisponible, "Debe ingresar cantidad de personas", CmpButton.Aceptar);
         return(true);
     }
     return(false);
 }
        private static void EnviarMensagens(Identificador identificador, IModel channel)
        {
            var ativo = true;

            while (ativo)
            {
                var mensagem = new Mensagem(Guid.NewGuid(), "Hello World", identificador.Nome, DateTime.Now.ToString("dd/MM/yyy hh:mm:ss")).ToString();
                var body     = Encoding.UTF8.GetBytes(mensagem);

                channel.BasicPublish(exchange: "",
                                     routingKey: "messageQueue",
                                     basicProperties: null,
                                     body: body);

                Console.WriteLine(" [x] Enviado: {0}", mensagem);

                Thread.Sleep(5000);
            }
        }
Example #14
0
 //Método que verifica se o arquivo contém as palavras reservadas
 private bool portugol()
 {
     listaVariavel = Variaveis();
     if (compare("PROGRAMA"))
     {
         index++;
         Identificador ident = new Identificador();
         if (identificador(ref ident))
         {
             result.ident = ident;
             if (compare(";"))
             {
                 index++;
                 if (compare("VARIAVEIS"))
                 {
                     index++;
                     Declaracoes delcs = new Declaracoes();
                     if (declaracoes(delcs))
                     {
                         result.decls = delcs;
                         if (compare("INICIO"))
                         {
                             index++;
                             Instrucoes inst = new Instrucoes();
                             if (instrucoes(inst))
                             {
                                 result.inst = inst;
                                 if (compare("FIM"))
                                 {
                                     index++;
                                     return(true);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }
        static void Main(string[] args)
        {
            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };
            var identificador = new Identificador();

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: "messageQueue",
                                         durable: false,
                                         exclusive: false,
                                         autoDelete: false,
                                         arguments: null);
                    EnviarMensagens(identificador, channel);
                }

            Console.ReadLine();
        }
 private void OnLocalChecked(string iden)
 {
     if (LocalChecked != null)
     {
         LocalChecked(this, new NewEventArgs()
         {
             IdentificadorText = iden
         });
         TIPO.SelectedIndex = -1;
         NombreDueño.ResetText();
         Identificador.ResetText();
         horarioatencioninicial.ResetText();
         horariofinatencion.ResetText();
         numerosalas.ResetText();
         categorias.ResetText();
         mesasexclusivas.ResetText();
         Controller.Serializacion();
         stackPanels.Add(panels["CheckStorePanel"]);
         ShowLastPanel();
     }
 }
Example #17
0
        public void LogOut()
        {
            if (Identificador.ToLower() != "System".ToLower())
            {
                new mData().LogOFF(Registro.Indice);
            }

            Identificador = string.Empty;
            Nome          = string.Empty;
            Sexo          = string.Empty;
            Email         = string.Empty;
            Cadastro      = DateTime.Now;
            Atualizado    = DateTime.Now;
            Ativo         = false;
            Thema         = "Light";
            Color         = "#FF3399FF";
            Conta         = AccountAccess.Bloqueado.ToString().ToUpper();
            Acesso        = (int)AccountAccess.Bloqueado;
            Modulos.Clear();
            Submodulos.Clear();
            Autenticado = false;
        }
Example #18
0
        //Método que verifica as atribuições
        private bool atribuicao(Atribuicao atr)
        {
            Identificador n = new Identificador();
            int           guarda;


            if (identificador(ref n))
            {
                atr.ident = n;

                if (tokens[index].valor.Equals('='))
                {
                    guarda = index - 1;
                    index++;
                    Expressoes expr = new Expressoes();
                    if (expressoes(expr))
                    {
                        atr.expr = expr;
                        if (tokens[index].valor.ToString() == ";")
                        {
                            index++;
                            contaLinha++;

                            return(true);
                        }
                        else
                        {
                            throw new System.Exception("Declaracao: \';\' esperado na linha: " + contaLinha);
                        }
                    }
                }
            }
            else
            {
                throw new System.Exception("Declaracao: \'=\' esperado!");
            }
            return(false);
        }
Example #19
0
        // metodo auxiliar para reconhecer a recursividade dos identificadores
        private bool identificador_r(ref Identificadores idents)
        {
            int guarda = index;

            if (tokens[index].valor.Equals(','))
            {
                index++;

                Identificador_r ident_r = new Identificador_r();
                ident_r.ident1 = new Identificador();

                if (identificador(ref ident_r.ident1))
                {
                    if (identificador_r(ref ident_r.ident2))
                    {
                        idents = ident_r;
                        return(true);
                    }
                }
            }

            index = guarda;

            if (tokens[index].valor.Equals(','))
            {
                index++;

                Identificador ident = new Identificador();

                if (identificador(ref ident))
                {
                    idents = ident;
                    return(true);
                }
            }

            return(false);
        }
Example #20
0
 internal static AtividadeRural importarDec(Identificador ide, Files.DEC_Intermediate dec)
 {
     throw new System.NotImplementedException();
 }
Example #21
0
        public TablaLexica(String[] palabras, int[] lineas, TablaIdentificador tablaI, TablaConstante tablaC)
        {
            this.palabras = new Token[palabras.Length];
            //this.palabras[0].reiniciar();
            Token.sNumero = 1;


            // Creando todos los TOKENS
            for (int x = 0; x < palabras.Length; x++)
            {
                //Regex.IsMatch(palabra, @"\d+")
                if (palabras[x] != null && !Regex.IsMatch(palabras[x], @"((\W|^)\s+(\W|$))"))
                {
                    if (palabras[x] != null && Regex.IsMatch(palabras[x], @regexT1))
                    { // Tipo 1 - Reservadas
                        Reservada apuntador = this.darReservada(palabras[x]);
                        if (apuntador != null)
                        {
                            this.palabras[x] = new Token(lineas[x], palabras[x], 1, apuntador.valor);
                        }
                    }
                    else if (palabras[x] != null && Regex.IsMatch(palabras[x], @regexT6))
                    { // Tipo 6 - Cosntantes
                        Constante apuntador = this.darConstante(palabras[x], tablaC);
                        if (apuntador != null)
                        {
                            this.palabras[x] = new Token(lineas[x], "Constante", 6, apuntador.valor);
                        }
                    }
                    else if (palabras[x] != null && Regex.IsMatch(palabras[x], regexT5))
                    { // Tipo 5 - Delimitadores
                        Delimitador apuntador = this.darDelimitador(palabras[x]);
                        if (apuntador != null)
                        {
                            this.palabras[x] = new Token(lineas[x], palabras[x], 5, apuntador.valor);
                        }
                    }
                    else if (palabras[x] != null && Regex.IsMatch(palabras[x], @regexT4))
                    { // Tipo 4 - Identificador
                        Identificador apuntador = this.darIdentificador(palabras[x], tablaI);
                        if (apuntador != null)
                        {
                            this.palabras[x] = new Token(lineas[x], palabras[x], 4, apuntador.valor);
                        }
                    }
                    else if (palabras[x] != null && Regex.IsMatch(palabras[x], @regexT7))
                    { // Tipo 7 - Operadores
                        Operador apuntador = this.darOperador(palabras[x]);
                        this.palabras[x] = new Token(lineas[x], palabras[x], 7, apuntador.valor);
                    }
                    else if (palabras[x] != null && Regex.IsMatch(palabras[x], @regexT8))
                    { // Tipo 8 - Relacionales
                        Relacional apuntador = this.darRelacional(palabras[x]);
                        this.palabras[x] = new Token(lineas[x], palabras[x], 8, apuntador.valor);
                    }
                    else
                    { // Error
                        this.lError = lineas[x];
                        this.error  = true;
                        this.pError = palabras[x];

                        x = palabras.Length;
                    }
                }
            }
        }
Example #22
0
        }                                           // Serialização

        internal static RendimentosTributacaoExclusiva importarDec(Identificador ide, Files.DEC_Intermediate dec)
        {
            throw new System.NotImplementedException();
        }
Example #23
0
        public override Result GetC3D(Ent e, bool funcion, bool ciclo, bool isDeclaracion, bool isObjeto, LinkedList <Error> errores)
        {
            if (!isDeclaracion)
            {
                Debugger(e, "Asignacion");
            }

            Result result = new Result();

            foreach (LinkedList <Expresion> valList in Valor)
            {
                if (Objetivo.Count() != valList.Count())
                {
                    if (isDeclaracion)
                    {
                        errores.AddLast(new Error("Semántico", "La lista de ids debe ser simétrica", Linea, Columna));
                    }
                    return(null);
                }
            }

            for (int i = 0; i < Objetivo.Count(); i++)
            {
                Expresion obj = Objetivo.ElementAt(i);
                if (obj is Identificador || obj is Referencia || obj is AccesoLista) //verifico que sea id o referencia a atributo
                {
                    Identificador idObjetivo   = null;
                    Referencia    refObjetivo  = null;
                    AccesoLista   listObjetivo = null;

                    Result rsObj = null;

                    if (obj is Identificador)
                    {
                        idObjetivo               = (Identificador)obj;
                        idObjetivo.Acceso        = false;
                        idObjetivo.IsDeclaracion = isDeclaracion;

                        if (!Tipo.IsIndefinido())
                        {
                            idObjetivo.GetLocal = true;
                        }
                        rsObj = idObjetivo.GetC3D(e, funcion, ciclo, isObjeto, errores);
                    }

                    if (obj is Referencia)
                    {
                        refObjetivo              = (Referencia)obj;
                        refObjetivo.Acceso       = false;
                        refObjetivo.ObtenerValor = true;
                        if (!isDeclaracion)
                        {
                            rsObj = refObjetivo.GetC3D(e, funcion, ciclo, isObjeto, errores);
                        }
                        else
                        {
                            rsObj = null;
                        }
                    }

                    if (obj is AccesoLista)
                    {
                        listObjetivo        = (AccesoLista)obj;
                        listObjetivo.Acceso = false;
                        //listObjetivo.IsDeclaracion = isDeclaracion;
                        if (!isDeclaracion)
                        {
                            rsObj = listObjetivo.GetC3D(e, funcion, ciclo, isObjeto, errores);
                        }
                        else
                        {
                            rsObj = null;
                        }
                    }

                    if (rsObj == null && obj is Identificador) //si no existe, creo la variable si viene con tipo
                    {
                        if (!Tipo.IsIndefinido())
                        {
                            idObjetivo.Tipo = Tipo;

                            rsObj = new Result();

                            Sim s = new Sim(((Identificador)obj).Id, Tipo, Rol.LOCAL, 1, e.GetPos(), e.Ambito, -1, -1);
                            rsObj.Simbolo = s;

                            if (isObjeto)
                            {
                                s.IsAtributo = true;
                            }

                            e.Add(s);

                            if (!isDeclaracion)
                            {
                                idObjetivo.PtrVariable = s.Pos + "";

                                string ptrStack = NuevoTemporal();
                                if (!isObjeto)
                                {
                                    rsObj.Codigo = ptrStack + " = P + " + s.Pos + ";\n";
                                    rsObj.Valor  = "stack[" + ptrStack + "]";
                                }
                                else
                                {
                                    string ptrHeap   = NuevoTemporal();
                                    string valorHeap = NuevoTemporal();

                                    rsObj.Codigo  = ptrStack + " = P + " + 1 + ";\n";
                                    rsObj.Codigo += valorHeap + " = stack[" + ptrStack + "];\n";
                                    rsObj.Codigo += ptrHeap + " = " + valorHeap + " + " + s.Pos + ";\n";
                                    rsObj.Valor   = "heap[" + ptrHeap + "]";
                                }
                            }
                        }
                        else
                        {
                            if (!isDeclaracion)
                            {
                                errores.AddLast(new Error("Semántico", "No se pudo encontrar la variable: " + idObjetivo.Id + ".", Linea, Columna));
                            }
                            return(null);
                        }
                    }
                    else
                    {
                        if (!Tipo.IsIndefinido() && obj is Identificador)
                        {
                            if (!isDeclaracion)
                            {
                                errores.AddLast(new Error("Semántico", "Ya se declaró una variable con el id: " + idObjetivo.Id + ".", Linea, Columna));
                            }
                            return(null);
                        }
                    }

                    LinkedList <Result> rsList = new LinkedList <Result>();
                    for (int j = 0; j < Valor.Count(); j++)
                    {
                        LinkedList <Expresion> valList = Valor.ElementAt(j);
                        Expresion expI = valList.ElementAt(i);

                        if (j + 1 == Valor.Count())
                        {
                            if (!isDeclaracion)
                            {
                                if (expI is Llamada)
                                {
                                    ((Llamada)expI).PtrVariable = idObjetivo.PtrVariable;
                                }

                                Result rsTemp = expI.GetC3D(e, funcion, ciclo, isObjeto, errores);
                                if (rsTemp != null)
                                {
                                    if (obj is Identificador)
                                    {
                                        if (expI.GetTipo().Tip != idObjetivo.Tipo.Tip)
                                        {
                                            errores.AddLast(new Error("Semántico", "El valor a asignar no es del mismo tipo.", Linea, Columna));
                                            return(null);
                                        }
                                    }
                                    else if (obj is Referencia)
                                    {
                                        if (expI.GetTipo().Tip != refObjetivo.Tipo.Tip)
                                        {
                                            errores.AddLast(new Error("Semántico", "El valor a asignar no es del mismo tipo.", Linea, Columna));
                                            return(null);
                                        }
                                    }
                                    else if (obj is AccesoLista)
                                    {
                                        if (expI.GetTipo().Tip != listObjetivo.Tipo.Tip)
                                        {
                                            errores.AddLast(new Error("Semántico", "El valor a asignar no es del mismo tipo.", Linea, Columna));
                                            return(null);
                                        }
                                    }
                                    rsList.AddLast(rsTemp);
                                }
                                else
                                {
                                    errores.AddLast(new Error("Semántico", "El valor contiene errores.", Linea, Columna));
                                    return(null);
                                }
                            }
                        }
                        else
                        {
                            if (expI is Identificador)
                            {
                                if (!Tipo.IsIndefinido())
                                {
                                    ((Identificador)expI).GetLocal = true;
                                }
                                ((Identificador)expI).Acceso = false;
                                Result rsTemp = expI.GetC3D(e, funcion, ciclo, isObjeto, errores);

                                if (rsTemp == null) //si no existe, creo la variable
                                {
                                    if (!Tipo.IsIndefinido())
                                    {
                                        rsTemp = new Result();

                                        Sim s = new Sim(((Identificador)expI).Id, Tipo, Rol.LOCAL, 1, e.GetPos(), e.Ambito, -1, -1);
                                        rsTemp.Simbolo = s;

                                        if (isObjeto)
                                        {
                                            s.IsAtributo = true;
                                        }

                                        e.Add(s);

                                        if (!isDeclaracion)
                                        {
                                            string ptrStack = NuevoTemporal();
                                            if (!isObjeto)
                                            {
                                                rsTemp.Codigo = ptrStack + " = P + " + s.Pos + ";\n";
                                                rsTemp.Valor  = "stack[" + ptrStack + "]";
                                            }
                                            else
                                            {
                                                string ptrHeap   = NuevoTemporal();
                                                string valorHeap = NuevoTemporal();

                                                rsTemp.Codigo  = ptrStack + " = P + " + 1 + ";\n";
                                                rsTemp.Codigo += valorHeap + " = stack[" + ptrStack + "];\n";
                                                rsTemp.Codigo += ptrHeap + " = " + valorHeap + " + " + s.Pos + ";\n";
                                                rsTemp.Valor   = "heap[" + ptrHeap + "]";
                                            }

                                            rsTemp.PtrStack = s.Pos;
                                        }
                                    }
                                    else
                                    {
                                        if (!isDeclaracion)
                                        {
                                            errores.AddLast(new Error("Semántico", "El valor contiene errores.", Linea, Columna));
                                        }
                                        return(null);
                                    }
                                }
                                else
                                {
                                    if (!Tipo.IsIndefinido())
                                    {
                                        if (!isDeclaracion)
                                        {
                                            errores.AddLast(new Error("Semántico", "Ya se declaró una variable con el id: " + idObjetivo.Id + ".", Linea, Columna));
                                        }
                                        return(null);
                                    }
                                }
                                rsList.AddLast(rsTemp);
                            }
                            else
                            {
                                return(null); /*No implementado otro tipo de valores(listas)*/
                            }
                        }
                    }

                    if (!isDeclaracion)
                    {
                        if (rsList.Count() == 1)
                        {
                            if (rsObj.Simbolo != null)
                            {
                                if (rsObj.Simbolo.Tipo.IsList())
                                {
                                    if (rsList.ElementAt(0).Tipo != null)
                                    {
                                        rsObj.Simbolo.Tipo = rsList.ElementAt(0).Tipo;
                                    }
                                }
                            }
                            //rsObj.Tipo = rsList.ElementAt(0).Tipo;
                            rsObj.Codigo += rsList.ElementAt(0).Codigo;
                            rsObj.Codigo += rsObj.Valor + " = " + rsList.ElementAt(0).Valor + ";\n";
                        }
                        else
                        {
                            Result rsAnt = rsList.ElementAt(rsList.Count() - 1);

                            for (int k = rsList.Count() - 2; k >= 0; k--)
                            {
                                Result rsAct = rsList.ElementAt(k);
                                rsAct.Codigo += rsAnt.Codigo;
                                rsAct.Codigo += rsAct.Valor + " = " + rsAnt.Valor + ";\n";

                                /*Esto solo funciona con ids*/
                                string ptrStack = NuevoTemporal();
                                rsAct.Codigo += ptrStack + " = P + " + rsAct.PtrStack + ";\n";
                                rsAct.Valor   = NuevoTemporal();
                                rsAct.Codigo += rsAct.Valor + " = stack[" + ptrStack + "];\n";

                                rsAnt = rsAct;
                            }

                            if (rsObj.Simbolo != null)
                            {
                                if (rsObj.Simbolo.Tipo.IsList())
                                {
                                    if (rsAnt.Tipo != null)
                                    {
                                        rsObj.Simbolo.Tipo = rsAnt.Tipo;
                                    }
                                }
                            }

                            rsObj.Codigo += rsAnt.Codigo;
                            rsObj.Codigo += rsObj.Valor + " = " + rsAnt.Valor + ";\n";
                        }
                    }
                    if (rsObj != null)
                    {
                        result.Codigo += rsObj.Codigo;
                    }
                }
            }

            return(result);
        }
Example #24
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            BD actual = e.Master.Actual;

            if (actual != null)
            {
                if (e.Master.UsuarioActual != null)
                {
                    if (e.Master.UsuarioActual.GetPermiso(actual.Id))
                    {
                        Simbolo sim = actual.GetTabla(Id);

                        if (sim != null)
                        {
                            Tabla tabla = (Tabla)sim.Valor;

                            LinkedList <Entorno> datos = new LinkedList <Entorno>();

                            if (Order != null)
                            {
                                if (tabla.Datos.Count() > 1)
                                {
                                    foreach (Entorno ent in tabla.Datos)
                                    {
                                        Entorno entActual = new Entorno(null, new LinkedList <Simbolo>());

                                        foreach (Simbolo simActual in ent.Simbolos)
                                        {
                                            entActual.Add(new Simbolo(simActual.Tipo, simActual.Rol, simActual.Id, simActual.Valor));
                                        }

                                        datos.AddLast(entActual);
                                    }

                                    e.Master.EntornoActual = tabla.Datos.ElementAt(0);

                                    if (Order.Count() >= 1)
                                    {
                                        for (int j = Order.Count() - 1; j >= 0; j--)
                                        {
                                            Identificador ident = Order.ElementAt(j);

                                            LinkedList <Entorno>  tmp = new LinkedList <Entorno>();
                                            IEnumerable <Entorno> ordered;

                                            object identValor = ident.GetValor(e, log, errores);

                                            if (identValor != null)
                                            {
                                                if (identValor is Throw)
                                                {
                                                    return(identValor);
                                                }

                                                if (ident.Tipo.IsString() || ident.Tipo.IsDate() || ident.Tipo.IsTime())
                                                {
                                                    ordered = datos.OrderBy(p => p.GetCualquiera(ident.GetId()).Valor.ToString()).AsEnumerable();
                                                }
                                                else if (ident.Tipo.IsInt())
                                                {
                                                    ordered = datos.OrderBy(p => (int)p.GetCualquiera(ident.GetId()).Valor).AsEnumerable();
                                                }
                                                else if (ident.Tipo.IsDouble())
                                                {
                                                    ordered = datos.OrderBy(p => (double)p.GetCualquiera(ident.GetId()).Valor).AsEnumerable();
                                                }
                                                else
                                                {
                                                    errores.AddLast(new Error("Semántico", "Solo se puede usar la cláusula Order By sobre datos primitivos.", Linea, Columna));
                                                    return(null);
                                                }

                                                if (ident.IsASC)
                                                {
                                                    foreach (Entorno eTmp in ordered)
                                                    {
                                                        tmp.AddLast(eTmp);
                                                    }
                                                }
                                                else
                                                {
                                                    for (int i = ordered.Count() - 1; i >= 0; i--)
                                                    {
                                                        tmp.AddLast(ordered.ElementAt(i));
                                                    }
                                                }
                                                datos = tmp;
                                            }
                                            else
                                            {
                                                return(null);
                                            }
                                        }
                                    }

                                    /*
                                     * else if (Order.Count() >= 2)
                                     * {
                                     *  Identificador ident = Order.ElementAt(0);
                                     *  Identificador ident2 = Order.ElementAt(1);
                                     *
                                     *  LinkedList<Entorno> tmp = new LinkedList<Entorno>();
                                     *  IEnumerable<Entorno> ordered;
                                     *
                                     *  object identValor = ident.GetValor(e, log, errores);
                                     *  object identValor2 = ident2.GetValor(e, log, errores);
                                     *
                                     *  if (identValor != null && identValor2 != null)
                                     *  {
                                     *      if (ident.Tipo.IsString() || ident.Tipo.IsDate() || ident.Tipo.IsTime() || ident.Tipo.IsInt() || ident.Tipo.IsDouble())
                                     *          if(ident2.Tipo.IsString() || ident2.Tipo.IsDate() || ident2.Tipo.IsTime() || ident2.Tipo.IsInt() || ident2.Tipo.IsDouble())
                                     *              ordered = datos.OrderBy(p => Tuple.Create(p.GetCualquiera(ident.GetId()).Valor.ToString(), p.GetCualquiera(ident2.GetId()).Valor.ToString()), new ComparaTupla()).AsEnumerable();
                                     *          else
                                     *          {
                                     *              errores.AddLast(new Error("Semántico", "Solo se puede usar la cláusula Order By sobre datos primitivos.", Linea, Columna));
                                     *              return null;
                                     *          }
                                     *      else
                                     *      {
                                     *          errores.AddLast(new Error("Semántico", "Solo se puede usar la cláusula Order By sobre datos primitivos.", Linea, Columna));
                                     *          return null;
                                     *      }
                                     *
                                     *      if (ident.IsASC)
                                     *      {
                                     *          foreach (Entorno eTmp in ordered)
                                     *          {
                                     *              tmp.AddLast(eTmp);
                                     *          }
                                     *      }
                                     *      else
                                     *      {
                                     *          for (int i = ordered.Count() - 1; i >= 0; i--)
                                     *          {
                                     *              tmp.AddLast(ordered.ElementAt(i));
                                     *          }
                                     *      }
                                     *      datos = tmp;
                                     *  }
                                     *  else
                                     *      return null;
                                     * }
                                     */
                                }
                                else
                                {
                                    datos = tabla.Datos;
                                }
                            }
                            else
                            {
                                datos = tabla.Datos;
                            }

                            LinkedList <Entorno> data = new LinkedList <Entorno>();

                            foreach (Entorno ent in datos)
                            {
                                e.Master.EntornoActual = ent;
                                Entorno entActual = new Entorno(null, new LinkedList <Simbolo>());

                                if (Where != null)
                                {
                                    object valWhere = Where.GetValor(e, log, errores);
                                    if (valWhere != null)
                                    {
                                        if (valWhere is Throw)
                                        {
                                            return(valWhere);
                                        }

                                        if (Where.Tipo.IsBoolean())
                                        {
                                            if (!(bool)valWhere)
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            errores.AddLast(new Error("Semántico", "Cláusula Where debe ser booleana.", Linea, Columna));
                                            return(null);
                                        }
                                    }
                                    else
                                    {
                                        return(null);
                                    }
                                }

                                if (Columnas != null)
                                {
                                    int numCol = 1;

                                    foreach (Expresion colExp in Columnas)
                                    {
                                        Simbolo simActual = new Simbolo();

                                        object valColExp = colExp.GetValor(e, log, errores);

                                        if (valColExp != null)
                                        {
                                            if (valColExp is Throw)
                                            {
                                                return(valColExp);
                                            }

                                            simActual.Tipo = colExp.Tipo;
                                            simActual.Rol  = Rol.COLUMNA;

                                            if (colExp is Identificador iden)
                                            {
                                                simActual.Id = iden.GetId().ToLower();
                                            }
                                            else
                                            {
                                                simActual.Id = "columna" + numCol++;
                                            }
                                            simActual.Valor = valColExp;
                                        }
                                        else
                                        {
                                            return(null);
                                        }

                                        entActual.Add(simActual);
                                    }
                                }
                                else
                                {
                                    foreach (Simbolo col in ent.Simbolos)
                                    {
                                        entActual.Add(new Simbolo(col.Tipo, col.Rol, col.Id, col.Valor));
                                    }
                                }

                                data.AddLast(entActual);
                            }

                            e.Master.EntornoActual = null;

                            int limite;

                            if (Limit != null)
                            {
                                object valLimit = Limit.GetValor(e, log, errores);
                                if (valLimit != null)
                                {
                                    if (valLimit is Throw)
                                    {
                                        return(valLimit);
                                    }

                                    if (Limit.Tipo.IsInt())
                                    {
                                        limite = (int)valLimit - 1;

                                        if ((int)valLimit < 0)
                                        {
                                            errores.AddLast(new Error("Semántico", "El Límite debe ser entero positivo.", Linea, Columna));
                                        }
                                    }
                                    else
                                    {
                                        Casteo cast = new Casteo(new Tipo(entorno.Type.INT), new Literal(Limit.Tipo, valLimit, 0, 0), 0, 0)
                                        {
                                            Mostrar = false
                                        };
                                        valLimit = cast.GetValor(e, log, errores);

                                        if (valLimit != null)
                                        {
                                            if (valLimit is Throw)
                                            {
                                                return(valLimit);
                                            }

                                            limite = (int)valLimit - 1;
                                            if ((int)valLimit < 0)
                                            {
                                                errores.AddLast(new Error("Semántico", "El Límite debe ser entero positivo.", Linea, Columna));
                                            }
                                        }
                                        else
                                        {
                                            errores.AddLast(new Error("Semántico", "El Límite debe ser de tipo Entero.", Linea, Columna));
                                            return(null);
                                        }
                                    }
                                }
                                else
                                {
                                    return(null);
                                }
                            }
                            else
                            {
                                limite = data.Count() - 1;
                            }

                            limite = limite > data.Count() - 1 ? data.Count() - 1 : limite;

                            if (Mostrar)
                            {
                                string salida;

                                if (data.Count() >= 1)
                                {
                                    salida  = "<div class=\"table - responsive\">";
                                    salida += "<table class=\"table table-striped table - sm\"> \n";
                                    salida += "<thead>\n";
                                    salida += "<tr> \n";

                                    foreach (Simbolo col in data.ElementAt(0).Simbolos)
                                    {
                                        salida += "\t<th>" + col.Id + "</th>\n";
                                    }

                                    salida += "</tr>\n";
                                    salida += "</thead>\n";
                                    salida += "<tbody>\n";
                                    for (int i = 0; i <= limite; i++)
                                    {
                                        Entorno ent = data.ElementAt(i);
                                        salida += "<tr>\n";

                                        foreach (Simbolo col in ent.Simbolos)
                                        {
                                            salida += "\t<td>" + col.Valor.ToString() + "</td>\n";
                                        }

                                        salida += "</tr>\n";
                                    }
                                    salida += "</tbody>\n";
                                    salida += "</table>\n";
                                    salida += "</div>\n\n";
                                }
                                else
                                {
                                    salida = "No hay datos en la consulta.\n\n";
                                }

                                log.AddLast(new Salida(2, salida));
                                return(null);
                            }
                            else
                            {
                                return(data);
                            }
                        }
                        else
                        {
                            return(new Throw("TableDontExists", Linea, Columna));
                        }
                        //errores.AddLast(new Error("Semántico", "No existe una Tabla con el id: " + Id + " en la base de datos.", Linea, Columna));
                    }
                    else
                    {
                        errores.AddLast(new Error("Semántico", "El Usuario no tiene permisos sobre: " + actual.Id + ".", Linea, Columna));
                    }
                }
                else
                {
                    errores.AddLast(new Error("Semántico", "No hay un Usuario logeado.", Linea, Columna));
                }
            }
            else
            {
                return(new Throw("UseBDException", Linea, Columna));
            }
            //errores.AddLast(new Error("Semántico", "No se ha seleccionado una base de datos, no se pudo Actualizar.", Linea, Columna));

            return(null);
        }
Example #25
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            Simbolo sim = e.Get(Id);

            if (sim != null)
            {
                if (sim.Tipo.IsCursor())
                {
                    Cursor cursor = (Cursor)sim.Valor;

                    if (cursor.Data != null)
                    {
                        if (cursor.Data.Count() > 0)
                        {
                            if (Parametro != null)
                            {
                                if (Parametro.Count() == cursor.Data.ElementAt(0).Simbolos.Count())
                                {
                                    foreach (Entorno ent in cursor.Data)
                                    {
                                        Entorno local = new Entorno(e);

                                        for (int i = 0; i < Parametro.Count(); i++)
                                        {
                                            Identificador par = Parametro.ElementAt(i);
                                            Simbolo       col = ent.Simbolos.ElementAt(i);

                                            Simbolo var;

                                            if (par.Tipo.Equals(col.Tipo))
                                            {
                                                var = new Simbolo(par.Tipo, Rol.VARIABLE, par.Id.ToLower(), col.Valor);
                                            }
                                            else
                                            {
                                                /*Agregar Collection*/

                                                Casteo cast = new Casteo(par.Tipo, new Literal(col.Tipo, col.Valor, 0, 0), 0, 0)
                                                {
                                                    Mostrar = false
                                                };
                                                object valCol = cast.GetValor(e, log, errores);

                                                if (valCol != null)
                                                {
                                                    if (valCol is Throw)
                                                    {
                                                        return(valCol);
                                                    }

                                                    var = new Simbolo(par.Tipo, Rol.VARIABLE, par.Id.ToLower(), valCol);
                                                }
                                                else
                                                {
                                                    errores.AddLast(new Error("Semántico", "Los Tipos en los parametros no coinciden con los del Cursor.", Linea, Columna));
                                                    return(null);
                                                }
                                            }
                                            local.Add(var);
                                        }

                                        object obj = Bloque.Ejecutar(local, funcion, true, sw, tc, log, errores);

                                        if (obj is Break)
                                        {
                                            break;
                                        }
                                        else if (obj is Return)
                                        {
                                            return(obj);
                                        }
                                        else if (obj is Throw)
                                        {
                                            return(obj);
                                        }
                                    }
                                    return(null);
                                }
                                else
                                {
                                    errores.AddLast(new Error("Semántico", "Los parametros no coinciden con los del Cursor.", Linea, Columna));
                                }
                            }
                            else
                            {
                                errores.AddLast(new Error("Semántico", "Los parametros no coinciden con los del Cursor.", Linea, Columna));
                            }
                        }
                    }
                    else
                    {
                        errores.AddLast(new Error("Semántico", "El Cursor esta cerrado, ejecute la sentecia Open primero.", Linea, Columna));
                    }
                }
                else
                {
                    errores.AddLast(new Error("Semántico", "La variable: " + Id + " no es un cursor.", Linea, Columna));
                }
            }
            return(null);
        }
Example #26
0
        public DataTable GenerarTabla(Tabla actual, Entorno.Entorno ent)
        {
            DataTable nueva = new DataTable();
            int       x     = 0;

            foreach (Expresion exp in this.campos)
            {
                if (exp is Identificador)
                {
                    Identificador ident = (Identificador)exp;
                    DataColumn    ncol  = new DataColumn(ident.identificador);
                    ncol.DataType = typeof(Object);
                    nueva.Columns.Add(ncol);
                }
                else
                {
                    DataColumn ncol = new DataColumn("Columna_" + x);
                    ncol.DataType = typeof(Object);
                    nueva.Columns.Add(ncol);
                }
                x++;
            }

            foreach (DataRow row in actual.tabla.Rows)
            {
                Entorno.Entorno local = new Entorno.Entorno(ent);
                int             y     = 0;
                foreach (DataColumn col in actual.tabla.Columns)
                {
                    if (row[col].GetType() != typeof(System.DBNull))
                    {
                        local.agregar(col.ColumnName, new Simbolo(col.ColumnName, actual.columnas.ElementAt(y).tipo, row[col]));
                    }
                    else
                    {
                        local.agregar(col.ColumnName, new Simbolo(col.ColumnName, actual.columnas.ElementAt(y).tipo, new Nulo()));
                    }
                    y++;
                }
                if (where == null)
                {
                    int     z         = 0;
                    DataRow row_nueva = nueva.NewRow();
                    foreach (Expresion exp in this.campos)
                    {
                        if (exp is Identificador)
                        {
                            Identificador ident = (Identificador)exp;
                            if (local.existe(ident.identificador))
                            {
                                object ob = exp.getValor(local);
                                if (!(ob is Nulo))
                                {
                                    row_nueva[ident.identificador] = ob;
                                }
                            }
                            else
                            {
                                Estatico.errores.Add(new ErrorCQL("Ejecucion", "La columna: " + ident.identificador + ", no existe en la tabla: " + nombre + ", en la base: " + Estatico.actualBase.nombre, this.fila, this.columna));
                                return(null);
                            }
                        }
                        else
                        {
                            object ob = exp.getValor(local);
                            if (!(ob is Nulo))
                            {
                                row_nueva["Columna_" + z] = ob;
                            }
                        }
                        z++;
                    }
                    try
                    {
                        nueva.Rows.Add(row_nueva);
                    }
                    catch (Exception e)
                    {
                        Estatico.errores.Add(new ErrorCQL("Ejecucion", "Problema en agregar a la tabla del select ", this.fila, this.columna));
                    }
                }
                else
                {
                    int    z       = 0;
                    Object val_exp = where.getValor(local);
                    if (val_exp is bool)
                    {
                        if ((bool)val_exp)
                        {
                            DataRow row_nueva = nueva.NewRow();
                            foreach (Expresion exp in this.campos)
                            {
                                if (exp is Identificador)
                                {
                                    Identificador ident = (Identificador)exp;
                                    object        ob    = exp.getValor(local);
                                    if (!(ob is Nulo))
                                    {
                                        row_nueva[ident.identificador] = ob;
                                    }
                                }
                                else
                                {
                                    object ob = exp.getValor(local);
                                    if (!(ob is Nulo))
                                    {
                                        row_nueva["Columna_" + z] = ob;
                                    }
                                }
                                z++;
                            }
                            try
                            {
                                nueva.Rows.Add(row_nueva);
                            }
                            catch (Exception e)
                            {
                                Estatico.errores.Add(new ErrorCQL("Ejecucion", "Problema en agregar a la tabla del select ", this.fila, this.columna));
                            }
                        }
                    }
                    else
                    {
                        Estatico.errores.Add(new ErrorCQL("Ejecucion", "Where debe de dar un resultado booleano ", this.fila, this.columna));
                    }
                }
            }
            if (order != null)
            {
                try
                {
                    nueva.DefaultView.Sort = order;
                    nueva = nueva.DefaultView.ToTable();
                }
                catch (Exception e)
                {
                    Estatico.errores.Add(new ErrorCQL("Ejecucion", "Problema en order by a la tabla del select ", this.fila, this.columna));
                }
            }

            if (limit != null)
            {
                Object val = limit.getValor(ent);
                if (val is int)
                {
                    int limite = (int)val;
                    while (nueva.Rows.Count > limite)
                    {
                        //dataTable.Rows[dataTable.Rows.Count - 1].Delete();
                        nueva.Rows[nueva.Rows.Count - 1].Delete();
                    }
                }
                else if (val is double)
                {
                    double valor  = (double)val;
                    int    limite = Convert.ToInt32(valor);

                    while (nueva.Rows.Count > limite)
                    {
                        //dataTable.Rows[dataTable.Rows.Count - 1].Delete();
                        nueva.Rows[nueva.Rows.Count - 1].Delete();
                    }
                }
                else
                {
                    Estatico.errores.Add(new ErrorCQL("Ejecucion", "El valor del limit no es un numero", this.fila, this.columna));
                }
            }

            return(nueva);
        }
Example #27
0
        public override Result GetC3D(Ent e, bool funcion, bool ciclo, bool isDeclaracion, bool isObjeto, LinkedList <Error> errores)
        {
            if (!isDeclaracion)
            {
                Debugger(e, "For");
            }

            Result result = new Result();

            if (!isDeclaracion)
            {
                if (Objetivo.Count() > 0)
                {
                    Expresion objetivo   = Objetivo.ElementAt(0); /*Solo funciona con uno*/
                    Result    rsObjetivo = null;

                    Identificador idObjetivo   = null;
                    Referencia    refObjetivo  = null;
                    AccesoLista   listObjetivo = null;

                    if (objetivo is Identificador)
                    {
                        idObjetivo               = (Identificador)objetivo;
                        idObjetivo.Acceso        = false;
                        idObjetivo.IsDeclaracion = isDeclaracion;

                        rsObjetivo = idObjetivo.GetC3D(e, funcion, ciclo, isObjeto, errores);
                    }

                    if (objetivo is Referencia)
                    {
                        refObjetivo              = (Referencia)objetivo;
                        refObjetivo.Acceso       = false;
                        refObjetivo.ObtenerValor = true;

                        rsObjetivo = refObjetivo.GetC3D(e, funcion, ciclo, isObjeto, errores);
                    }

                    if (objetivo is AccesoLista)
                    {
                        listObjetivo        = (AccesoLista)objetivo;
                        listObjetivo.Acceso = false;

                        rsObjetivo = listObjetivo.GetC3D(e, funcion, ciclo, isObjeto, errores);
                    }

                    if (rsObjetivo != null)
                    {
                        if (rsObjetivo.Valor != null)
                        {
                            result.Codigo = rsObjetivo.Codigo;

                            Result rsValor = Valor.GetC3D(e, funcion, ciclo, isObjeto, errores);

                            if (rsValor != null)
                            {
                                if (Valor.GetTipo().IsList())
                                {
                                    if (rsValor != null)
                                    {
                                        result.Codigo += rsValor.Codigo;

                                        string ptr = NuevoTemporal();
                                        result.Codigo += ptr + " = " + rsValor.Valor + ";\n";

                                        result.EtiquetaF = NuevaEtiqueta();
                                        result.EtiquetaV = NuevaEtiqueta();
                                        string etqCiclo  = NuevaEtiqueta();
                                        string etqSalida = "";

                                        if (BloqueElse != null)
                                        {
                                            etqSalida = NuevaEtiqueta();
                                        }

                                        result.Codigo += etqCiclo + ":\n";

                                        result.Codigo += "ifFalse (" + ptr + " >= 0 ) goto " + result.EtiquetaF + ";\n";
                                        result.Codigo += "goto " + result.EtiquetaV + ";\n";
                                        result.Codigo += result.EtiquetaV + ":\n";
                                        result.Codigo += rsObjetivo.Valor + " = heap[" + ptr + "];\n";
                                        result.Codigo += ptr + " = " + ptr + " + 1;\n";
                                        result.Codigo += ptr + " = heap[" + ptr + "];\n";

                                        Ent local = new Ent(e.Ambito + "_for", e);
                                        local.EtiquetaCiclo = etqCiclo;

                                        if (BloqueElse != null)
                                        {
                                            local.EtiquetaSalidaCiclo = etqSalida;
                                        }
                                        else
                                        {
                                            local.EtiquetaSalidaCiclo = result.EtiquetaF;
                                        }

                                        result.Codigo += Bloque.GetC3D(local, funcion, true, isDeclaracion, isObjeto, errores).Codigo; //arreglar

                                        result.Codigo += "goto " + etqCiclo + ";\n";
                                        result.Codigo += result.EtiquetaF + ":\n";

                                        if (BloqueElse != null)
                                        {
                                            Ent local2 = new Ent(e.Ambito + "_for", e);
                                            result.Codigo += BloqueElse.GetC3D(local2, funcion, ciclo, isDeclaracion, isObjeto, errores).Codigo;
                                            result.Codigo += etqSalida + ":\n";
                                        }
                                    }
                                    else
                                    {
                                        errores.AddLast(new Error("Semántico", "Error obteniendo el valor a iterar.", Linea, Columna));
                                    }
                                }/*buscar otras*/
                            }
                            else
                            {
                                errores.AddLast(new Error("Semántico", "Error obteniendo el valor a iterar.", Linea, Columna));
                            }
                        }
                        else
                        {
                            errores.AddLast(new Error("Semántico", "Error obteniendo el target.", Linea, Columna));
                        }
                    }
                    else
                    {
                        errores.AddLast(new Error("Semántico", "Error obteniendo el target.", Linea, Columna));
                    }
                }
            }
            else
            {
                if (BloqueElse == null)
                {
                    Ent local = new Ent(e.Ambito + "_for", e);
                    local.Pos      = e.Pos;
                    result.Codigo += Bloque.GetC3D(local, funcion, ciclo, isDeclaracion, isObjeto, errores).Codigo;
                    e.Pos          = local.Pos;
                }
                else
                {
                    Ent local = new Ent(e.Ambito + "_for", e);
                    local.Pos      = e.Pos;
                    result.Codigo += Bloque.GetC3D(local, funcion, ciclo, isDeclaracion, isObjeto, errores).Codigo;
                    e.Pos          = local.Pos;
                    Ent local2 = new Ent(e.Ambito + "_else", e);
                    local2.Pos     = e.Pos;
                    result.Codigo += BloqueElse.GetC3D(local2, funcion, ciclo, isDeclaracion, isObjeto, errores).Codigo;
                    e.Pos          = local.Pos;
                }
            }

            return(result);
        }
Example #28
0
	// Default Constructor
	public Paquete()
	{
		this.identificadorPaquete = Identificador.Null;
		this.jugador = -1;
		this.bullets = new List<BulletMessage> ();
	}
Example #29
0
        public ResponseFormat Autenticar(string Usuario_, string Contrasenia1_, string Contrasenia2_, DateTime FechaNacimiento_, int TipoCliente_)
        {
            ResponseFormat _retvalue = new ResponseFormat();
            Identificador  IdNuevo_  = new Identificador();

            using (var scope = DAContenedor._contenedor.BeginLifetimeScope())
            {
                if (ValidarFormatos.ValidarEmail(Usuario_) == false || Usuario_.Length > 50)
                {
                    _retvalue.Err        = true;
                    _retvalue.ErrMessage = "El correo electronico no tiene el formato requerido, o es mayor a 50 caracteres.";
                    _retvalue.Body       = null;
                    _retvalue.CodErr     = 1;
                    return(_retvalue);
                }
                if (Contrasenia1_ != Contrasenia2_)
                {
                    _retvalue.Err        = true;
                    _retvalue.ErrMessage = "La contraseña y la confirmación no coninciden.";
                    _retvalue.Body       = null;
                    _retvalue.CodErr     = 1;
                    return(_retvalue);
                }
                if (ValidarFormatos.ValidatePassword(Contrasenia1_) == false)
                {
                    _retvalue.Err        = true;
                    _retvalue.ErrMessage = "La contraseña derbe tener al menos un numero, una minuscula, una mayuscula y un caracter especial asi como maximo de  12 caracteres.";
                    _retvalue.Body       = null;
                    _retvalue.CodErr     = 1;
                    return(_retvalue);
                }
                if (TipoCliente_ < 2)
                {
                    _retvalue.Err        = true;
                    _retvalue.ErrMessage = "Seleccione el tipo de cliente.";
                    _retvalue.Body       = null;
                    _retvalue.CodErr     = 1;
                    return(_retvalue);
                }

                IdNuevo_ = scope.Resolve <IDASeguridad>().ValidarUsuario <Identificador>(Usuario_);
                if (IdNuevo_ == null)
                {
                    IdNuevo_ = scope.Resolve <IDASeguridad>().Autenticar <Identificador>(Usuario_, Encrypter.GetHash(Contrasenia1_), FechaNacimiento_, TipoCliente_);
                    if (IdNuevo_.id > 0)
                    {
                        _retvalue.Err        = false;
                        _retvalue.ErrMessage = "Registro guardado correctamente.";
                        _retvalue.Body       = null;
                        _retvalue.CodErr     = 0;
                        return(_retvalue);
                    }
                    else
                    {
                        _retvalue.Err        = true;
                        _retvalue.ErrMessage = "Error al guardar el registro.";
                        _retvalue.Body       = null;
                        _retvalue.CodErr     = 1;
                        return(_retvalue);
                    }
                }
                else
                {
                    _retvalue.Err        = true;
                    _retvalue.ErrMessage = "El usuario ya existe, favor de ingresar otro.";
                    _retvalue.Body       = null;
                    _retvalue.CodErr     = 1;
                    return(_retvalue);
                }
            }
        }
Example #30
0
 internal static MoedaEstrangeira importarDec(Identificador ide, Files.DEC_Intermediate dec)
 {
     throw new System.NotImplementedException();
 }
Example #31
0
        }                    // Serialização

        public Espolio(Identificador IdentificadorDeclaracao)
        {
            this.IdentificadorDeclaracao = IdentificadorDeclaracao;
        }
Example #32
0
 internal static ImpostoPago importarDec(Identificador ide, Files.DEC_Intermediate dec)
 {
     throw new System.NotImplementedException();
 }
Example #33
0
 internal static GanhosCapital importarDec(Identificador ide, Files.DEC_Intermediate dec)
 {
     throw new System.NotImplementedException();
 }