Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                ReadSettings();
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    ctx.Load(ctx.Web);
                    ctx.ExecuteQuery();
                    Console.WriteLine(ctx.Web.Url);

                    TraceHelper.TraceInformation("Configuring site");

                    var provisioningService = new CSOMProvisionService();
                    var siteModel           = Model.BuildSiteModel();

                    var str1 = siteModel.ToDotGraph();
                    var str2 = siteModel.ToPrettyPrint();

                    Console.WriteLine(str2);

                    System.IO.File.WriteAllText("sitemode.txt", str1);

                    provisioningService.DeployModel(SiteModelHost.FromClientContext(ctx), siteModel);
                }
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    ctx.Load(ctx.Web);
                    ctx.ExecuteQuery();
                    Console.WriteLine(ctx.Web.Url);

                    TraceHelper.TraceInformation("Configuring web");

                    var provisioningService = new CSOMProvisionService();
                    var webModel            = Model.BuilWebModel();

                    provisioningService.DeployModel(WebModelHost.FromClientContext(ctx), webModel);
                }
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("an error has occured, message:{0}", ex.Message);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                ReadSettings();
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    TraceHelper.TraceInformation("Configuring managed metadata");

                    var provisioningService = new StandardCSOMProvisionService();
                    var siteModel           = SiteModel.BuildTaxonomyModel();

                    Console.WriteLine(siteModel.ToPrettyPrint());

                    provisioningService.RegisterModelHandlers(typeof(TaxonomyGroupModelHandler).Assembly);
                    provisioningService.DeployModel(SiteModelHost.FromClientContext(ctx), siteModel);
                }
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    TraceHelper.TraceInformation("Building site features");

                    var provisioningService = new CSOMProvisionService();
                    var siteModel           = SiteModel.BuildSiteFeaturesModel();
                    Console.WriteLine(siteModel.ToPrettyPrint());

                    provisioningService.DeployModel(SiteModelHost.FromClientContext(ctx), siteModel);
                }
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    TraceHelper.TraceInformation("Building site fields");

                    var provisioningService = new StandardCSOMProvisionService();
                    var siteModel           = SiteModel.BuildFieldsModel();
                    Console.WriteLine(siteModel.ToPrettyPrint());

                    provisioningService.DeployModel(SiteModelHost.FromClientContext(ctx), siteModel);
                }
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    TraceHelper.TraceInformation("Building site content types");

                    var provisioningService = new StandardCSOMProvisionService();
                    var siteModel           = SiteModel.BuildContentTypesModel();
                    Console.WriteLine(siteModel.ToPrettyPrint());

                    provisioningService.DeployModel(SiteModelHost.FromClientContext(ctx), siteModel);
                }
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    TraceHelper.TraceInformation("Building web root model ");

                    var provisioningService = new StandardCSOMProvisionService();
                    var webModel            = SiteModel.BuildWebRootModel();
                    Console.WriteLine(webModel.ToPrettyPrint());

                    provisioningService.DeployModel(SiteModelHost.FromClientContext(ctx), webModel);
                }
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    TraceHelper.TraceInformation("Building web root files and modules");

                    var provisioningService = new StandardCSOMProvisionService();
                    var webModel            = Model.FIles.BuildFilesModel();
                    Console.WriteLine(webModel.ToPrettyPrint());

                    provisioningService.DeployModel(WebModelHost.FromClientContext(ctx), webModel);
                }
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    TraceHelper.TraceInformation("Building pages");

                    var provisioningService = new StandardCSOMProvisionService();
                    var webModel            = Model.Pages.BuildPagesModel();
                    Console.WriteLine(webModel.ToPrettyPrint());

                    provisioningService.DeployModel(WebModelHost.FromClientContext(ctx), webModel);
                }
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("an error has occured, message:{0}", ex);
            }
        }