public void GetFolderContentTypes(string nomListe) { // Get the content type collection for the list nomListe NomDossier = nomListe; ContentTypeCollection contentTypeColl = ClientCtx.Web.Lists.GetByTitle(NomDossier).ContentTypes; //Execute the reques ClientCtx.Load(contentTypeColl); //try //{ ClientCtx.ExecuteQuery(); //} //catch //{ // Console.WriteLine("Quelquechose s'est mal passé dans la récupération des content types veuillez verifier le nom du dossier"); //Console.Read(); //System.Environment.Exit(-3); // } foreach (ContentType c in contentTypeColl) { ListDesContentType.Add(c); } }
public void GetChampsDunContentType(string nomContentType) { SetContentTypeWithString(nomContentType); //// Get the field collection for the content type nomContentType contenu dans la collection contentTypeCollection foreach (ContentType ct in ListDesContentType) { if (ct == TypeDuFichier) { //Recupération des champs FieldCollection fieldColl = ct.Fields; //Execution de la requette // ClientCtx.Credentials = new NetworkCredential(); ClientCtx.Load(fieldColl); try { ClientCtx.ExecuteQuery(); } catch { Console.WriteLine("Quelquechose s'est mal passé dans la récupération des champs veuillez verifier le nom du content type"); Console.Read(); System.Environment.Exit(-4); } foreach (Field f in fieldColl) { if (true) { if (f.Group == "Custom Columns" && f.FromBaseType == false) { ListDesField.Add(f); } //if (f.Title == "Content Type") ListDesField.Add(f); } } } } }
/* * private void GetAllSubWebs() * { * // Get the SharePoint web * Web web = ClientCtx.Web; * ClientCtx.Load(web, website => website.Webs, website => website.Title); * * // Execute the query to the server * try * { * ClientCtx.ExecuteQuery(); * } * catch * { * Console.WriteLine("Quelquechose s'est mal passé dans l'exéctution de la requete pour avoir les sites veuillez verifier l'url"); * Console.Read(); * System.Environment.Exit(-1); * } * * // Loop through all the webs * foreach (Web subWeb in web.Webs) * { * string newpath = Domaine + subWeb.ServerRelativeUrl; * ListDesSites.Add(subWeb); * ClientCtx = new ClientContext(newpath); * if (subWeb.Webs != null) GetAllSubWebs(); * } * } */ public void GetSiteFolders(string nomSite) { foreach (KeyValuePair <string, string> s in ListDesSiteCollections) { if (s.Key.Equals(nomSite, StringComparison.InvariantCultureIgnoreCase)) { //Update the client context with the selected site ClientCtx = new ClientContext(Domaine + "/sites/" + s.Value); } } ListCollection listColl = ClientCtx.Web.Lists; // Execute query. ClientCtx.Load(listColl, lists => lists.Include(testList => testList.Title, testList => testList.BaseTemplate)); //try //{ ClientCtx.ExecuteQuery(); /*} * catch * { * Console.WriteLine("Quelquechose s'est mal passé dans la récupération des dossier veuillez verifier le nom du site"); * Task.Delay(4000); * System.Environment.Exit(-2); * }*/ foreach (List list in listColl) { if (list.BaseTemplate == 101 && list.Title != "Site Assets") // id dossier { ListDesDossier.Add(list); } } }