Exemplo n.º 1
0
 protected DbCommand CreateDbCommand(DbInsertStatement clause)
 {
     return(DbMgr.CreateDbCommand(clause));
 }
Exemplo n.º 2
0
 protected DbCommand CreateDbCommand(DbSelectStatement _query)
 {
     return(DbMgr.CreateDbCommand(_query));
 }
Exemplo n.º 3
0
 protected DbCommand CreateDbCommand(DbDeleteStatement clause)
 {
     return(DbMgr.CreateDbCommand(clause));
 }
Exemplo n.º 4
0
        protected override object GetDbProperty(AuthRole _obj, string property_name)
        {
            if (property_name.Equals("Children"))
            {
                List <int>        child_role_ids = new List <int>();
                DbSelectStatement clause         = DbMgr.CreateSelectClause();
                clause
                .SelectColumn("AuthRoleRole", "ChildRoleID")
                .From("AuthRoleRole")
                .Criteria
                .IsEqual("AuthRoleRole", "ParentRoleID", _obj.RoleID);

                DbCommand    cmd     = DbMgr.CreateDbCommand(clause);
                DbDataReader _reader = cmd.ExecuteReader();
                while (_reader.Read())
                {
                    int?child_role_id = GetInt32(_reader, "ChildRoleID");
                    if (child_role_id != null)
                    {
                        child_role_ids.Add(child_role_id.Value);
                    }
                }
                _reader.Close();
                cmd.Dispose();

                List <AuthRole> child_roles = new List <AuthRole>();
                foreach (int child_role_id in child_role_ids)
                {
                    AuthRole child_role = RepositoryMgr.AuthRoleMgr.FindByRoleID(child_role_id);
                    if (child_role != null)
                    {
                        child_roles.Add(child_role);
                    }
                }
                return(child_roles);
            }
            else if (property_name.Equals("Items"))
            {
                List <int>        item_ids = new List <int>();
                DbSelectStatement clause   = DbMgr.CreateSelectClause();
                clause
                .SelectColumn("AuthRoleItem", "ItemID")
                .From("AuthRoleItem")
                .Criteria
                .IsEqual("AuthRoleItem", "RoleID", _obj.RoleID);

                DbCommand    cmd     = DbMgr.CreateDbCommand(clause);
                DbDataReader _reader = cmd.ExecuteReader();
                while (_reader.Read())
                {
                    int?item_id = GetInt32(_reader, "ItemID");
                    if (item_id != null)
                    {
                        item_ids.Add(item_id.Value);
                    }
                }
                _reader.Close();
                cmd.Dispose();

                List <AuthItem> items = new List <AuthItem>();
                foreach (int item_id in item_ids)
                {
                    AuthItem item = RepositoryMgr.AuthItemMgr.FindById(item_id);
                    if (item != null)
                    {
                        items.Add(item);
                    }
                }
                return(items);
            }
            return(null);
        }