Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. using ITR.SharePoint.Client.CSOM;
  2. using Microsoft.SharePoint.Client;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace SP.DEMO.PROVISIONING {
  10. class Program {
  11. private static string username = "alnstrange@alnstrange.onmicrosoft.com";
  12. private static string siteURL = "https://alnstrange.sharepoint.com/sites/provisioning";
  13.  
  14. //Opret SharePoint Team Site
  15. //Opret liste med felter: Site Title, URL, IsProvisioned
  16. //Hent listen ud i koden
  17. //opret subsite på nye elementer
  18. //Ryd forsiden for webparts
  19. //Indsæt en Youtube video på forsiden (efter ejet valg)
  20.  
  21. static void Main(string[] args) {
  22. Console.WriteLine("Please enter password:");
  23. using (SPClientContext ctx = new SPClientContext(siteURL)) {
  24. ctx.Credentials = new SharePointOnlineCredentials(username, ctx.GetPasswordFromConsoleInput());
  25.  
  26. Web web = ctx.Web;
  27. ctx.Load(web);
  28. ctx.Load(web, x => x.Lists);
  29.  
  30. ctx.ExecuteQuery();
  31.  
  32. Console.WriteLine(string.Format("Connected to site with title of {0}", web.Title));
  33.  
  34. CamlQuery query = new CamlQuery();
  35. List myList = web.Lists.GetByTitle("testliste");
  36.  
  37. ListItemCollection websites = myList.GetItems(query);
  38. ctx.Load<List>(myList);
  39. ctx.Load<ListItemCollection>(websites);
  40. ctx.ExecuteQuery();
  41.  
  42. Console.WriteLine("Getting list items:");
  43.  
  44. foreach (var item in websites)
  45. {
  46. string siteTitle = (string)item["Title"];
  47. Console.WriteLine(siteTitle);
  48. }
  49.  
  50.  
  51. //Console.WriteLine(web.Lists);
  52.  
  53. //foreach (List list in web.Lists)
  54. //{
  55. // Console.WriteLine(list);
  56. //}
  57.  
  58. Console.ReadLine();
  59. }
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement