我正在尝试使用客户端对象模型从sharepoint 2010网站远程访问数据。对于某些限制,我无法使用CAML查询,即使我使用我无法根据用户登录过滤适当的受众(如果你可以帮助我关于CAML查询也很好::我不知道如何获得当前用户受众名称和使用CAML /客户端对象模型的所有受众。此代码位于移动站点上并调用共享点站点,如我的代码所示)。以下代码运行良好但无法从webpart获取内容。有人可以帮忙解决这个问题
using (ClientContext ctx = new ClientContext("https://mysite.com/Pages/Default.aspx"))
{
ctx.ExecutingWebRequest += new EventHandler<WebRequestEventArgs> (clientContext_ExecutingWebRequest);
File home=ctx.Web.GetFileByServerRelativeUrl("/Student/Pages/default.aspx");
//get the web part manager
Microsoft.SharePoint.Client.WebParts.LimitedWebPartManager wpm = home.GetLimitedWebPartManager(Microsoft.SharePoint.Client.WebParts.PersonalizationScope.Shared);
IEnumerable<Microsoft.SharePoint.Client.WebParts.WebPartDefinition> wpds = null;
//create the LINQ query to get the web parts from
//the web part definition collection
wpds = ctx.LoadQuery(wpm.WebParts.Include(wp => wp.Id,wp => wp.WebPart));
//load the list of web parts
ctx.ExecuteQuery();
//enumerate the results
foreach (Microsoft.SharePoint.Client.WebParts.WebPartDefinition wpd in wpds)
{
string title= wpd.WebPart.Title;
Microsoft.SharePoint.Client.WebParts.WebPart wpart = wpd.WebPart;
????? How to render and receive the data (looking for the same data When you browse the site with the browser)
}
Code continues...
答案 0 :(得分:0)
我也在努力解决这个问题。看起来这对客户端对象模型来说是不可能的。实际上我已经在Build Conference 2012上向一些SharePoint工作人员提出过这个问题。
但是,使用SharePoint Designer,实际上可以下载想要的WebPart。 Fiddler可以方便地追踪哪些服务可以为您提供这些服务。
看一下这篇文章here on SharePoint StackExchange
不幸的是,帖子不会给你任何具体的解决方法。
祝你好运!