Beispiel #1
0
    private static string getArticleIdsByGroup()
    {
        string        output = "getArticleIdsByGroup\n";
        PrimaryGroups pg     = new PrimaryGroups();

        pg.GroupId = primaryGroupId;
        List <int> list = Article2GroupManager.getArticleIdsByGroup(pg);

        if (list == null)
        {
            output += "Error! 调用getArticleIdsByGroup失败,返回null。\n";
            errorCount++;
            return(output);
        }
        for (int i = 0; i < count; i++)
        {
            if (!list.Contains(ids[i]))
            {
                output += "Error! id为" + primaryGroupId + "的主分类中未找到id为" + ids[i] + "的文章!\n";
                errorCount++;
            }
            else
            {
                output += "Ok! id为" + primaryGroupId + "的主分类中找到了id为" + ids[i] + "的文章!\n";
            }
        }
        return(output);
    }
Beispiel #2
0
    private static void changeGroupRelation()
    {
        output += "changeGroupRelation\n";

        List <int> list0_pre = Article2GroupManager.getArticleIdsByGroup(primaryGroup[0]);
        List <int> list1_pre = Article2GroupManager.getArticleIdsByGroup(primaryGroup[1]);

        int list1_pre_len = 0;

        if (list1_pre != null)
        {
            list1_pre_len = list1_pre.Count;
        }

        output += "调用changeGroupRelation前,primaryGroup[0]下有" + list0_pre.Count + "篇文章,primaryGroup[1]下有" + list1_pre_len + "篇文章。\n";
        List <int> groupIds = new List <int>();

        groupIds.Add(primaryGroup[0].GroupId);
        groupIds.Add(primaryGroup[1].GroupId);
        for (int i = 0; i < count; i++)
        {
            Article a = new Article();
            a.ArticleId = ids[i];
            ManagerAssist.changeGroupRelation(a, groupIds);
        }
        List <int> list0_post = Article2GroupManager.getArticleIdsByGroup(primaryGroup[0]);
        List <int> list1_post = Article2GroupManager.getArticleIdsByGroup(primaryGroup[1]);

        output += "调用changeGroupRelation前,primaryGroup[0]下有" + list0_post.Count + "篇文章,primaryGroup[1]下有" + list1_post.Count + "篇文章。\n";

        if (list0_pre.Count - list1_pre_len > list0_post.Count - list1_post.Count)
        {
            output += "Ok! changeGroupRelation执行成功!\n";
        }
        else
        {
            output += "Ok! changeGroupRelation执行失败!\n";
            errorCount++;
        }
    }
Beispiel #3
0
    //获取该分类下的所有文章的article的列表(仅读取传入参数中的GroupId字段)
    //返回article的列表List<Article>
    public static List <Article> getArticleListByPrimaryGroup(PrimaryGroups g)
    {
        List <int> articlesByGroupId = Article2GroupManager.getArticleIdsByGroup(g);

        return(getArticleListByArticleIdList(articlesByGroupId));
    }