예제 #1
0
        /// <summary>
        /// Deploys and validates target web model.
        /// </summary>
        /// <param name="model"></param>
        public override void DeployWebModel(ModelNode model)
        {
            foreach (var webUrl in WebUrls)
            {
                Trace.WriteLine(string.Format("[INF]    Running on web: [{0}]", webUrl));



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

                        if (EnableDefinitionValidation)
                        {
                            _validationService.DeployModel(WebModelHost.FromClientContext(context), model);
                        }
                    });
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Deploys and validates target web model.
        /// </summary>
        /// <param name="model"></param>
        public override void DeployWebModel(ModelNode model)
        {
            if (!WebUrls.Any())
            {
                throw new SPMeta2Exception("WebUrls is empty");
            }

            foreach (var webUrl in WebUrls)
            {
                ContainerTraceUtils.WriteLine(string.Format("[INF]    Running on web: [{0}]", webUrl));



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

                        if (EnableDefinitionValidation)
                        {
                            _validationService.DeployModel(WebModelHost.FromClientContext(context), model);
                        }
                    });
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Deploys and validates target web model.
        /// </summary>
        /// <param name="model"></param>
        public override void DeployWebModel(ModelNode model)
        {
            if (RandomBalancedUrls.Count > 0)
            {
                var url = RandomBalancedUrls[rnd.Next(0, RandomBalancedUrls.Count)];
                WebOnUrl(model, url);
            }
            else
            {
                foreach (var webUrl in WebUrls)
                {
                    ContainerTraceUtils.WriteLine(string.Format("[INF]    Running on web: [{0}]", webUrl));



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

                            if (EnableDefinitionValidation)
                            {
                                _validationService.DeployModel(WebModelHost.FromClientContext(context), model);
                            }
                        });
                    }
                }
            }
        }
예제 #4
0
        private void WebOnUrl(ModelNode model, string webUrl)
        {
            ContainerTraceUtils.WriteLine(string.Format("[INF]    Running on web: [{0}]", webUrl));

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

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

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

                    if (EnableDefinitionValidation)
                    {
                        _validationService.DeployModel(WebModelHost.FromClientContext(context), model);
                    }
                }
            });
        }
예제 #5
0
        protected override void InternalDeployWebModel(ProvisionServiceContext context)
        {
            var clientContext = context.Context as ClientContext;
            var model         = context.Model;

            ModelService.DeployModel(WebModelHost.FromClientContext(clientContext), model);
        }
예제 #6
0
        public static void DeployListModel(this CSOMProvisionService modelHost, ClientContext context, List list, ModelNode model)
        {
            var listHost = ModelHostBase.Inherit <ListModelHost>(WebModelHost.FromClientContext(context), h =>
            {
                h.HostList = list;
            });

            modelHost.DeployModel(listHost, model);
        }
예제 #7
0
        public override void DeployWebModel(ModelNode model)
        {
            WithO365Context(context =>
            {
                _provisionService.DeployModel(WebModelHost.FromClientContext(context), model);

                if (EnableDefinitionValidation)
                {
                    _validationService.DeployModel(WebModelHost.FromClientContext(context), model);
                }
            });
        }
예제 #8
0
        public override void DeployListModel(ModelNode model)
        {
            foreach (var webUrl in WebUrls)
            {
                ContainerTraceUtils.WriteLine(string.Format("[INF]    Running on web: [{0}]", webUrl));

                WithCSOMContext(webUrl, context =>
                {
                    for (var provisionGeneration = 0;
                         provisionGeneration < ProvisionGenerationCount;
                         provisionGeneration++)
                    {
                        List list = null;

                        try
                        {
                            list = context.Web.QueryAndGetListByTitle("Site Pages");
                        }
                        catch (Exception ex) { }

                        if (list == null)
                        {
                            try
                            {
                                list = context.Web.QueryAndGetListByTitle("Pages");
                            }
                            catch (Exception ex) { }
                        }

                        if (list == null)
                        {
                            throw new SPMeta2Exception("Cannot find host list");
                        }

                        if (EnableDefinitionProvision)
                        {
                            _provisionService.DeployListModel(context, list, model);
                        }

                        if (EnableDefinitionValidation)
                        {
                            var listHost = ModelHostBase.Inherit <ListModelHost>(WebModelHost.FromClientContext(context), h =>
                            {
                                h.HostList = list;
                            });

                            _validationService.DeployModel(listHost, model);
                        }
                    }
                });
            }
        }
예제 #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);
            }
        }
예제 #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()));
                }
            });
        }
예제 #11
0
        private void ListOnUrl(ModelNode model, string webUrl)
        {
            ContainerTraceUtils.WriteLine(string.Format("[INF]    Running on web: [{0}]", webUrl));

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

                        var web  = context.Web;
                        var list = web.QueryAndGetListByTitle("Site Pages");

                        if (list == null)
                        {
                            list = web.QueryAndGetListByTitle("Pages");
                        }

                        if (list == null)
                        {
                            throw new SPMeta2Exception("Cannot find host list");
                        }

                        var listHost = ModelHostBase.Inherit <ListModelHost>(WebModelHost.FromClientContext(context), h =>
                        {
                            h.HostList = list;
                        });

                        _provisionService.DeployModel(listHost, model);

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

                    if (EnableDefinitionValidation)
                    {
                        var web  = context.Web;
                        var list = web.QueryAndGetListByTitle("Site Pages");

                        if (list == null)
                        {
                            list = web.QueryAndGetListByTitle("Pages");
                        }

                        if (list == null)
                        {
                            throw new SPMeta2Exception("Cannot find host list");
                        }

                        var listHost = ModelHostBase.Inherit <ListModelHost>(WebModelHost.FromClientContext(context), h =>
                        {
                            h.HostList = list;
                        });

                        _validationService.DeployModel(listHost, model);
                    }
                }
            });
        }
예제 #12
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);
            }
        }