示例#1
0
        // GET: Accesos/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            List <SelectListItem> list = new List <SelectListItem>();

            list.Add(new SelectListItem()
            {
                Value = null, Text = "Seleccione..."
            });
            foreach (var acceso in db.Accesos.Where(x => x.AccesoPredecesor == null).Where(x => x.Tipo == false))
            {
                list.Add(new SelectListItem()
                {
                    Value = acceso.id_acceso.ToString(), Text = acceso.Nombre
                });
            }
            ViewBag.Accesos = list;

            Accesos accesos = await db.Accesos.FindAsync(id);

            //ViewBag.Predecesor = accesos
            if (accesos == null)
            {
                return(HttpNotFound());
            }
            return(View(accesos));
        }
示例#2
0
        protected void btningresar_Click(object sender, EventArgs e)
        {
            bool        existe;
            string      id      = "";
            string      nombre  = "";
            string      cargo   = "";
            string      idcargo = "";
            PersonalDAO db      = new PersonalDAO();
            Accesos     ac      = new Accesos();

            ac.Usuario = txtuser.Text;
            ac.Clave   = txtpass.Text;
            existe     = db.Ingreso(ac, out id, out nombre, out idcargo, out cargo);
            if (existe)
            {
                Session["NombreUsuario"] = nombre;
                Session["IDUsuario"]     = id;
                Session["CargoUsuario"]  = cargo;
                if (idcargo == "3")
                {
                    Response.Redirect("~/Inicio.aspx", true);
                }
                else if (idcargo == "1")
                {
                    Response.Redirect("~/InicioVendedor.aspx", true);
                }
            }
            else
            {
                lblerror.Text    = "Usuario o contraseña incorrecto";
                lblerror.Visible = true;
                txtpass.Focus();
            }
        }
示例#3
0
        private void ButtonEditar_Click(object sender, RoutedEventArgs e)
        {
            if (TextCodigo.Text != "")
            {
                string       resp   = "";
                ClassAccesos Logica = new ClassAccesos();
                Accesos      INFO   = new Accesos();
                INFO.Accesos_Id  = Convert.ToInt32(this.TextCodigo.Text);
                INFO.Descripcion = this.TextDescripcion.Text;
                INFO.Ventas      = bool.Parse(TextVenta.Text);
                INFO.Productos   = bool.Parse(TextProductos.Text);
                INFO.Reportes    = bool.Parse(TextReportes.Text);
                resp             = Logica.ActualizaAcceso(INFO);
                MessageBox.Show(resp);

                /* MessageBox.Show(TextCodigo.Text);
                 * MessageBox.Show(TextDescripcion.Text);
                 * MessageBox.Show(TextVenta.Text);
                 * MessageBox.Show(TextProductos.Text);
                 * MessageBox.Show(TextReportes.Text);*/
            }
            else
            {
                MessageBox.Show("Marque el registro a modificar", "Error al Editar",
                                MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
        }
示例#4
0
 public Accesos Insert(Accesos item)
 {
     try
     {
         _sisGmaEntities.Accesos.Add(item);
         _sisGmaEntities.SaveChanges();
         return(item);
     }
     catch (EntryPointNotFoundException ep)
     {
         IsValid      = false;
         ErrorMessage = ep.GetBaseException().Message;
         return(null);
     }
     catch (Exception e)
     {
         IsValid      = false;
         ErrorMessage = e.GetBaseException().Message;
         return(null);
     }
     finally
     {
         _sisGmaEntities.Dispose();
     }
 }
示例#5
0
        public bool validarModuloPerfil(Guid parametro, string VchUrl)
        {
            bool       resultado = false;
            SqlCommand comando   = new SqlCommand();

            try
            {
                comando.CommandType = CommandType.StoredProcedure;
                comando.CommandText = "sp_ManejoDeSessionAccesoModulos";

                comando.Parameters.Add("@UIDPerfil", SqlDbType.UniqueIdentifier);
                comando.Parameters["@UIDPerfil"].Value = parametro;

                comando.Parameters.Add("@VchUrl", SqlDbType.VarChar, 30);
                comando.Parameters["@VchUrl"].Value = VchUrl;

                foreach (DataRow item in this.Busquedas(comando).Rows)
                {
                    accesos = new Accesos()
                    {
                        UidPerfil = new Guid(item["UidPerfil"].ToString()),
                        UidModulo = new Guid(item["UidModulo"].ToString()),
                        VchURL    = item["VchURL"].ToString(),
                    };
                }

                resultado = this.ManipulacionDeDatos(comando);
            }
            catch (Exception)
            {
                throw;
            }
            return(resultado);
        }
示例#6
0
        public List <Accesos> GetPermissionsByUsers(string userName)
        {
            List <Accesos> detalles = new List <Accesos>();

            conexionSQL.Open();

            SqlCommand commando = new SqlCommand("COVID_ObtenerUsuariosByUser", conexionSQL);

            commando.CommandType = CommandType.StoredProcedure;
            commando.Parameters.AddWithValue("@userName", userName);

            SqlDataReader reader = commando.ExecuteReader();


            while (reader.Read())
            {
                Accesos det = new Accesos();
                det.Rutas  = reader["Ruta"].ToString();
                det.Nombre = reader["Nombre"].ToString();

                detalles.Add(det);
            }

            conexionSQL.Close();

            return(detalles);
        }
示例#7
0
 public Accesos Update(Accesos item)
 {
     try
     {
         _sisGmaEntities.Entry(item).State = EntityState.Modified;
         _sisGmaEntities.SaveChanges();
         return(item);
     }
     catch (EntryPointNotFoundException ep)
     {
         IsValid      = false;
         ErrorMessage = ep.GetBaseException().Message;
         return(null);
     }
     catch (Exception e)
     {
         IsValid      = false;
         ErrorMessage = e.GetBaseException().Message;
         return(null);
     }
     finally
     {
         _sisGmaEntities.Dispose();
     }
 }
示例#8
0
        public string NuevoAcceso(string descripcion, bool ventas, bool productos, bool reportes)
        {
            RepositorioGenerico <Accesos> REP = new RepositorioGenerico <Accesos>();
            Accesos NUEVO     = new Accesos();
            string  resultado = "";

            try
            {
                IEnumerable busca = BuscarAccesoPorNombre(descripcion);
                if (busca.Cast <object>().Any())
                {
                    resultado = "Error: ya existe el estado " + descripcion;
                }
                else
                {
                    NUEVO.Accesos_Id  = Convert.ToInt32(REP.ListarTodo().Max(z => z.Accesos_Id)) + 1;//los lista
                    NUEVO.Descripcion = descripcion;
                    NUEVO.Ventas      = ventas;
                    NUEVO.Productos   = productos;
                    NUEVO.Reportes    = reportes;
                    resultado         = REP.Agregar(NUEVO);
                }
            }
            catch (Exception error)
            {
                resultado = "ERROR" + error.Message;
            }
            return(resultado);
        }//fin del NuevoAcceso
        public string GrabarAccesos(Accesos oAcceso)
        {
            try
            {
                string response        = string.Empty;
                int    id              = 0;
                string accesoConcedido = string.Empty;

                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(Request.Form["UsuarioConcede"]))
                    {
                        oAcceso.UsuarioConcede = Request.Form["UsuarioConcede"];
                    }

                    if (!string.IsNullOrEmpty(Request.Form["UsuarioDenega"]))
                    {
                        oAcceso.UsuarioDenega = Request.Form["UsuarioDenega"];
                        oAcceso.FechaDenega   = Convert.ToDateTime(Request.Form["FechaDenega"]);
                    }

                    accesoConcedido = Request.Form["Concedido"];
                    if (accesoConcedido == "1")
                    {
                        oAcceso.Concedido = 1;
                    }
                    else
                    {
                        oAcceso.Concedido = 0;
                    }

                    id = mantenedorBusiness.GrabarAcceso(oAcceso);
                    if (id > 0)
                    {
                        response = "Todo bien,ok";
                    }
                    else
                    {
                        response  = "Error en la aplicación!,";
                        response += "Se produjo un error no controlado (business)... Revisar!!";
                    }
                }
                else
                {
                    mensajeError  = "Faltan datos:,";
                    mensajeError += string.Join("; ", ModelState.Values
                                                .SelectMany(x => x.Errors)
                                                .Select(x => x.ErrorMessage));
                    response = mensajeError;
                }
                return(response);
            }
            catch (Exception ex)
            {
                mensajeError  = "Error grave,";
                mensajeError += "Ups! algo salió realmente mal... Error: " + ex.Message;
                return(mensajeError);
            }
        }
示例#10
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Accesos accesos = await db.Accesos.FindAsync(id);

            db.Accesos.Remove(accesos);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
示例#11
0
        public bool Ingreso(Accesos ac, out string nombre)
        {
            bool   hay;
            string Ingresar = "select* from v_Acc where Usuario='" + ac.Usuario + "' and " + " Clave='" + ac.Clave + "'";

            try
            {
                SqlCommand comando = new SqlCommand(Ingresar, );
            }
        }
示例#12
0
        void cargarpersonal()
        {
            //txtcodigo.Text = Request.QueryString["IDACCESO"];
            int       codigo = Convert.ToInt32(txtcodigo.Text);
            AccesoDAO db     = new AccesoDAO();
            Accesos   acc    = db.BuscarAcceso(codigo);

            ddlpersonal.SelectedValue = acc.Id_Personal.ToString();
            txtusuario.Text           = acc.Usuario;
            txtclave.Text             = acc.Clave;
        }
示例#13
0
        public async Task <ActionResult> Edit([Bind(Include = "id_acceso,Nombre,Control,Metodo,Tipo,AccesoPredecesor")] Accesos accesos)
        {
            if (ModelState.IsValid)
            {
                db.Entry(accesos).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(accesos));
        }
示例#14
0
        public async Task <ActionResult> Create([Bind(Include = "id_acceso,Nombre,Control,Metodo,Tipo,AccesoPredecesor")] Accesos accesos)
        {
            if (ModelState.IsValid)
            {
                db.Accesos.Add(accesos);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Index"));
        }
示例#15
0
 protected void btnguardar_Click(object sender, EventArgs e)
 {
     if (txtusuario.Text.Length < 0 || txtclave.Text.Length < 0 || ddlpersonal.SelectedValue == "0")
     {
         if (txtusuario.Text.Length < 0)
         {
             lblmesaje.Text = "El campo usuario es obligatorio.";
         }
         if (txtclave.Text.Length < 0)
         {
             lblmesaje.Text = "El campo clave es obligatorio.";
         }
         if (ddlpersonal.SelectedValue == "0")
         {
             lblmesaje.Text = "Debe escojer al personal.";
         }
         string script = "openModal();";
         ScriptManager.RegisterStartupScript(this, typeof(Page), "error", script, true);
     }
     else
     {
         AccesoDAO db  = new AccesoDAO();
         Accesos   acc = new Accesos();
         if (txtusuario.Text == usuario)
         {
             acc.Id_Personal = Convert.ToInt32(ddlpersonal.SelectedValue);
             acc.Usuario     = txtusuario.Text;
             acc.Clave       = txtclave.Text;
             acc.Id_Acceso   = Convert.ToInt32(txtcodigo.Text);
             db.Update(acc);
             Response.Redirect("ManteAcceso.aspx", true);
         }
         else
         {
             bool existe = db.ExisteUsario(txtusuario.Text);
             if (existe)
             {
                 lblmesaje.Text = "El usuario ya esta en uso.";
                 string script = "openModal();";
                 ScriptManager.RegisterStartupScript(this, typeof(Page), "existe", script, true);
             }
             else
             {
                 acc.Id_Personal = Convert.ToInt32(ddlpersonal.SelectedValue);
                 acc.Usuario     = txtusuario.Text;
                 acc.Clave       = txtclave.Text;
                 acc.Id_Acceso   = Convert.ToInt32(txtcodigo.Text);
                 db.Update(acc);
                 Response.Redirect("ManteAcceso.aspx", true);
             }
         }
     }
 }
示例#16
0
 protected void lnkSalir_Click(object sender, EventArgs e)
 {
     if (usuario != "")
     {
         Accesos salida = new Accesos();
         salida.Acceso  = "S";
         salida.Punto   = 0;
         salida.Usuario = usuario;
         salida.registraIngreso();
     }
     Response.Redirect("Default.aspx");
 }
示例#17
0
 private void accesosToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Application.OpenForms["Accesos"] != null)
     {
         Application.OpenForms["Accesos"].Activate();
     }
     else
     {
         Accesos frm = new Accesos();
         frm.MdiParent = this;
         frm.Show();
     }
 }
示例#18
0
        // GET: Accesos/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Accesos accesos = await db.Accesos.FindAsync(id);

            if (accesos == null)
            {
                return(HttpNotFound());
            }
            return(View(accesos));
        }
        public IActionResult Accesos()
        {
            ViewData["Title"] = "Accesos";
            if (String.IsNullOrEmpty(Startup.ConfigSite.Login))
            {
                return(RedirectToAction("Login", "Home"));
            }

            ViewBag.Accesos  = mantenedorBusiness.ListarAcesos();
            ViewBag.Perfiles = mantenedorBusiness.ListarPerfiles();

            Accesos oAcceso = new Accesos();

            return(View(oAcceso));
        }
示例#20
0
        }//fin del NuevoAcceso

        public string ActualizaAcceso(Accesos Info)
        {
            string resultado = "";
            RepositorioGenerico <Accesos> REP = new RepositorioGenerico <Accesos>();

            try
            {
                resultado = REP.Editar(Info);
            }
            catch (Exception error)
            {
                resultado = "Error " + error.Message;
            }
            return(resultado);
        }//fin de ActualizaAcceso
示例#21
0
    public void registraAccesoAdmin()
    {
        object[] datos  = new object[2];
        Accesos  acceso = new Accesos();

        acceso.Punto   = _pv;
        acceso.Usuario = _usuario;
        acceso.Acceso  = "E";
        acceso.registraIngreso();
        datos = acceso.Registrado;
        if (Convert.ToBoolean(datos[0]))
        {
            _registrado = Convert.ToBoolean(datos[1]);
        }
        else
        {
            _registrado = false;
        }
    }
示例#22
0
        // GET: Accesos
        public async Task <ActionResult> Index()
        {
            var ace = await db.Permisos.ToListAsync();

            var list = (from a in db.Accesos
                        select new
            {
                id_acceso = a.id_acceso,
                Nombre = a.Nombre,
                Control = a.Control,
                Metodo = a.Metodo,
                Tipo = a.Tipo,
                AccesoPredecesor =
                    (from a1 in db.Accesos
                     where a1.id_acceso.ToString() == a.AccesoPredecesor
                     select a1.Nombre).FirstOrDefault()
            }).ToList();

            List <Accesos> ac = new List <Accesos>();

            foreach (var item in list)
            {
                Accesos clr = new Accesos();
                clr.id_acceso = item.id_acceso;
                clr.Nombre    = item.Nombre;
                clr.Control   = item.Control;
                clr.Metodo    = item.Metodo;
                clr.Tipo      = item.Tipo;
                if (item.AccesoPredecesor == null)
                {
                    clr.AccesoPredecesor = "";
                }
                else
                {
                    clr.AccesoPredecesor = item.AccesoPredecesor.ToString();
                }

                ac.Add(clr);
            }

            return(View(ac));
        }
示例#23
0
    protected void btnCierreSesion_Click(object sender, EventArgs e)
    {
        Accesos acceso = new Accesos();

        acceso.Punto   = 0;
        acceso.Usuario = username.Text;
        acceso.Acceso  = "S";
        acceso.registraIngreso();
        if (Convert.ToBoolean(acceso.Registrado[0]))
        {
            btnCierreSesion.Visible = false;
            btnIngresar.Enabled     = true;
            lblError.Text           = "Se ha cerrado la sesión existósamente, por favor vuelva a ingresar";
        }
        else
        {
            btnCierreSesion.Visible = false;
            btnIngresar.Enabled     = true;
            lblError.Text           = "No se pudo cerrar la sesión previa, contacte al administrador del sistema";
        }
    }
示例#24
0
 public int GrabarAcceso(Accesos pObjAcceso)
 {
     try
     {
         using (LigaContext dbLiga = new LigaContext())
         {
             if (pObjAcceso.Id > 0)
             {
                 //Editar
                 var v = dbLiga.Accesos.Where(a => a.Id == pObjAcceso.Id).FirstOrDefault();
                 if (v != null)
                 {
                     v.Tipo           = pObjAcceso.Tipo;
                     v.Nombre         = pObjAcceso.Nombre;
                     v.PerfilId       = pObjAcceso.PerfilId;
                     v.Concedido      = pObjAcceso.Concedido;
                     v.UsuarioConcede = pObjAcceso.UsuarioConcede;
                     v.FechaConcede   = pObjAcceso.FechaConcede;
                     v.UsuarioDenega  = pObjAcceso.UsuarioDenega;
                     v.FechaDenega    = pObjAcceso.FechaDenega;
                     dbLiga.Accesos.Update(v);
                 }
             }
             else
             {
                 //grabar
                 dbLiga.Accesos.Add(pObjAcceso);
             }
             dbLiga.SaveChanges();
             return(pObjAcceso.Id);
         }
     }
     catch (Exception e)
     {
         return(0);
     }
 }
示例#25
0
        public JsonResult GuardarAcceso(int idAcceso, string idCategoriaAcceso, string idAccesoPadre, string nombreAcceso,
                                        string descripcion, string icono, string urlAcceso, string estado)
        {
            int idCat, idAccPadre;

            int.TryParse(idCategoriaAcceso, out idCat);
            int.TryParse(idAccesoPadre, out idAccPadre);
            bool response;
            var  accesosBo  = new AccesosBo();
            var  dataAcceso = new Accesos
            {
                IdAcceso          = idAcceso,
                IdCategoriaAcceso = idCat,
                NombreAcceso      = nombreAcceso,
                Descripcion       = descripcion,
                Icono             = icono,
                UrlAcceso         = urlAcceso,
                Estado            = "true".Equals(estado.ToLower())
            };

            if (idAccPadre > 0)
            {
                dataAcceso.IdAccesoPadre = idAccPadre;
            }

            if (accesosBo.GetAcceso(idAcceso) != null)
            {
                response = accesosBo.UpdateAcceso(dataAcceso).IdAcceso > 0;
            }
            else
            {
                response = accesosBo.InsertAcceso(dataAcceso).IdAcceso > 0;
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
示例#26
0
        public static Class.ListaDeAccesos Actualizar(Class.ListaDeAccesos model)
        {
            var db = new TemplateEntities1();

            // var accesos = db.Accesos.Where(x => x.RolId == model.RolId);
            if (model.RolId == null)
            {
                var nuevoRol = db.Roles.Create();
                nuevoRol.Activo = model.Activo;
                nuevoRol.Nombre = model.NombreRol;
                db.Roles.Add(nuevoRol);
                db.SaveChanges();

                if (!string.IsNullOrEmpty(model.Modulos))
                {
                    var modulos = model.Modulos.Split(',').Select(n => n).ToList();
                    foreach (var item in modulos)
                    {
                        var nuevoAcceso = db.Accesos.Create();
                        nuevoAcceso.RolId    = nuevoRol.RolId;
                        nuevoAcceso.ModuloId = Convert.ToInt32(item);
                        db.Accesos.Add(nuevoAcceso);
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                var editarRol = db.Roles.First(x => x.RolId == model.RolId);
                editarRol.Activo = model.Activo;
                editarRol.Nombre = model.NombreRol;
                db.SaveChanges();

                using (var ctx = new TemplateEntities1())
                {
                    var listaAccesos = db.Accesos.Where(x => x.RolId == model.RolId).ToList();
                    if (listaAccesos.Any())
                    {
                        foreach (var item in listaAccesos)
                        {
                            var id = item.AccesoId;
                            var a  = new Accesos()
                            {
                                AccesoId = id
                            };
                            ctx.Accesos.Attach(a);
                            ctx.Accesos.Remove(a);
                            ctx.SaveChanges();
                        }
                    }
                }

                if (!string.IsNullOrEmpty(model.Modulos))
                {
                    var modulos = model.Modulos.Split(',').Select(n => n).ToList();
                    foreach (var item in modulos)
                    {
                        var nuevoAcceso = db.Accesos.Create();
                        nuevoAcceso.RolId    = model.RolId;
                        nuevoAcceso.ModuloId = Convert.ToInt32(item);
                        db.Accesos.Add(nuevoAcceso);
                        db.SaveChanges();
                    }
                }
            }
            return(Funciones.GetListaAccesos(model.RolId));
        }
        public async Task <HttpResponseMessage> Add()
        {
            var    folderName  = "Content/Photos";
            var    CurrentTime = Helper.Now();
            string json        = "";
            var    fromAndroid = false;

            var PATH           = HttpContext.Current.Server.MapPath("~/" + folderName);
            var rootUrl        = Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.AbsolutePath, String.Empty);
            var streamProvider = new MultipartFormDataStreamProvider(PATH);


            if (Request.Content.IsMimeMultipartContent())
            {
                await Request.Content.ReadAsMultipartAsync(streamProvider);

                var PIN         = streamProvider.FormData["Pin"];
                var Plate       = streamProvider.FormData["Plate"];
                var Cone        = streamProvider.FormData["Cone"];
                var IdStreet    = Guid.Parse(streamProvider.FormData["IdStreet"]);
                var NumberHouse = streamProvider.FormData["NumberHouse"];
                var IdSubject   = Guid.Parse(streamProvider.FormData["IdSubject"]);
                var Photo       = "";

                Visitantes newVisitor = (from us in db.Visitantes where us.pin == PIN select us).FirstOrDefault();
                Calles     street     = (from ca in db.Calles where ca.id_calle == IdStreet select ca).FirstOrDefault();
                Asuntos    subject    = (from sub in db.Asuntos where sub.id_asunto == IdSubject select sub).FirstOrDefault();

                Domicilios address = (from dom in db.Domicilios where dom.id_calle == IdStreet && dom.no_casa == NumberHouse select dom).FirstOrDefault();

                if (newVisitor == null)
                {
                    json = Helper.toJson(false, "No existe el visitante");

                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent(json.ToString(), Encoding.UTF8, "application/json")
                    });
                }

                if (address == null)
                {
                    json = Helper.toJson(false, "No existe el domicilio");

                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent(json.ToString(), Encoding.UTF8, "application/json")
                    });
                }

                foreach (MultipartFileData fileData in streamProvider.FileData)
                {
                    if (string.IsNullOrEmpty(fileData.Headers.ContentDisposition.FileName))
                    {
                        return(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
                    }
                    string fileName = fileData.Headers.ContentDisposition.FileName;
                    if (fileName.StartsWith("\"") && fileName.EndsWith("\""))
                    {
                        fileName = fileName.Trim('"');
                    }
                    if (fileName.Contains(@"/") || fileName.Contains(@"\"))
                    {
                        fileName = Path.GetFileName(fileName);
                    }

                    string ext = Path.GetExtension(fileName);

                    var phototemp = Guid.NewGuid().ToString().ToUpper() + ext;
                    var photo     = Guid.NewGuid().ToString().ToUpper() + ext;
                    var lastphoto = Guid.NewGuid().ToString().ToUpper() + ext;

                    File.Move(fileData.LocalFileName, Path.Combine(PATH, phototemp));

                    string text = System.IO.File.ReadAllText(Path.Combine(PATH, phototemp));

                    string base64 = text.Split(',')[1];
                    if (Helper.IsBase64(base64))
                    {
                        fromAndroid = true;
                        byte[] bytes = Convert.FromBase64String(base64);
                        using (Image image = Image.FromStream(new MemoryStream(bytes)))
                        {
                            image.Save(Path.Combine(PATH, photo), ImageFormat.Jpeg);  // Or Png
                        }
                    }
                    else
                    {
                        File.Move(fileData.LocalFileName, Path.Combine(PATH, photo));
                    }
                    // First load the image somehow
                    Image myImage = Image.FromFile(Path.Combine(PATH, photo), true);

                    if (myImage.Width < myImage.Height)
                    {
                        Helper.RotateAndSaveImage(Path.Combine(PATH, photo), Path.Combine(PATH, lastphoto));
                    }
                    else
                    {
                        myImage.Save(Path.Combine(PATH, lastphoto), System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                    // Save the image with a quality of 50%
                    myImage.Dispose();

                    Image LastImage = Image.FromFile(Path.Combine(PATH, lastphoto), true);
                    Helper.SaveJpeg(Path.Combine(PATH, "min" + lastphoto), LastImage, 40);
                    LastImage.Dispose();

                    if (File.Exists(Path.Combine(PATH, phototemp)))
                    {
                        File.Delete(Path.Combine(PATH, phototemp));
                    }
                    if (File.Exists(Path.Combine(PATH, photo)))
                    {
                        File.Delete(Path.Combine(PATH, photo));
                    }
                    Photo = lastphoto;
                }

                try
                {
                    Accesos acceso = new Accesos();
                    acceso.id_acceso      = Guid.NewGuid();
                    acceso.id_visitante   = newVisitor.id_visitante;
                    acceso.id_asunto      = IdSubject;
                    acceso.id_domicilio   = address.id_domicilio;
                    acceso.fecha          = Helper.Now();
                    acceso.placa          = Plate == "undefined" ? "" : Plate;
                    acceso.cono           = Cone == "undefined" ? "" : Cone;
                    acceso.identificacion = Photo;

                    db.Accesos.Add(acceso);

                    db.SaveChanges();

                    if (fromAndroid)
                    {
                        json = Helper.toJson(true, "Acceso Grabado");
                    }
                    else
                    {
                        json = Helper.toJson(true, "Acceso Grabado");
                    }


                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent(json.ToString(), Encoding.UTF8, "application/json")
                    });
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            //Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",ve.PropertyName, ve.ErrorMessage);

                            EventLog eventLog = new EventLog("Application");

                            eventLog.Source = "BonaterraSite";
                            eventLog.WriteEntry("- Property: " + ve.PropertyName + ", Error: " + ve.ErrorMessage, EventLogEntryType.Information, 101, 1);
                        }

                        json = Helper.toJson(false, "No se pudo guardar el acceso");

                        return(new HttpResponseMessage()
                        {
                            Content = new StringContent(json.ToString(), Encoding.UTF8, "application/json")
                        });
                    }
                    throw;
                }
            }
            json = Helper.toJson(false, "Error");

            return(new HttpResponseMessage()
            {
                Content = new StringContent(json.ToString(), Encoding.UTF8, "application/json")
            });
        }
示例#28
0
        public Object traeLlamadas(ParseTreeNode raiz)
        {
            String eti = raiz.Term.Name;

            switch (eti)
            {
            case "LLAMADAID_OBJ":
            {
                if (raiz.ChildNodes.Count > 0)
                {
                    Accesos acceso = new Accesos(0, 0, this.clase);
                    acceso.SetArchivoOrigen(archivo);
                    foreach (ParseTreeNode n in raiz.ChildNodes)
                    {
                        Expresion ex = (Expresion)traeLlamadas(n);
                        if (ex != null)
                        {
                            acceso.AddExpresion(ex);
                        }
                    }
                    return(acceso);
                }
                break;
            }

            case "LLAMADA":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    if (raiz.ChildNodes.ElementAt(1).ToString().Equals("L_EXPRE"))
                    {
                        String  id    = raiz.ChildNodes.ElementAt(0).Token.Text.ToLower();    //MINUSCULAS
                        int     linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                        int     col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;
                        Llamada llam  = new Llamada(id, linea, col, this.clase);
                        llam.SetArchivoOrigen(archivo);
                        if (raiz.ChildNodes.ElementAt(1).ChildNodes.Count > 0)        //SI EL HIJO DERECHO TIENE MAS DE UN HIJO ENTONCES LO RECORRO COMO EXP
                        {
                            foreach (ParseTreeNode n in raiz.ChildNodes.ElementAt(1).ChildNodes)
                            {
                                Expresion aux = (Expresion)recorreExpresion(n); //LOS TOMO...
                                if (aux != null)                                //SI NO ES NULL...
                                {
                                    llam.AddExpresion(aux);                     //LO ANADO
                                }
                            }
                        }
                        return(llam);
                    }
                    else if (raiz.ChildNodes.ElementAt(1).ToString().Equals("DIMS"))
                    {
                        //NECESITO HACER LA EXPRESION PARA ACCESO A ARREGLO
                        // id + DIMS
                        String id    = raiz.ChildNodes.ElementAt(0).Token.Text.ToLower();
                        int    linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                        int    col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                        List <Expresion> expresiones = (List <Expresion>)getDimensiones(raiz.ChildNodes.ElementAt(1));

                        if (expresiones != null)
                        {
                            ValorArreglo val = new ValorArreglo(id, expresiones, linea, col, clase);
                            return(val);
                        }
                    }
                }
                else if (raiz.ChildNodes.Count == 3)
                {
                    if (raiz.ChildNodes.ElementAt(0).ToString().Contains("obtener") || raiz.ChildNodes.ElementAt(0).ToString().Contains("buscar"))
                    {
                        String id    = raiz.ChildNodes.ElementAt(0).Token.Text.ToLower();     //MINUSCULAS
                        int    linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                        int    col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                        Llamada llam = new Llamada(id, linea, col, this.clase);

                        ASTTreeExpresion ar  = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(1), clase, archivo);
                        Expresion        uno = (Expresion)ar.ConstruyeASTExpresion();

                        ar = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(2), clase, archivo);
                        Expresion dos = (Expresion)ar.ConstruyeASTExpresion();

                        if (uno != null && dos != null)
                        {
                            llam.AddExpresion(uno);
                            llam.AddExpresion(dos);
                            return(llam);
                        }
                    }
                }
                break;
            }

            case "identificador":
            {
                int           linea = raiz.Token.Location.Line;
                int           col   = raiz.Token.Location.Column;
                String        id    = raiz.Token.Text.ToLower();//MINUSCULAS
                Identificador ide   = new Identificador(id, col, linea, this.clase);
                ide.SetArchivoOrigen(archivo);
                return(ide);
            }

            case "DECLARACION_OBJ":
            {
                if (raiz.ChildNodes.Count == 3)
                {
                    String           tipo       = (String)dameTipo(raiz.ChildNodes.ElementAt(1));
                    List <Expresion> parametros = new List <Expresion>();
                    foreach (ParseTreeNode nodo in raiz.ChildNodes.ElementAt(2).ChildNodes)
                    {
                        Expresion aux = (Expresion)recorreExpresion(nodo);
                        if (aux != null)
                        {
                            parametros.Add(aux);
                        }
                    }
                    if (tipo != null)
                    {
                        int         linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                        int         col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;
                        NuevoObjeto ob    = new NuevoObjeto(parametros, tipo, linea, col, this.clase);
                        ob.SetArchivoOrigen(archivo);
                        return(ob);
                    }
                }
                break;
            }

            case "DECLARACION_ARR":
            {
                if (raiz.ChildNodes.Count == 3)
                {
                    String           tipo        = (String)dameTipo(raiz.ChildNodes.ElementAt(1));//OBTENGO EL TIPO DEL ARREGLO
                    int              linea       = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int              col         = raiz.ChildNodes.ElementAt(0).Token.Location.Column;
                    List <Expresion> dimensiones = (List <Expresion>)getDimensiones(raiz.ChildNodes.ElementAt(2));      //OBTENGO LAS DIMENSIONES

                    if (tipo != null)
                    {
                        NuevoArreglo nuev = new NuevoArreglo(tipo, dimensiones, linea, col, clase);
                        return(nuev);
                    }
                }
                break;
            }

            case "OPCS_NUEVO":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int colum = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    NuevoListadoOpcs opcs = new NuevoListadoOpcs(this.clase.ToLower(), linea, colum);
                    return(opcs);
                }
                break;
            }

            case "FUN_CADENA":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    ASTTreeExpresion arbol = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(1), clase, archivo);
                    Expresion        exp   = (Expresion)arbol.ConstruyeASTExpresion();

                    if (exp != null)
                    {
                        ACadena cad = new ACadena(exp, clase, linea, col);
                        return(cad);
                    }
                }
                break;
            }

            case "FUN_SUBCAD":
            {
                if (raiz.ChildNodes.Count == 4)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    ASTTreeExpresion arbol  = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(1), clase, archivo);
                    Expresion        cadena = (Expresion)arbol.ConstruyeASTExpresion();

                    arbol = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(2), clase, archivo);
                    Expresion num1 = (Expresion)arbol.ConstruyeASTExpresion();

                    arbol = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(3), clase, archivo);
                    Expresion num2 = (Expresion)arbol.ConstruyeASTExpresion();

                    if (cadena != null && num1 != null && num2 != null)
                    {
                        SubCade s = new SubCade(cadena, num1, num2, linea, col, clase);
                        return(s);
                    }
                }
                break;
            }

            case "FUN_POSCAD":
            {
                if (raiz.ChildNodes.Count == 3)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    ASTTreeExpresion arbol  = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(1), clase, archivo);
                    Expresion        cadena = (Expresion)arbol.ConstruyeASTExpresion();

                    arbol = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(2), clase, archivo);
                    Expresion posicion = (Expresion)arbol.ConstruyeASTExpresion();

                    if (cadena != null && posicion != null)
                    {
                        PosCade posca = new PosCade(cadena, posicion, clase, linea, col);
                        return(posca);
                    }
                }
                break;
            }

            case "FUN_BOOLEAN":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    ASTTreeExpresion expr      = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(1), clase, archivo);
                    Expresion        expresion = (Expresion)expr.ConstruyeASTExpresion();

                    if (expresion != null)
                    {
                        return(new ABooleano(expresion, clase, linea, col));
                    }
                }
                break;
            }

            case "FUN_ENTERO":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    ASTTreeExpresion expr      = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(1), clase, archivo);
                    Expresion        expresion = (Expresion)expr.ConstruyeASTExpresion();

                    if (expresion != null)
                    {
                        return(new AEntero(expresion, clase, linea, col));
                    }
                }
                break;
            }

            case "FUN_TAM":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    ASTTreeExpresion expr      = new ASTTreeExpresion(raiz.ChildNodes.ElementAt(1), clase, archivo);
                    Expresion        expresion = (Expresion)expr.ConstruyeASTExpresion();

                    if (expresion != null)
                    {
                        FunTam f = new FunTam(expresion, clase, linea, col);
                        return(f);
                    }
                }
                break;
            }

            case "FUN_RANDOM":
            {
                if (raiz.ChildNodes.Count == 1)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    FunRandom r = new FunRandom(clase, linea, col);
                    return(r);
                }
                else if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    List <Expresion> exp = new List <Expresion>();

                    foreach (ParseTreeNode nodo in raiz.ChildNodes.ElementAt(1).ChildNodes)
                    {
                        Expresion aux = (Expresion)recorreExpresion(nodo);
                        if (aux != null)
                        {
                            exp.Add(aux);
                        }
                    }

                    FunRandom r = new FunRandom(exp, clase, linea, col);
                    return(r);
                }
                break;
            }

            case "FUN_MIN":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;
                    if (raiz.ChildNodes.ElementAt(1).ToString().Equals("L_EXPRE"))
                    {
                        List <Expresion> expresiones = new List <Expresion>();
                        foreach (ParseTreeNode nodo in raiz.ChildNodes.ElementAt(1).ChildNodes)
                        {
                            Expresion exp = (Expresion)recorreExpresion(nodo);
                            if (exp != null)
                            {
                                expresiones.Add(exp);
                            }
                        }

                        ///AQUI RETORNO
                        FunMin f = new FunMin(expresiones, clase, linea, col);
                        return(f);
                    }
                    else
                    {
                        String idArreglo = raiz.ChildNodes.ElementAt(1).Token.Text.ToLower();
                        FunMin f         = new FunMin(idArreglo.ToLower(), clase, linea, col);
                        return(f);
                    }
                }
                break;
            }

            case "FUN_MAX":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;
                    if (raiz.ChildNodes.ElementAt(1).ToString().Equals("L_EXPRE"))
                    {
                        List <Expresion> expresiones = new List <Expresion>();
                        foreach (ParseTreeNode nodo in raiz.ChildNodes.ElementAt(1).ChildNodes)
                        {
                            Expresion exp = (Expresion)recorreExpresion(nodo);
                            if (exp != null)
                            {
                                expresiones.Add(exp);
                            }
                        }

                        /// AQUI RETORNO
                        FunMax f = new FunMax(expresiones, clase, linea, col);
                        return(f);
                    }
                    else
                    {
                        String idArreglo = raiz.ChildNodes.ElementAt(1).Token.Text.ToLower();
                        FunMax f         = new FunMax(idArreglo.ToLower(), clase, linea, col);
                        return(f);
                    }
                }
                break;
            }

            case "FUN_POW":
            {
                if (raiz.ChildNodes.Count == 3)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion bas = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));
                    Expresion pot = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(2));

                    if (bas != null && pot != null)
                    {
                        FunPow po = new FunPow(bas, pot, clase, linea, col);
                        return(po);
                    }
                }
                break;
            }

            case "FUN_LOG":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion exp = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));

                    if (exp != null)
                    {
                        Logaritmo l = new Logaritmo(exp, clase, linea, col);
                        return(l);
                    }
                }
                break;
            }

            case "FUN_LOG10":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion exp = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));

                    if (exp != null)
                    {
                        LogTen l = new LogTen(exp, clase, linea, col);
                        return(l);
                    }
                }
                break;
            }

            case "FUN_ABS":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion exp = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));

                    if (exp != null)
                    {
                        FunAbs abs = new FunAbs(exp, clase, linea, col);
                        return(abs);
                    }
                }
                break;
            }

            case "FUN_SIN":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion exp = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));

                    if (exp != null)
                    {
                        Seno s = new Seno(exp, clase, linea, col);
                        return(s);
                    }
                }
                break;
            }

            case "FUN_COS":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion exp = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));

                    if (exp != null)
                    {
                        Coseno c = new Coseno(exp, clase, linea, col);
                        return(c);
                    }
                }
                break;
            }

            case "FUN_TAN":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion exp = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));

                    if (exp != null)
                    {
                        Tangente t = new Tangente(exp, clase, linea, col);
                        return(t);
                    }
                }
                break;
            }

            case "FUN_SQRT":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion exp = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));

                    if (exp != null)
                    {
                        Raiz r = new Raiz(exp, clase, linea, col);
                        return(r);
                    }
                }
                break;
            }

            case "FUN_PI":
            {
                if (raiz.ChildNodes.Count == 1)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;
                    Pi  p     = new Pi(clase, linea, col);
                    return(p);
                }
                break;
            }

            case "FUN_HOY":
            {
                if (raiz.ChildNodes.Count == 1)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    FunHoy hoy = new FunHoy(clase, linea, col);
                    return(hoy);
                }
                break;
            }

            case "FUN_AHORA":
            {
                if (raiz.ChildNodes.Count == 1)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    FunAhora ahora = new FunAhora(clase, linea, col);
                    return(ahora);
                }
                break;
            }

            case "FUN_AFECHA":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion exp = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));

                    if (exp != null)
                    {
                        FunAFecha r = new FunAFecha(exp, clase, linea, col);
                        return(r);
                    }
                }
                break;
            }

            case "FUN_TOHORA":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion exp = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));

                    if (exp != null)
                    {
                        FunToHora f = new FunToHora(exp, clase, linea, col);
                        return(f);
                    }
                }
                break;
            }

            case "FUN_TOFECHAHORA":
            {
                if (raiz.ChildNodes.Count == 2)
                {
                    int linea = raiz.ChildNodes.ElementAt(0).Token.Location.Line;
                    int col   = raiz.ChildNodes.ElementAt(0).Token.Location.Column;

                    Expresion exp = (Expresion)recorreExpresion(raiz.ChildNodes.ElementAt(1));

                    if (exp != null)
                    {
                        FunFechaHora f = new FunFechaHora(exp, clase, linea, col);
                        return(f);
                    }
                }
                break;
            }
            }
            return(null);
        }
示例#29
0
 public Accesos UpdateAcceso(Accesos acceso)
 {
     return(new AccesosDa().Update(acceso));
 }
示例#30
0
 public Accesos InsertAcceso(Accesos acceso)
 {
     return(new AccesosDa().Insert(acceso));
 }