Example #1
0
 public Permissions(UserRole userRole)
 {
     if (!Objectbase.IsNullOrEmpty(userRole))
     {
         this.mUserRole = userRole;
         using (SqlDataReader dr = AppDAL.PermssionSelect_AllEntityByUser(userRole.ObjectGuid))
         {
             if (dr != null)
             {
                 while (dr.Read())
                 {
                     Permission obj = null;
                     if (AppShared.IsNull(dr[Permission.Columns.PermissionEntityGuid]))
                     {
                         Entity entity = new Entity();
                         if (entity.Populate(dr))
                         {
                             obj = new Permission(userRole, entity);
                             this.Add(obj);
                         }
                     }
                     else
                     {
                         obj = new Permission();
                         if (obj.Populate(dr))
                         {
                             this.Add(obj);
                         }
                     }
                 }
             }
         }
     }
 }
Example #2
0
 public FieldPermissions(UserRole userRole)
 {
     if (!Objectbase.IsNullOrEmpty(userRole))
     {
         this.mUserRole = userRole;
         using (SqlDataReader dr = AppDAL.FieldPermssionSelectAllEntityByUser(userRole.ObjectGuid))
         {
             if (dr != null)
             {
                 while (dr.Read())
                 {
                     FieldPermission obj = null;
                     if (AppShared.IsNull(dr[FieldPermission.Columns.PermisionFieldGuid]))
                     {
                         Field field = new Field();
                         if (field.Populate(dr))
                         {
                             obj = new FieldPermission(userRole, field);
                             this.Add(obj);
                         }
                     }
                     else
                     {
                         obj = new FieldPermission();
                         if (obj.Populate(dr))
                             this.Add(obj);
                     }
                 }
             }
         }
     }
 }
Example #3
0
        internal static FieldPermission GetFieldPermission(Guid fieldGuid)
        {
            FieldPermission r = null;

            if (mUserFieldPermissions == null)
            {
                lock (_lock)
                {
                    if (mUserFieldPermissions == null)
                    {
                        mUserFieldPermissions = new Dictionary <Guid, CacheObject <FieldPermission> >();
                    }
                }
            }

            if (mUserFieldPermissions != null)
            {
                if (mUserFieldPermissions.ContainsKey(fieldGuid))
                {
                    r = mUserFieldPermissions[fieldGuid].Item;
                }
                else
                {
                    r = new FieldPermission(UserRoleGuid, fieldGuid);
                    if (!Objectbase.IsNullOrEmpty(r))
                    {
                        mUserFieldPermissions.Add(fieldGuid, new CacheObject <FieldPermission>(r));
                    }
                }
            }

            return(r);
        }
Example #4
0
        internal static Permission GetPermission(Guid entityGuid)
        {
            Permission r = null;

            if (mUserPermissions == null)
            {
                lock (_lock)
                {
                    if (mUserPermissions == null)
                    {
                        mUserPermissions = new Dictionary <Guid, CacheObject <Permission> >();
                    }
                }
            }

            if (mUserPermissions != null)
            {
                if (mUserPermissions.ContainsKey(entityGuid))
                {
                    r = mUserPermissions[entityGuid].Item;
                }
                else
                {
                    r = new Permission(UserRoleGuid, entityGuid);
                    if (!Objectbase.IsNullOrEmpty(r))
                    {
                        mUserPermissions.Add(entityGuid, new CacheObject <Permission>(r));
                    }
                }
            }

            return(r);
        }
Example #5
0
        public static User GetSystemUser()
        {
            User r = new User(SystemUsername);

            if (Objectbase.IsNullOrEmpty(r))
            {
                r = null;
            }
            return(r);
        }
Example #6
0
 public override bool Equals(object obj)
 {
     if (object.ReferenceEquals(this, obj))
     {
         return(true);
     }
     else
     {
         Objectbase that = obj as Objectbase;
         return(that != null && this.mObjectGuid == that.mObjectGuid);
     }
 }
Example #7
0
 public static bool CanFieldView(Guid fieldGuid)
 {
     if (IsAdministrator)
     {
         return(true);
     }
     else
     {
         FieldPermission p = GetFieldPermission(fieldGuid);
         return(Objectbase.IsNullOrEmpty(p) ? false : p.CanView);
     }
 }
Example #8
0
 public static bool CanSpecial(Guid entityGuid)
 {
     if (IsAdministrator)
     {
         return(true);
     }
     else
     {
         Permission p = GetPermission(entityGuid);
         return(Objectbase.IsNullOrEmpty(p) ? false : p.CanSpecial);
     }
 }
Example #9
0
        public static bool ForgotMe()
        {
            User user = LoggedUser;

            if (!Objectbase.IsNullOrEmpty(user))
            {
                return(user.UpdateWindowsUserName(null));
            }
            else
            {
                return(false);
            }
        }
Example #10
0
        public static bool RememberMe()
        {
            User user = LoggedUser;

            if (!Objectbase.IsNullOrEmpty(user))
            {
                return(user.UpdateWindowsUserName(SystemUsername));
            }
            else
            {
                return(false);
            }
        }
Example #11
0
 protected void LoadObjectsFromReader(SqlDataReader dr)
 {
     if (dr != null)
     {
         while (dr.Read())
         {
             //T obj = Activator.CreateInstance<T>();
             T obj = Activator.CreateInstance(typeof(T), new object[] { dr }) as T;
             if (!Objectbase.IsNullOrEmpty(obj))
             {
                 this.Add(obj);
             }
         }
     }
 }
Example #12
0
        public bool UpdateChanges()
        {
            bool r = false;

            if (!Objectbase.IsNullOrEmpty(mUserRole))
            {
                foreach (FieldPermission obj in this.Items)
                {
                    if ((obj.CanView))
                        obj.MarkToSave();
                    else
                        obj.MarkToDelete();

                    obj.UpdateChanges();
                }
                r = true;
            }

            return r;
        }
Example #13
0
        public bool UpdateChanges()
        {
            bool r = false;

            if (!Objectbase.IsNullOrEmpty(mUserRole))
            {
                foreach (Permission obj in this.Items)
                {
                    if ((obj.CanCreate || obj.CanView || obj.CanEdit || obj.CanDelete || obj.CanSpecial))
                    {
                        obj.MarkToSave();
                    }
                    else
                    {
                        obj.MarkToDelete();
                    }

                    obj.UpdateChanges();
                }
                r = true;
            }

            return(r);
        }
Example #14
0
 public static string GetName(Objectbase obj)
 {
     return(IsNullOrEmpty(obj) ? string.Empty : obj.DisplayName);
 }
Example #15
0
 public static bool IsNullOrEmpty(Objectbase obj)
 {
     return(obj == null || (!obj.IsUsable));
 }