コード例 #1
0
    private static void getArticleListOfCertainPrimaryGroup()
    {
        output += "getArticleListOfCertainPrimaryGroup\n";

        GroupNode gn = new GroupNode();

        gn.Id = primaryGroup.GroupId;
        List <Article> list = NewsAssist.getArticleListOfCertainPrimaryGroup(gn);

        if (list == null)
        {
            output += "Error! getArticleListOfCertainPrimaryGroup失败,返回null。\n";
            errorCount++;
            return;
        }

        if (list.Count < count)
        {
            output += "Error! 返回列表长度(=" + list.Count + ")小于测试用例数量!\n";
            errorCount++;
        }
        else
        {
            output += "Ok! 返回列表长度(=" + list.Count + ")不少于测试用例数量!\n";
        }
    }
コード例 #2
0
    private static void getArticleListByDynamicSearch()
    {
        output += "getArticleListByDynamicSearch\n";

        // add tags
        string name = "测试 样例";
        Tag    t    = new Tag(name, name, primaryGroup.GroupId, DateTime.Now, 0);

        t.TagId = TagManager.addTag(t);
        if (t.TagId < 0)
        {
            output += "Error! 新增Tag\"" + name + "\"失败!返回值为" + t.TagId + "\n";
            errorCount++;
            return;
        }

        // Test
        GroupNode gn = new GroupNode();

        gn.Id = t.TagId;
        List <Article> list = NewsAssist.getArticleListByDynamicSearch(gn);

        if (list == null)
        {
            output += "Error! getArticleListByDynamicSearch失败,返回null。\n";
            errorCount++;
            return;
        }
        if (list.Count < count)
        {
            output += "Error! 返回列表长度(=" + list.Count + ")小于测试用例数量!\n";
            errorCount++;
        }
        else
        {
            output += "Ok! 返回列表长度(=" + list.Count + ")不少于测试用例数量!\n";
        }

        // delete tag
        if (!TagManager.deleteTag(t))
        {
            output += "Error! 删除Tag(id为\"" + t.TagId + "\")失败!\n";
            errorCount++;
            return;
        }
    }
コード例 #3
0
ファイル: SearchResult.aspx.cs プロジェクト: zccshome/sepj2
    private void searchArticle(string keyword, int primaryId)
    {
        GroupNode      gn          = new GroupNode("", primaryId, true, primaryId, false);
        List <Article> articleList = NewsAssist.getArticleListOfCertainPrimaryGroup(gn);

        if (articleList == null)
        {
            return;
        }
        foreach (Article a in articleList)
        {
            string abstractString = a.Abstrct;
            if (abstractString.Contains(keyword))
            {
                finalArticleList.Add(a);
            }
        }
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int     articleId = Convert.ToInt32(Request["articleId"]);
        Article a         = NewsAssist.getArticleByIdWrapper(articleId);

        /*titleLable.Text = "哈哈";
         * titleLable.Font.Size = 16;
         * contentLabel.Text = "文件找不到或已损坏!";*/
        titleLable.Text      = a.Title;
        titleLable.Font.Size = 16;
        string content = NewsAssist.getArticleContentByArticleModel(a);

        if (content != null)
        {
            contentLabel.Text = content;
        }
        else
        {
            contentLabel.Text      = "文件找不到或已损坏!";
            contentLabel.ForeColor = Color.Red;
        }
        contentLabel.Font.Size = 11;
    }
コード例 #5
0
ファイル: showArticles.aspx.cs プロジェクト: zccshome/sepj2
    protected void Page_Load(object sender, EventArgs e)
    {
        user = (User)Session["user"];
        int primary_flag = -1;
        int groupID      = -1;
        int other_flag   = -1;
        int pgid         = -1;

        try
        {
            primary_flag = Int32.Parse(Request["primary"]);
            groupID      = Int32.Parse(Request["gn"]);
            other_flag   = Int32.Parse(Request["other"]);
            pgid         = Int32.Parse(Request["pgid"]);
        }
        catch (Exception e2)
        {
            TableCell titleCell = new TableCell();
            Label     label     = new Label();
            label.Text      = "请求的参数不正确!";
            label.Font.Size = 18;
            label.ForeColor = Color.Red;
            titleCell.Controls.Add(label);
            TableRow tr = new TableRow();
            tr.Controls.Add(titleCell);
            HolderTable.Rows.Add(tr);
            return;
        }

        /*
         * Article a0 = new Article();
         * a0.Title = "唐智慧和汤志辉跳舞,多恶心啊!";
         * a0.Abstrct = "啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊,恶心啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊。真尼玛恶心啊啊啊啊啊啊啊啊!!!!来来来,我们把他揍一顿吧,啊哈哈哈哈!";
         * a0.ArticleId = 0;
         *
         * Article a1 = new Article();
         * a1.Title = "唐智慧和汤志辉跳舞,多恶心啊!";
         * a1.Abstrct = "啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊,恶心啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊。真尼玛恶心啊啊啊啊啊啊啊啊";
         * a1.ArticleId = 1;
         */

        List <Article> articles;

        /*
         * articles = new List<Article>();
         * articles.Add(a0);
         * articles.Add(a1);
         */

        GroupNode gn = new GroupNode();

        gn.Id             = groupID;
        gn.PrimaryGroupId = pgid;

        if (other_flag == 1)
        {
            if (user != null)
            {
                //主分类
                if (primary_flag == 1)
                {
                    articles = NewsAssist.getArticleListOfOthers(user.UserId, null);
                }
                else//子分类
                {
                    articles = NewsAssist.getArticleListOfOthers(user.UserId, gn);
                }
            }
            else
            {
                //主分类
                if (primary_flag == 1)
                {
                    articles = NewsAssist.getArticleListOfOthersForNoLogin(-1, null);
                }
                else//子分类
                {
                    articles = NewsAssist.getArticleListOfOthersForNoLogin(-1, gn);
                }
            }
        }
        else
        {
            if (primary_flag == 1)
            {
                articles = NewsAssist.getArticleListOfCertainPrimaryGroup(gn);
            }
            else
            {
                articles = NewsAssist.getArticleListByDynamicSearch(gn);
            }
        }

        if (articles != null)
        {
            foreach (Article article in articles)
            {
                TableCell titleCell = new TableCell();

                HyperLink titleLink = new HyperLink();
                titleLink.Font.Size   = 16;
                titleLink.Text        = article.Title;
                titleLink.NavigateUrl = "OneNews.aspx?articleId=" + article.ArticleId;
                titleCell.Controls.Add(titleLink);

                TableRow row = new TableRow();
                row.Cells.Add(titleCell);

                HolderTable.Rows.Add(row);

                TableRow row2          = new TableRow();
                Label    abstractlabel = new Label();
                abstractlabel.Font.Size = 10;
                abstractlabel.ForeColor = Color.White;
                abstractlabel.Text      = article.Abstrct;
                TableCell abstractCell = new TableCell();
                abstractCell.Controls.Add(abstractlabel);

                row2.Controls.Add(abstractCell);

                HolderTable.Rows.Add(row2);
            }
        }
        else
        {
            TableCell titleCell = new TableCell();
            Label     label     = new Label();
            label.Text      = "该分类暂时不存在文章!";
            label.Font.Size = 18;
            label.ForeColor = Color.Red;
            titleCell.Controls.Add(label);
            TableRow tr = new TableRow();
            tr.Controls.Add(titleCell);
            HolderTable.Rows.Add(tr);
        }
    }