static void Main(string[] args)
        {
            var siteUrl = "http://portal";
            var o365UserName = "******";
            var o365UserPassword = "******";

            var consoleUtils = new ConsoleUtils();

            consoleUtils.WithO365Context(siteUrl, o365UserName, o365UserPassword, context =>
            {
                // replace it with your M2 models
                var siteModel = default(ModelNode);
                var rotWebModel = default(ModelNode);

                // create a provision service - CSOMProvisionService or StandardCSOMProvisionService
                var provisionService = new CSOMProvisionService();

                // little nice thing, tracing the progress
                consoleUtils.TraceDeploymentProgress(provisionService);

                // deploy!
                provisionService.DeploySiteModel(context, siteModel);
                provisionService.DeployWebModel(context, rotWebModel);
            });
        }
Пример #2
0
        static void Main(string[] args)
        {
            // Step 1, define site field
            var customerField = new FieldDefinition
            {
                Id = new Guid("26470917-fbbf-413b-9eb3-537f74797e4e"),
                Title = "Customer Name",
                InternalName = "cstm_CustomerName",
                Description = "Name of the target customer.",
                Group = "Hello SPMeta2",
                FieldType = BuiltInFieldTypes.Text
            };

            // Step 2, define site model and artifact relationships - add field to the site 
            var siteModel = SPMeta2Model
                             .NewSiteModel(site =>
                             {
                                 site.AddField(customerField);
                             });

            // Step 3, deploy model via CSOM
            using (var clientContext = new ClientContext(SampleConsts.CSOM_SiteUrl))
            {
                var csomProvisionService = new CSOMProvisionService();
                csomProvisionService.DeployModel(SPMeta2.CSOM.ModelHosts.SiteModelHost.FromClientContext(clientContext), siteModel);
            }

            // Step 4, deploy model via SSOM
            using (var site = new SPSite(SampleConsts.SSOM_SiteUrl))
            {
                var csomProvisionService = new SSOMProvisionService();
                csomProvisionService.DeployModel(SPMeta2.SSOM.ModelHosts.SiteModelHost.FromSite(site), siteModel);
            }
        }
Пример #3
0
 /// <summary>
 /// A shortcut for incremental provision
 /// Sets incremental provision mode with AutoDetectSharePointPersistenceStorage = true
 /// Once done, reverts back to default provision mode
 /// </summary>
 public static void DeployWebModelIncrementally(this CSOMProvisionService modelHost,
                                                ClientContext context,
                                                ModelNode model,
                                                string incrementalModelId)
 {
     DeployWebModelIncrementally(modelHost, context, model, incrementalModelId, null);
 }
Пример #4
0
        private static void Deploy(Options options)
        {
            using (var ctx = new ClientContext(options.siteUrl))
            {
                ctx.ExecutingWebRequest +=
                    (sender, e) => e.WebRequestExecutor.RequestHeaders.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
                ctx.Credentials = new NetworkCredential(options.windowsLogin, options.windowsPassword,
                    options.windowsDomain);
                var pService = new CSOMProvisionService();

                pService.DeployModel(SiteModelHost.FromClientContext(ctx), 
                    AllModels.GetTaxoMotorSiteModel(ctx));
                pService.DeployModel(WebModelHost.FromClientContext(ctx), 
                    AllModels.GetTaxoMotorWebModel(ctx));
                pService.DeployModel(SiteModelHost.FromClientContext(ctx), 
                    AllModels.GetTaxoMotorSiteDependentModel(ctx));
                pService.DeployModel(WebModelHost.FromClientContext(ctx), 
                    AllModels.GetTaxoMotorWebDependentModel());
                pService.DeployModel(SiteModelHost.FromClientContext(ctx), 
                    AllModels.GetTaxoMotorIncomeRequestSiteDependentModel(ctx));
                pService.DeployModel(WebModelHost.FromClientContext(ctx), 
                    AllModels.GetTaxoMotorIncomeRequestWebDependentModel(ctx));
                pService.DeployModel(WebModelHost.FromClientContext(ctx),
                    AllModels.GetTaxoMotorWebPagesModel(ctx));
                pService.DeployModel(WebModelHost.FromClientContext(ctx),
                    AllModels.GetTaxomotorLookupsModel(ctx));
                
                ModelHandlers.MakeContentTypesDefault(ctx);
                ModelHandlers.CreateBcsFields(ctx);
                ModelHandlers.CreatePlumsailFields(ctx);
                ModelHandlers.CreateFieldIndexes(ctx);
            }
        }
 protected void DeployWebModelAsCSOM(ModelNode model)
 {
     using (var clientContext = new ClientContext(SampleConsts.CSOM_SiteUrl))
     {
         var csomProvisionService = new CSOMProvisionService();
         csomProvisionService.DeployModel(SPMeta2.CSOM.ModelHosts.WebModelHost.FromClientContext(clientContext), model);
     }
 }
Пример #6
0
 /// <summary>
 /// A shortcut for incremental provision
 /// Sets incremental provision mode with IncrementalProvisionConfig.AutoDetectSharePointPersistenceStorage = true
 /// Once done, reverts back to default provision mode
 /// Callback on IncrementalProvisionConfig makes it easy to configure IncrementalProvisionConfig instance
 public static void DeployWebModelIncrementally(this CSOMProvisionService modelHost,
                                                ClientContext context,
                                                ModelNode model,
                                                string incrementalModelId,
                                                Action <IncrementalProvisionConfig> config)
 {
     modelHost.DeployModelIncrementally(new WebModelHost(context), model, incrementalModelId, config);
 }
Пример #7
0
 static void Main(string[] args)
 {
     var model = GoogleMapsModel.GetModel();
     var siteUrl = "http://dev";
     var context = new ClientContext(siteUrl);
     var provisionService = new CSOMProvisionService();
     provisionService.DeployWebModel(context, model);
 }
        public static void Provision(ClientContext context, CSOMProvisionService provisioningService)
        {
            context.Site.EnsureProperties("ServerRelativeUrl");

            // model for Site Collection artifacts for stories
            var rootSiteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddTaxonomyTermStore(
                    new TaxonomyTermStoreDefinition() { UseDefaultSiteCollectionTermStore = true},
                    store =>
                    {
                        store.AddTaxonomyTermGroup(new TaxonomyTermGroupDefinition() {IsSiteCollectionGroup = true},
                            group =>
                            {
                                group.AddTaxonomyTermSet(new TaxonomyTermSetDefinition()
                                {
                                    Name = "SPMETA2Test",
                                    LCID = 1033
                                },
                                    termset =>
                                    {
                                        termset.AddTaxonomyTerm(new TaxonomyTermDefinition() {Name = "testterm", LCID = 1033});
                                    });
                            });
                    }
                    );

            });
            var rootSiteModel2 = SPMeta2Model.NewSiteModel(site =>
            {

                site.AddTaxonomyField(new TaxonomyFieldDefinition()
                {
                    InternalName = "sptaxfieldtest1",
                    Group = "spmeta2test",
                    Title = "TextTaxonomyField",
                    IsSiteCollectionGroup = true,
                    //TermGroupName = "Site Collection - mbakirov367.sharepoint.com",
                    UseDefaultSiteCollectionTermStore = true,
                    TermSetName = "SPMETA2Test",
                    TermSetLCID = 1033,
                    TermName = "testterm",
                    TermLCID = 1033
                }
                    );
            });

            // model for Site Collection artifacts for stories
            var rootWebModel = SPMeta2Model.NewWebModel(web =>
            {

            });

            provisioningService.DeploySiteModel(context, rootSiteModel);
            Thread.Sleep(1000);
            provisioningService.DeploySiteModel(context, rootSiteModel2);
            provisioningService.DeployWebModel(context, rootWebModel);
        }
Пример #9
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);
        }
Пример #10
0
        public void CanDeployFieldsToSite()
        {
            WithO365Context(context =>
            {
                var model = new RegModel().GetSiteFields();

                var provisionService = new CSOMProvisionService();
                provisionService.DeployModel(SiteModelHost.FromClientContext(context), model);
            });
        }
Пример #11
0
        public void EnsureCSOMModelHandlers()
        {
            var service = new CSOMProvisionService();
            var modelHandlers = ReflectionUtils.GetTypesFromAssembly<ModelHandlerBase>(typeof(SPMeta2.CSOM.ModelHandlers.FieldModelHandler).Assembly);

            foreach (var srcHandlerImplType in modelHandlers)
            {
                var dstHandlerImpl = service.ModelHandlers.Values.FirstOrDefault(h => h.GetType() == srcHandlerImplType);
                Assert.IsNotNull(dstHandlerImpl);
            }
        }
Пример #12
0
 static void Main(string[] args)
 {
     var siteUrl = "http://dev";
     var context = new ClientContext(siteUrl);
     var provisionService = new CSOMProvisionService();
     var model = GetModel();
     provisionService.DeployWebModel(context, model);
     var model2 = GetModel2();
     var context2 = new ClientContext(siteUrl + "/" + subWebUrl);
     provisionService.DeployWebModel(context2, model2);
 }
Пример #13
0
        private void InitServices()
        {
            _provisionService = new CSOMProvisionService();
            _validationService = new CSOMValidationService();

            var csomStandartAsm = typeof(TaxonomyFieldModelHandler).Assembly;

            foreach (var handlerType in ReflectionUtils.GetTypesFromAssembly<ModelHandlerBase>(csomStandartAsm))
                _provisionService.RegisterModelHandler(Activator.CreateInstance(handlerType) as ModelHandlerBase);

            var csomtandartValidationAsm = typeof(ClientTaxonomyFieldDefinitionValidator).Assembly;

            foreach (var handlerType in ReflectionUtils.GetTypesFromAssembly<ModelHandlerBase>(csomtandartValidationAsm))
                _validationService.RegisterModelHandler(Activator.CreateInstance(handlerType) as ModelHandlerBase);
        }
Пример #14
0
        private void InitServices()
        {
            _provisionService = new CSOMProvisionService();
            _validationService = new CSOMValidationService();

            // TODO, setup a high level validation registration
            _provisionService.PreDeploymentServices.Add(new DefaultRequiredPropertiesValidationService());

            var csomStandartAsm = typeof(TaxonomyFieldModelHandler).Assembly;

            foreach (var handlerType in ReflectionUtils.GetTypesFromAssembly<ModelHandlerBase>(csomStandartAsm))
                _provisionService.RegisterModelHandler(Activator.CreateInstance(handlerType) as ModelHandlerBase);

            var csomtandartValidationAsm = typeof(ClientTaxonomyFieldDefinitionValidator).Assembly;

            foreach (var handlerType in ReflectionUtils.GetTypesFromAssembly<ModelHandlerBase>(csomtandartValidationAsm))
                _validationService.RegisterModelHandler(Activator.CreateInstance(handlerType) as ModelHandlerBase);
        }
Пример #15
0
        private void InitServices()
        {
            _provisionService = new CSOMProvisionService();
            _validationService = new CSOMValidationService();

            // TODO, setup a high level validation registration
            _provisionService.PreDeploymentServices.Add(new DefaultRequiredPropertiesValidationService());

            var csomStandartAsm = typeof(TaxonomyFieldModelHandler).Assembly;

            foreach (var handlerType in ReflectionUtils.GetTypesFromAssembly<ModelHandlerBase>(csomStandartAsm))
                _provisionService.RegisterModelHandler(Activator.CreateInstance(handlerType) as ModelHandlerBase);

            var csomtandartValidationAsm = typeof(ClientTaxonomyFieldDefinitionValidator).Assembly;

            foreach (var handlerType in ReflectionUtils.GetTypesFromAssembly<ModelHandlerBase>(csomtandartValidationAsm))
                _validationService.RegisterModelHandler(Activator.CreateInstance(handlerType) as ModelHandlerBase);

            _provisionService.OnModelNodeProcessing += (sender, args) =>
            {
                Trace.WriteLine(
                    string.Format("Processing: [{0}/{1}] - [{2:0} %] - [{3}] [{4}]",
                    new object[] {
                                  args.ProcessedModelNodeCount,
                                  args.TotalModelNodeCount,
                                  100d * (double)args.ProcessedModelNodeCount / (double)args.TotalModelNodeCount,
                                  args.CurrentNode.Value.GetType().Name,
                                  args.CurrentNode.Value
                                  }));
            };

            _provisionService.OnModelNodeProcessed += (sender, args) =>
            {
                Trace.WriteLine(
                   string.Format("Processed: [{0}/{1}] - [{2:0} %] - [{3}] [{4}]",
                   new object[] {
                                  args.ProcessedModelNodeCount,
                                  args.TotalModelNodeCount,
                                  100d * (double)args.ProcessedModelNodeCount / (double)args.TotalModelNodeCount,
                                  args.CurrentNode.Value.GetType().Name,
                                  args.CurrentNode.Value
                                  }));
            };
        }
        public void CanProvisionIntranet_SiteModel()
        {
            WithCSOMContext(context =>
            {
                var siteModel = new M2ProjectPrefixSiteModel();
                var rootWebModel = new M2ProjectPrefixRootWebModel();

                var provisionService = new CSOMProvisionService();

                // site
                provisionService.DeploySiteModel(context, siteModel.GetSiteFeaturesModel());
                provisionService.DeploySiteModel(context, siteModel.GetUserCustomActionModel());
                provisionService.DeploySiteModel(context, siteModel.GetSiteSecurityModel());

                provisionService.DeploySiteModel(context, siteModel.GetFieldsAndContentTypesModel());
                provisionService.DeploySiteModel(context, siteModel.GetSandboxSolutionsModel());

                // root web
                provisionService.DeployWebModel(context, rootWebModel.GetStyleLibraryModel());
                provisionService.DeployWebModel(context, rootWebModel.GetModel());
            });
        }
        static void Main(string[] args)
        {
            try
            {

                ReadSettings();
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    TraceHelper.TraceInformation("Configuring managed metadata");

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

                    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();

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

                    var provisioningService = new CSOMProvisionService();
                    var siteModel = SiteModel.BuildFieldsModel();

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

                    var provisioningService = new CSOMProvisionService();
                    var siteModel = SiteModel.BuildContentTypesModel();

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

                    var provisioningService = new CSOMProvisionService();
                    var siteModel = SiteModel.BuildWebRootModel();

                    provisioningService.RegisterModelHandlers(typeof(TaxonomyGroupModelHandler).Assembly);
                    provisioningService.DeployModel(SiteModelHost.FromClientContext(ctx), siteModel);
                }
                //using (ClientContext ctx = GetAuthenticatedContext())
                //{
                //    TraceHelper.TraceInformation("Building web root files and modules");

                //    var provisioningService = new CSOMProvisionService();
                //    var siteModel = Model.FIles.BuildFilesModel();

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

                //    var provisioningService = new CSOMProvisionService();
                //    var siteModel = Model.Pages.BuildPagesModel();

                //    provisioningService.RegisterModelHandlers(typeof(TaxonomyGroupModelHandler).Assembly);
                //    provisioningService.DeployModel(WebModelHost.FromClientContext(ctx), siteModel);
                //}
                using (ClientContext ctx = GetAuthenticatedContext())
                {
                    TraceHelper.TraceInformation("Building lookup model");

                    var provisioningService = new CSOMProvisionService();
                    var siteModel = SiteModel.BuildLookupModel();

                    provisioningService.RegisterModelHandlers(typeof(TaxonomyGroupModelHandler).Assembly);
                    provisioningService.DeployModel(SiteModelHost.FromClientContext(ctx), siteModel);
                }
            }
            catch (Exception ex)
            {
                TraceHelper.TraceError("an error has occured, message:{0}", ex);
            }
        }
Пример #18
0
 static void Main(string[] args)
 {
     var siteUrl = "https://staging-nps.skanska.net/sites/jsomtest/tolle";
     var context = new ClientContext(siteUrl);
     var provisionService = new CSOMProvisionService();
     var model = GetModel();
     provisionService.DeployWebModel(context, model);
 }
        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();

                    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);
            }
        }
Пример #20
0
 public static void DeployWebModel(this CSOMProvisionService modelHost, ClientContext context, ModelNode model)
 {
     modelHost.DeployModel(new WebModelHost(context), model);
 }