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);
            }
        }
Example #2
0
 public void ProcessState(ClientCtx ctx)
 {
     switch (this.state)
     {
         case "ACK":
             break;
         default:
             throw new Exception("unknown state");
             break;
     }
 }
        //Pour convertir la collection il faut mettre null dans les autres paramètres

        public void SetCollValue(string nomColl, object valeur)
        {
            Field f = ListDesField.Find(field => field.Title == nomColl);

            //if (f == null) Console.WriteLine("Veuiller verifier le nom du champ");
            if (f.TypeAsString == "Boolean")
            {
                try
                {
                    Fichier[nomColl] = Convert.ToBoolean(valeur);
                }
                catch
                {
                    Console.WriteLine("L'entré n'était pas un booleen");
                }
            }
            else if (f.TypeAsString == "Number" || f.TypeAsString == "Currency")
            {
                try
                {
                    Fichier[nomColl] = Convert.ToInt32(valeur);
                }
                catch
                {
                    Console.WriteLine("L'entré n'était pas un nombre");
                }
            }
            else if (f.TypeAsString == "Text")
            {
                try
                {
                    Fichier[nomColl] = valeur.ToString();
                }
                catch
                {
                    Console.WriteLine("L'entré n'était pas une chaine de caractère");
                }
            }


            Fichier.Update(); // important, rembeber changes

            try
            {
                ClientCtx.ExecuteQuery();
            }
            catch
            {
                Console.WriteLine("Quelquechose s'est mal passé dans la mofication de la valeur d'un champs veuillez verifier le le champs et la valeur");
                Console.Read();
                System.Environment.Exit(-5);
            }
        }
        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);
                }
            }
        }