none
如何高效获取 sharepoint里面 Discussion Boards List 里面的所有 Discussion Topic RRS feed

  • 问题

  • 获取s

    harepoint 里面 Discussion Boards List 里面的所有 Discussion Topic!

    public
     void
     BindAllTopic()
    {
    //绑定帖子
    using (SPSite site = new SPSite(ApplicationConfiguration.webUrl))
    {
    using (SPWeb web = site.OpenWeb())
    {
    //DiscussionBoards 自己封装的一个类<br/>


    List<DiscussionBoards> discassionTopics = new List<DiscussionBoards>()<br/>


     try
    {
    foreach (SPList l in web.Lists)
    {
    //类型为 DiscussionBoard 且为隐藏<br/>


    if (l.BaseTemplate == SPListTemplateType.DiscussionBoard && l.Hidden == false )
    {

    //Response.Write("Lists:" + l.Lists[0].GetType()+"<br />"); listi
    //Response.Write("Folders:" + l.Folders[0].GetType()+"<br />");

    DiscussionBoards topic = null ;
    foreach (SPListItem folder in l.Folders)
    {
    topic = new DiscussionBoards()
    {
    Id = folder.ID,
    Name = folder.Fields["Subject" ].GetFieldValueAsHtml(folder["Subject" ]),
    Items = folder.Fields["Replies" ].GetFieldValueAsHtml(folder["Replies" ])
    ,
    LastModified = Convert.ToDateTime(folder["Last Updated" ].ToString()).ToLocalTime().ToString(),
    CreateBy = folder.Fields["Created By" ].GetFieldValueAsText(folder["Created By" ]),
    Body = folder.Fields["Body" ].GetFieldValueAsHtml(folder["Body" ]),
    Avatars = GetPicByFolderId(folder.ID, folder.ParentList.Title),
    Description = folder.ParentList.Title
    };
    discassionTopics.Add(topic);
    }

    }

    }
    }
    catch (Exception ex)
    {
    throw ex;
    }

    //回复数量排序
    discassionTopics.Sort(MyComDatetime);
    ViewState["topicAll" ] = discassionTopics;
    RepTopics.DataSource = discassionTopics;
    RepTopics.DataBind();
    }
    }
    }

                Stopwatch watch = new Stopwatch();

                watch.Start();
                BindAllTopic(); //
                watch.Stop();
                Response.Write("Load Topic Time..." + (watch.Elapsed.TotalMilliseconds / 1000));

    用Stopwatc测试,就这个方法时间很长!

    有什么好的方法呢? 非常感谢!


    Anything Is Possible !
    2010年4月9日 9:24

答案

  • 你好,

    你可以用sharepoint里已经提供的操作:

    你的里面 Discussion Boards List  操作Access打开” 》 选择“连接到sharepoint站点的数据”》保存数据》导出到excel里。

    除此之外,“连接到outlook” 也是一个很好的功能去导出Discussion Boards List里的数据。


    Seven
    2010年4月16日 6:56