Exemple #1
0
        /// <summary>
        /// Deploys and validates target site model.
        /// </summary>
        /// <param name="model"></param>
        public override void DeploySiteModel(ModelNode model)
        {
            if (!SiteUrls.Any())
            {
                throw new SPMeta2Exception("SiteUrls is empty");
            }

            foreach (var siteUrl in SiteUrls)
            {
                ContainerTraceUtils.WriteLine(string.Format("[INF]    Running on site: [{0}]", siteUrl));


                for (var provisionGeneration = 0;
                     provisionGeneration < ProvisionGenerationCount;
                     provisionGeneration++)
                {
                    WithO365Context(siteUrl, context =>
                    {
                        if (EnableDefinitionProvision)
                        {
                            _provisionService.DeployModel(SiteModelHost.FromClientContext(context), model);
                        }

                        if (EnableDefinitionValidation)
                        {
                            _validationService.DeployModel(SiteModelHost.FromClientContext(context), model);
                        }
                    });
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Deploys and validates target site model.
        /// </summary>
        /// <param name="model"></param>
        public override void DeploySiteModel(ModelNode model)
        {
            foreach (var siteUrl in SiteUrls)
            {
                Trace.WriteLine(string.Format("[INF]    Running on site: [{0}]", siteUrl));


                for (var provisionGeneration = 0;
                     provisionGeneration < ProvisionGenerationCount;
                     provisionGeneration++)
                {
                    WithO365Context(siteUrl, context =>
                    {
                        if (EnableDefinitionProvision)
                        {
                            _provisionService.DeployModel(SiteModelHost.FromClientContext(context), model);
                        }

                        if (EnableDefinitionValidation)
                        {
                            _validationService.DeployModel(SiteModelHost.FromClientContext(context), model);
                        }
                    });
                }
            }
        }
        private void SiteOnUrl(ModelNode model, string siteUrl)
        {
            ContainerTraceUtils.WriteLine(string.Format("[INF]    Running on site: [{0}]", siteUrl));

            for (var provisionGeneration = 0;
                 provisionGeneration < ProvisionGenerationCount;
                 provisionGeneration++)
            {
                WithO365Context(siteUrl, context =>
                {
                    if (EnableDefinitionProvision)
                    {
                        if (OnBeforeDeployModel != null)
                        {
                            OnBeforeDeployModel(_provisionService, model);
                        }

                        _provisionService.DeployModel(SiteModelHost.FromClientContext(context), model);

                        if (OnAfterDeployModel != null)
                        {
                            OnAfterDeployModel(_provisionService, model);
                        }
                    }

                    if (EnableDefinitionValidation)
                    {
                        _validationService.DeployModel(SiteModelHost.FromClientContext(context), model);
                    }
                });
            }
        }
Exemple #4
0
        protected override void InternalDeploySiteModel(ProvisionServiceContext context)
        {
            var clientContext = context.Context as ClientContext;
            var model         = context.Model;

            ModelService.DeployModel(SiteModelHost.FromClientContext(clientContext), model);
        }
Exemple #5
0
 public static void ExecuteModel(this SiteModelNode Model, string url, ICredentials Credential = null)
 {
     SharePoint.Session(url, Credential, ctx =>
     {
         var provisionService = new CSOMProvisionService();
         provisionService.DeployModel(SiteModelHost.FromClientContext(ctx), Model);
     });
 }
Exemple #6
0
 public static void Deploy(SPDeployOptions options)
 {
     SharePoint.Session(options.url, options.Credentials, ctx =>
     {
         var provisionService = new CSOMProvisionService();
         provisionService.DeployModel(SiteModelHost.FromClientContext(ctx), DeployModel());
     });
 }
Exemple #7
0
        public void CanDeployFieldsToSite()
        {
            WithO365Context(context =>
            {
                var model = new RegModel().GetSiteFields();

                var provisionService = new CSOMProvisionService();
                provisionService.DeployModel(SiteModelHost.FromClientContext(context), model);
            });
        }
        public override void DeploySiteModel(ModelNode model)
        {
            WithO365Context(context =>
            {
                _provisionService.DeployModel(SiteModelHost.FromClientContext(context), model);

                if (EnableDefinitionValidation)
                {
                    _validationService.DeployModel(SiteModelHost.FromClientContext(context), model);
                }
            });
        }
Exemple #9
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);
            }
        }
Exemple #10
0
        private void DeployModel(ModelNode model)
        {
            WithCSOMContext(context =>
            {
                var provisionService = new StandardCSOMProvisionService();

                if (model.Value.GetType() == typeof(FarmDefinition))
                {
                    throw new SPMeta2NotImplementedException(
                        string.Format("Runner does not support model of type: [{0}]", model.Value.GetType()));
                }
                else if (model.Value.GetType() == typeof(WebApplicationDefinition))
                {
                    throw new SPMeta2NotImplementedException(
                        string.Format("Runner does not support model of type: [{0}]", model.Value.GetType()));
                }
                else if (model.Value.GetType() == typeof(SiteDefinition))
                {
                    provisionService.DeployModel(SiteModelHost.FromClientContext(context), model);
                }
                else if (model.Value.GetType() == typeof(WebDefinition))
                {
                    provisionService.DeployModel(WebModelHost.FromClientContext(context), model);
                }
                else if (model.Value.GetType() == typeof(ListDefinition))
                {
                    throw new SPMeta2NotImplementedException(
                        string.Format("Runner does not support model of type: [{0}]", model.Value.GetType()));
                }
                else
                {
                    throw new SPMeta2NotImplementedException(
                        string.Format("Runner does not support model of type: [{0}]", model.Value.GetType()));
                }
            });
        }
Exemple #11
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);
            }
        }