Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using ITR.SharePoint.Client.CSOM;
- using Microsoft.SharePoint.Client;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SP.DEMO.PROVISIONING {
- class Program {
- private static string username = "alnstrange@alnstrange.onmicrosoft.com";
- private static string siteURL = "https://alnstrange.sharepoint.com/sites/provisioning";
- //Opret SharePoint Team Site
- //Opret liste med felter: Site Title, URL, IsProvisioned
- //Hent listen ud i koden
- //opret subsite på nye elementer
- //Ryd forsiden for webparts
- //Indsæt en Youtube video på forsiden (efter ejet valg)
- static void Main(string[] args) {
- Console.WriteLine("Please enter password:");
- using (SPClientContext ctx = new SPClientContext(siteURL)) {
- ctx.Credentials = new SharePointOnlineCredentials(username, ctx.GetPasswordFromConsoleInput());
- Web web = ctx.Web;
- ctx.Load(web);
- ctx.Load(web, x => x.Lists);
- ctx.ExecuteQuery();
- Console.WriteLine(string.Format("Connected to site with title of '{0}'", web.Title));
- CamlQuery query = new CamlQuery();
- List myList = web.Lists.GetByTitle("testliste");
- var myListFieldCollection = myList.Fields;
- ListItemCollection websites = myList.GetItems(query);
- ctx.Load<List>(myList);
- ctx.Load<ListItemCollection>(websites);
- ctx.Load<FieldCollection>(myListFieldCollection);
- ctx.ExecuteQuery();
- Console.WriteLine("Getting list items:");
- var siteTitleColumnInternalName = myListFieldCollection.Single(t => t.Title == "Site Title").InternalName;
- var urlColumnInternalName = myListFieldCollection.Single(t => t.Title == "URL").InternalName;
- var isProvisionedTitleColumnInternalName = myListFieldCollection.Single(t => t.Title == "IsProvisioned").InternalName;
- foreach (var website in websites)
- {
- Console.WriteLine(website.FieldValues.Single(k => k.Key == siteTitleColumnInternalName).Value);
- Console.WriteLine(website.FieldValues.Single(k => k.Key == urlColumnInternalName).Value);
- Console.WriteLine(website.FieldValues.Single(k => k.Key == isProvisionedTitleColumnInternalName).Value);
- //string isProvisioned = (string)item["IsProvisioned"];
- //Console.WriteLine(isProvisioned);
- }
- Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement