Exemplo n.º 1
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);
            }
        }