Exemple #1
0
 public bool TienePermiso(IElementoDeDatos elemento, Sys.Permisos.Operaciones operacion)
 {
     if (this.Usuario == null)
     {
         return(true);    // FIXME: tengo que decir que si por los módulos que no se loguean
     }
     else
     {
         return(this.Usuario.Pemisos.TienePermiso(elemento, operacion));
     }
 }
        public ListaIds GetItemsxTipo(IElementoDeDatos elemento)
        {
            ListaIds items        = new ListaIds();
            string   TipoElemento = elemento.GetType().ToString();

            foreach (Permiso Perm in this)
            {
                if (Perm.Objeto.Tipo == TipoElemento && Perm.Item != null && Perm.Item.Count > 0)
                {
                    for (int i = 0; i < Perm.Item.Count; i++)
                    {
                        items.Add(Perm.Item[i]);
                    }
                }
            }
            return(items);
        }
        public bool TienePermiso(IElementoDeDatos elemento, Operaciones operacion)
        {
            if (this.TieneAccesoGlobal())
            {
                return(true);
            }


            string TipoElemento = elemento.GetType().ToString();

            foreach (Permiso Perm in this)
            {
                if (Perm.Objeto.Tipo == TipoElemento &&
                    ((Perm.Operaciones & operacion) == operacion || (Perm.Operaciones & Operaciones.Total) == Operaciones.Total) &&
                    (Perm.Item == null || Perm.Item.Contains(elemento.Id)))
                {
                    return(true);
                }
            }

            return(TienePermiso(elemento.GetType().BaseType, operacion));
        }
Exemple #4
0
 /// <summary>
 /// Escribe un evento en la tabla sys_log. Se utiliza para registrar operaciones de datos (altas, bajas, ingresos, egresos, etc.)
 /// </summary>
 public static void ActionLog(Lfx.Data.IConnection conn, Log.Acciones action, IElementoDeDatos elemento, string extra1)
 {
     try {
         qGen.Insert Comando = new qGen.Insert("sys_log");
         Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
         Comando.ColumnValues.AddWithValue("estacion", Lfx.Environment.SystemInformation.MachineName);
         if (Lbl.Sys.Config.Actual == null || Lbl.Sys.Config.Actual.UsuarioConectado == null || Lbl.Sys.Config.Actual.UsuarioConectado.Id == 0)
         {
             Comando.ColumnValues.AddWithValue("usuario", null);
         }
         else
         {
             Comando.ColumnValues.AddWithValue("usuario", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
         }
         Comando.ColumnValues.AddWithValue("comando", action.ToString());
         if (elemento == null)
         {
             Comando.ColumnValues.AddWithValue("tabla", null);
             Comando.ColumnValues.AddWithValue("item_id", null);
         }
         else
         {
             if (action == Log.Acciones.LogOn || action == Log.Acciones.LogOnFail)
             {
                 Comando.ColumnValues.AddWithValue("tabla", null);
             }
             else
             {
                 Comando.ColumnValues.AddWithValue("tabla", elemento.TablaDatos);
             }
             Comando.ColumnValues.AddWithValue("item_id", elemento.Id);
         }
         Comando.ColumnValues.AddWithValue("extra1", extra1);
         conn.ExecuteNonQuery(Comando);
     } catch (System.Exception ex) {
         System.Console.WriteLine(ex.ToString());
     }
 }
Exemple #5
0
 public ListaIds GetItemsxTipo(IElementoDeDatos elemento)
 {
     return(this.Usuario.Pemisos.GetItemsxTipo(elemento));
 }
Exemple #6
0
 /// <summary>
 /// Escribe un evento en la tabla sys_log. Se utiliza para registrar operaciones de datos (altas, bajas, ingresos, egresos, etc.)
 /// </summary>
 public static void ActionLog(Lfx.Data.Connection conn, Log.Acciones action, IElementoDeDatos elemento, string extra1)
 {
         try {
                 qGen.Insert Comando = new qGen.Insert(conn, "sys_log");
                 Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                 Comando.Fields.AddWithValue("estacion", Lfx.Environment.SystemInformation.MachineName);
                 if (Lbl.Sys.Config.Actual == null || Lbl.Sys.Config.Actual.UsuarioConectado == null || Lbl.Sys.Config.Actual.UsuarioConectado.Id == 0)
                         Comando.Fields.AddWithValue("usuario", null);
                 else
                         Comando.Fields.AddWithValue("usuario", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
                 Comando.Fields.AddWithValue("comando", action.ToString());
                 if (elemento == null) {
                         Comando.Fields.AddWithValue("tabla", null);
                         Comando.Fields.AddWithValue("item_id", null);
                 } else {
                         if (action == Log.Acciones.LogOn || action == Log.Acciones.LogOnFail)
                                 Comando.Fields.AddWithValue("tabla", null);
                         else
                                 Comando.Fields.AddWithValue("tabla", elemento.TablaDatos);
                         Comando.Fields.AddWithValue("item_id", elemento.Id);
                 }
                 Comando.Fields.AddWithValue("extra1", extra1);
                 conn.Execute(Comando);
         } catch (System.Exception ex) {
                 System.Console.WriteLine(ex.ToString());
         }
 }
 public bool TienePermiso(IElementoDeDatos elemento, Sys.Permisos.Operaciones operacion)
 {
         if (this.Usuario == null)
                 return true;    // FIXME: tengo que decir que si por los módulos que no se loguean
         else
                 return this.Usuario.Pemisos.TienePermiso(elemento, operacion);
 }