Exemple #1
0
        internal static string SavePermissionSql(string roleId, string objType, string objId, PermissionTypes permission)
        {
            DataTable tb = SecuritySettings.Execute(@"select * from xsys_role_permissions where role_id='" +
                                                    roleId + "' and object_type='" + objType + "' and object_id='" + objId + "'");

            int intPer = (int)permission;

            if (tb.Rows.Count > 0)
            {
                return(@"UPDATE [xsys_role_permissions]  "
                       + " SET [permission]=" + intPer
                       + " where role_id='" + roleId + "' and object_type='" + objType + "' and object_id='" + objId + "'");
            }
            else
            {
                return(@"INSERT INTO  [xsys_role_permissions] 
                        ( [role_id],
                          [object_type],
                          [object_id],
                          [permission]
                       ) 
                       VALUES 
                      (" +
                       "'" + roleId + "'," +
                       "'" + objType + "'," +
                       "'" + objId + "', " +
                       intPer +
                       ");"
                       );
            }
        }
Exemple #2
0
        public List <User> getUsers(string groupId)
        {
            string      sql = SecurityDataScripts.GetUserListSQL(groupId);
            DataTable   tb  = SecuritySettings.Execute(sql);
            List <User> ret = new List <User>();

            foreach (DataRow r in tb.Rows)
            {
                User user = new User();
                user.Id          = r["user_id"].ToString();
                user.DisplayName = r["display_name"].ToString();
                if (string.IsNullOrEmpty(user.DisplayName))
                {
                    user.DisplayName = user.Id;
                }
                user.CreateDate = r["create_date"].ToString();
                user.Password   = "";
                user.IsDisable  = r["disabled"] is System.DBNull ? false : (bool)r["disabled"];
                user.IsActive   = r["actived"] is System.DBNull ? false : (bool)r["actived"];
                user.Email      = r["bind_email"].ToString();
                user.Mobile     = r["bind_mobile"].ToString();
                user.GroupId    = r["group_id"].ToString();
                ret.Add(user);
            }
            return(ret);
        }
Exemple #3
0
        public static List <Role> getUserRoles(string userId)
        {
            string      sql = SecurityDataScripts.GetUserRoleListSQL(userId);
            DataTable   tb  = SecuritySettings.Execute(sql);
            List <Role> ret = new List <Role>();

            foreach (DataRow r in tb.Rows)
            {
                Role role = new Role();
                role.Id          = r["role_id"].ToString();
                role.DisplayName = r["display_name"].ToString();
                role.Remark      = r["remark"].ToString();
                ret.Add(role);
            }
            return(ret);
        }