从Sharepoint检索会议

时间:2018-10-16 12:08:12

标签: asp.net-mvc sharepoint

我正在开发一个c#mvc应用程序中的以下代码,以从sharepoint 2013网站检索数据

string siteUrl = "https://meetings";
var login = "user";
var password = "passwrd";

var securePassword = new SecureString();
foreach(char c in password)
{
securePassword.AppendChar(c);
}
ClientContext clientContext = new ClientContext(siteUrl);
clientContext.Credentials = new NetworkCredential(login, securePassword, "group");
Web web = clientContext.Web;
clientContext.Load(web, w => w.Title, w => w.Description);

clientContext.ExecuteQuery();
System.Web.HttpContext.Current.Response.Write(web.Title + "<br />");


clientContext.Load(web.Lists,
lists => lists.Include(list => list.Title, // For each list, retrieve Title and Id. 
            list => list.Id));
clientContext.ExecuteQuery();

foreach (List list in web.Lists)
{
//label1.Text = label1.Text + ", " + list.Title;
System.Web.HttpContext.Current.Response.Write(list.Title + " : " + list.Tag + "<br />");
}

foreach循环返回

Composed Looks : 
Documents : 
Master Page Gallery : 
Meetings : 
MicroFeed : 
NintexForms : 
NintexWorkflowHistory : 
NintexWorkflows : 
Site Assets : 
Site Pages : 
Workflow Tasks : 
Workflows : 

但是,如果我浏览到实际的共享点页面,则会有一个会议列表,其中包含指向要显示在我的mvc页面上的子页面的链接。

我已将此代码添加到我的代码中,但随后出现错误

List oList = clientContext.Web.Lists.GetByTitle("Meetings");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Geq><FieldRef Name='ID'/>" +
"<Value Type='Number'>10</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>";
ListItemCollection collListItem = oList.GetItems(camlQuery);

clientContext.Load(collListItem);

clientContext.ExecuteQuery();

foreach (ListItem oListItem in collListItem)
{
    System.Web.HttpContext.Current.Response.Write("ID: " + oListItem.Id + " \nTitle: " + oListItem["Title"] + " \nBody: " + oListItem["Body"] + "<br />");
}

任何人都可以向我指出教程或任何帮助的方向

预先感谢

0 个答案:

没有答案