如何在Sharepoint 2010中以编程方式获得用户评级?

时间:2011-03-30 20:29:59

标签: sharepoint-2010 web-parts rating sharepoint-api

因此,我已根据本指南在Sharepoint 2010中为文档库启用了评分:http://weblogs.asp.net/bsimser/archive/2009/10/19/sharepoint-2010-what-s-new-ratings-spc09.aspx

现在我需要一种方法来在Webpart中以编程方式获得评级。

我想要一种获得如下列表的方法(尽管欢迎任何其他方式):

Item Id/Url    |    Rating   |  UserId

谢谢

3 个答案:

答案 0 :(得分:1)

我在这里找到了答案:http://msdn.microsoft.com/en-us/library/ff407954.aspx

有趣的是,我无法在任何地方使用谷歌找到它,我应该搜索“Sharepoint社会评级”而不仅仅是“评级”。

答案 1 :(得分:0)

您可以SPService获取对网址的评分:

        //Get Rating on Url
        //libraryUrl is url of your library
        $().SPServices({
            operation: "GetRatingOnUrl",
            url: libraryUrl,
            async: false,
            completefunc: function (xData, Status) {
                if (Status == "success") {
                    var url = $(xData.responseXML).find("Url").text();
                    var rating = $(xData.responseXML).find("Rating").text();
                    var user = $(xData.responseXML).find("Owner").text();
                    ....
                }
            }
        });

当webservice返回xml然后你可以得到一些你需要的信息:Url,Owner,LastModifiedTime,Title and Rating

答案 2 :(得分:-1)

以下是从列表中获取项目并在webpart中显示它们的方法。它使用简单的Label控件,但您可以按照自己喜欢的方式对其进行格式化:

        Dim SPListVar As SPList 'SharePoint List

    Dim SPColl As SPListItemCollection 'Define a list item Collection
    Using Site1 As New SPSite(Me.Context.Request.Url.ToString) 'Define the site
        Using Web1 As SPWeb = Site1.OpenWeb 'Define the web
            SPListVar = Web1.Lists("Tasks") 'Point to the required list
        End Using
    End Using

    SPColl = SPListVar.GetItems() ' Fill the List item collection with the return data

    Dim i As Integer

    While i < SPColl.Count

        LblRes.Text = LblRes.Text + SPColl.Item(i).Item("Title").ToString + "<BR>"

        'Read every record and put it in a new line in the Label control

        i = i + 1

    End While