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); } } } } } } }
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); } } } } } }
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); }
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); }
public static User GetSystemUser() { User r = new User(SystemUsername); if (Objectbase.IsNullOrEmpty(r)) { r = null; } return(r); }
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); } }
public static bool CanFieldView(Guid fieldGuid) { if (IsAdministrator) { return(true); } else { FieldPermission p = GetFieldPermission(fieldGuid); return(Objectbase.IsNullOrEmpty(p) ? false : p.CanView); } }
public static bool CanSpecial(Guid entityGuid) { if (IsAdministrator) { return(true); } else { Permission p = GetPermission(entityGuid); return(Objectbase.IsNullOrEmpty(p) ? false : p.CanSpecial); } }
public static bool ForgotMe() { User user = LoggedUser; if (!Objectbase.IsNullOrEmpty(user)) { return(user.UpdateWindowsUserName(null)); } else { return(false); } }
public static bool RememberMe() { User user = LoggedUser; if (!Objectbase.IsNullOrEmpty(user)) { return(user.UpdateWindowsUserName(SystemUsername)); } else { return(false); } }
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); } } } }
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; }
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); }
public static string GetName(Objectbase obj) { return(IsNullOrEmpty(obj) ? string.Empty : obj.DisplayName); }
public static bool IsNullOrEmpty(Objectbase obj) { return(obj == null || (!obj.IsUsable)); }