Beispiel #1
0
        public RoleCollection GetRolesNotBelongTo()
        {
            PSCPortal.Framework.Database database = new PSCPortal.Framework.Database("PSCPortalConnectionString");
            RoleCollection result = new RoleCollection();

            using (DbConnection connection = database.GetConnection())
            {
                DbCommand command = database.GetCommand(connection);
                #region SubDomainId
                DbParameter prId = database.GetParameter(System.Data.DbType.Guid, "@SubDomainId", _id);
                command.Parameters.Add(prId);
                #endregion
                command.CommandText = @"SELECT 
	                                    a.[RoleId],
	                                    [RoleName],
	                                    [RoleDescription]
                                    FROM 
	                                    dbo.[Role] a
	                                    inner join SubDomainInRole b on a.RoleId = b.RoleId 
                                    WHERE 
	                                    SubDomainId!=@SubDomainId"    ;
                command.CommandType = System.Data.CommandType.Text;
                command.Connection  = connection;
                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Role item = new Role(reader);
                    result.Add(item);
                }
            }
            return(result);
        }
Beispiel #2
0
        public ArticleCollection GetArticlesBelongTo()
        {
            PSCPortal.Framework.Database database = new PSCPortal.Framework.Database("PSCPortalConnectionString");
            ArticleCollection            result   = new ArticleCollection();

            using (DbConnection connection = database.GetConnection())
            {
                DbCommand command = database.GetCommand(connection);
                #region SubDomainId
                DbParameter prId = database.GetParameter(System.Data.DbType.Guid, "@SubDomainId", _id);
                command.Parameters.Add(prId);
                #endregion

                command.CommandText = @"SELECT 
	                                    a.[ArticleId],
	                                    [ArticleName],
	                                    [ArticleTitle],
                                        b.[IsCheck],
                                        s.[Name] as SubDomainFromName 
                                    FROM 
	                                    dbo.[Article] a 
	                                    inner join SubDomainInArticle b on a.ArticleId = b.ArticleNewId 
                                        inner join SubDomain s on b.SubDomainFromId = s.Id 
                                    WHERE 
	                                    b.SubDomainToId = @SubDomainId AND b.IsCheck = 'false'"    ;
                command.CommandType = System.Data.CommandType.Text;
                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Article item = new Article();
                    if (!reader.IsDBNull(reader.GetOrdinal("ArticleId")))
                    {
                        item.Id = new Guid(reader["ArticleId"].ToString());
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ArticleName")))
                    {
                        item.Name = (string)reader["ArticleName"].ToString();
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("ArticleTitle")))
                    {
                        item.Title = (string)reader["ArticleTitle"].ToString();
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("SubDomainFromName")))
                    {
                        item.SubDomainFromName = (string)reader["SubDomainFromName"];
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("IsCheck")))
                    {
                        item.IsCheck = (bool)reader["IsCheck"];
                    }
                    result.Add(item);
                }
            }
            return(result);
        }
Beispiel #3
0
        public UserCollection GetUsersNotInRole()
        {
            PSCPortal.Framework.Database database = new PSCPortal.Framework.Database("PSCPortalConnectionString");
            UserCollection result = new UserCollection();

            using (DbConnection connection = database.GetConnection())
            {
                DbCommand command = GetUsersNotInByRoleIDCommand(database, this._id);
                command.Connection = connection;
                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    User item = new User(reader);
                    result.Add(item);
                }
            }
            return(result);
        }
Beispiel #4
0
        public static UserInRoleCollection GetRolesByUserID(Guid userID)
        {
            PSCPortal.Framework.Database database = new PSCPortal.Framework.Database("PSCPortalConnectionString");
            UserInRoleCollection         result   = new UserInRoleCollection();

            using (DbConnection connection = database.GetConnection())
            {
                DbCommand command = result.GetRolesByUserIDCommand(database, userID);
                command.Connection = connection;
                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    UserInRole item = new UserInRole(reader);
                    result.Add(item);
                }
            }
            return(result);
        }
Beispiel #5
0
        public RoleCollection GetRolesNotBelongTo()
        {
            PSCPortal.Framework.Database database = new PSCPortal.Framework.Database("PSCPortalConnectionString");
            RoleCollection result = new RoleCollection();

            using (DbConnection connection = database.GetConnection())
            {
                DbCommand command = GetRolesNotBelongToCommand(database);
                command.Connection = connection;
                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Role item = new Role(reader);
                    result.Add(item);
                }
            }
            return(result);
        }
        public static SubDomainCollection GetSubDomainByUser(User user)
        {
            PSCPortal.Framework.Database database = new PSCPortal.Framework.Database("PSCPortalConnectionString");
            SubDomainCollection          result   = new SubDomainCollection();

            using (DbConnection connection = database.GetConnection())
            {
                DbCommand command = database.GetCommand(connection);
                #region RoleId
                DbParameter prId = database.GetParameter(System.Data.DbType.String, "@UserName", user.Name);
                command.Parameters.Add(prId);
                #endregion

                command.CommandText = @"SELECT b.* FROM UserInSubDomain
	                                      a LEFT JOIN SubDomain b
                                          ON a.SubDomainId = b.Id
                                          INNER JOIN [User] c
                                          ON a.UserId = c.UserId
                                          WHERE c.UserName = @UserName and b.IsDelete = 0";//Ngọc - 18122015
                command.CommandType = System.Data.CommandType.Text;
                command.Connection  = connection;
                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    SubDomain item = new SubDomain();
                    if (!reader.IsDBNull(reader.GetOrdinal("Id")))
                    {
                        item.Id = new Guid(reader["Id"].ToString());
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("Name")))
                    {
                        item.Name = reader["Name"].ToString();
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("OldVisitors")))
                    {
                        item.OldVisitors = (int)reader["OldVisitors"];
                    }
                    result.Add(item);
                }
            }
            return(result);
        }
Beispiel #7
0
        public Topic GetTopic()
        {
            PSCPortal.Framework.Database database = new PSCPortal.Framework.Database("PSCPortalConnectionString");
            Topic result = new Topic();

            using (DbConnection connection = database.GetConnection())
            {
                DbCommand command = GetTopicBelongToCommand(database);
                command.Connection = connection;
                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    result = new Topic {
                        Id = new Guid(reader["TopicId"].ToString())
                    };
                }
            }
            return(result);
        }
        public static SubDomainCollection GetSubDomainCollection(Role role)
        {
            PSCPortal.Framework.Database database = new PSCPortal.Framework.Database("PSCPortalConnectionString");
            SubDomainCollection          result   = new SubDomainCollection();

            using (DbConnection connection = database.GetConnection())
            {
                DbCommand command = database.GetCommand(connection);
                #region RoleId
                DbParameter prId = database.GetParameter(System.Data.DbType.Guid, "@RoleId", role.Id);
                command.Parameters.Add(prId);
                #endregion

                command.CommandText = @"SELECT 
	                                    a.[Id],
	                                    [Name]
                                    FROM 
	                                    dbo.[SubDomain] a
	                                    inner join SubDomainInRole b on a.Id = b.SubDomainId 
                                    WHERE 
	                                    RoleId=@RoleId and a.IsDelete = 0"    ;//Ngọc - 18122015
                command.CommandType = System.Data.CommandType.Text;
                command.Connection  = connection;
                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    SubDomain item = new SubDomain();
                    if (!reader.IsDBNull(reader.GetOrdinal("Id")))
                    {
                        item.Id = new Guid(reader["Id"].ToString());
                    }
                    if (!reader.IsDBNull(reader.GetOrdinal("Name")))
                    {
                        item.Name = reader["Name"].ToString();
                    }
                    result.Add(item);
                }
            }
            return(result);
        }