Exemplo n.º 1
0
        //gavdcodeend 46

        //gavdcodebegin 47
        static void SpCsPnpcoreGenerateSiteListTemplate(ClientContext spCtx)
        {
            OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.
            ProvisioningTemplateCreationInformation myProvisioner =
                new OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.
                ProvisioningTemplateCreationInformation(spCtx.Web);

            myProvisioner.FileConnector =
                new OfficeDevPnP.Core.Framework.Provisioning.Connectors.
                FileSystemConnector(@"C:\Temporary\InMemTemplate.xml", "");
            List <string> myLists = new List <string>();

            myLists.Add("MyCustomList");
            myLists.Add("Shared Documents");
            myProvisioner.ListsToExtract = myLists;

            // Write progress to output
            myProvisioner.ProgressDelegate = delegate(String prMessage,
                                                      Int32 prProgress,
                                                      Int32 prTotal)
            {
                Console.WriteLine("{0:00}/{1:00} - {2}", prProgress, prTotal, prMessage);
            };

            // Template in memory
            OfficeDevPnP.Core.Framework.Provisioning.Model.ProvisioningTemplate
                myTemplate = spCtx.Web.GetProvisioningTemplate(myProvisioner);

            // Template in file
            OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLTemplateProvider
                myXmlProvider = new OfficeDevPnP.Core.Framework.Provisioning.Providers.
                                Xml.XMLFileSystemTemplateProvider(@"C:\Temporary", "");
            myXmlProvider.SaveAs(myTemplate, "TestProvisioningLists.xml");
        }
Exemplo n.º 2
0
        //gavdcodeend 47

        //gavdcodebegin 48
        static void SpCsPnpcoreApplySiteTemplate(ClientContext spCtx)
        {
            Web myWeb = spCtx.Web;

            spCtx.Load(myWeb, w => w.Title);
            spCtx.ExecuteQueryRetry();

            OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.XMLTemplateProvider
                myXmlProvider = new OfficeDevPnP.Core.Framework.Provisioning.Providers.
                                Xml.XMLFileSystemTemplateProvider(@"C:\Temporary", "");

            OfficeDevPnP.Core.Framework.Provisioning.Model.ProvisioningTemplate
                myTemplate = myXmlProvider.GetTemplate("TestProvisioningSite.xml");

            myWeb.ApplyProvisioningTemplate(myTemplate);
        }