Esempio n. 1
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);
            }
        }
Esempio n. 2
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 SSOMProvisionService modelHost,
                                                SPWeb web,
                                                ModelNode model,
                                                string incrementalModelId)
 {
     DeployWebModelIncrementally(modelHost, web, model, incrementalModelId, null);
 }
Esempio n. 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 DeploySiteModelIncrementally(this SSOMProvisionService modelHost,
                                                 SPSite site,
                                                 ModelNode model,
                                                 string incrementalModelId)
 {
     DeploySiteModelIncrementally(modelHost, site, model, incrementalModelId, null);
 }
Esempio n. 4
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
 /// </summary>
 public static void DeployWebModelIncrementally(this SSOMProvisionService modelHost,
                                                SPWeb web,
                                                ModelNode model,
                                                string incrementalModelId,
                                                Action <IncrementalProvisionConfig> config)
 {
     modelHost.DeployModelIncrementally(WebModelHost.FromWeb(web), model, incrementalModelId, config);
 }
Esempio n. 5
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
 /// </summary>
 public static void DeploySiteModelIncrementally(this SSOMProvisionService modelHost,
                                                 SPSite site,
                                                 ModelNode model,
                                                 string incrementalModelId,
                                                 Action <IncrementalProvisionConfig> config)
 {
     modelHost.DeployModelIncrementally(SiteModelHost.FromSite(site), model, incrementalModelId);
 }
 protected void DeploySiteModelAsSSOM(ModelNode model)
 {
     using (var site = new SPSite(SampleConsts.SSOM_SiteUrl))
     {
         var ssomProvisionService = new SSOMProvisionService();
         ssomProvisionService.DeployModel(SPMeta2.SSOM.ModelHosts.SiteModelHost.FromSite(site), model);
     }
 }
Esempio n. 7
0
        public static void DeployListModel(this SSOMProvisionService modelHost, SPList list, ModelNode model)
        {
            var listHost = ModelHostBase.Inherit <ListModelHost>(WebModelHost.FromWeb(list.ParentWeb), h =>
            {
                h.HostList = list;
            });

            modelHost.DeployModel(listHost, model);
        }
        public void EnsureSSOMModelHandlers()
        {
            var service = new SSOMProvisionService();
            var modelHandlers = ReflectionUtils.GetTypesFromAssembly<ModelHandlerBase>(typeof(SPMeta2.SSOM.ModelHandlers.FieldModelHandler).Assembly);

            foreach (var srcHandlerImplType in modelHandlers)
            {
                var dstHandlerImpl = service.ModelHandlers.Values.FirstOrDefault(h => h.GetType() == srcHandlerImplType);
                Assert.IsNotNull(dstHandlerImpl);
            }
        }
 protected void DeployWebModelAsSSOM(ModelNode model)
 {
     using (var site = new SPSite(SampleConsts.SSOM_SiteUrl))
     {
         using (var web = site.OpenWeb())
         {
             var ssomProvisionService = new SSOMProvisionService();
             ssomProvisionService.DeployModel(SPMeta2.SSOM.ModelHosts.WebModelHost.FromWeb(web), model);
         }
     }
 }
Esempio n. 10
0
        private void InitServices()
        {
            _provisionService = new SSOMProvisionService();
            _validationService = new SSOMValidationService();

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

            var ssomStandartAsm = typeof(ContactFieldControlModelHandler).Assembly;

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

            var ssomStandartValidationAsm = typeof(ImageRenditionDefinitionValidator).Assembly;

            foreach (var handlerType in ReflectionUtils.GetTypesFromAssembly<ModelHandlerBase>(ssomStandartValidationAsm))
                _validationService.RegisterModelHandler(Activator.CreateInstance(handlerType) as ModelHandlerBase);
        }
Esempio n. 11
0
        private void InitServices()
        {
            _provisionService = new SSOMProvisionService();
            _validationService = new SSOMValidationService();

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

            var ssomStandartAsm = typeof(ContactFieldControlModelHandler).Assembly;

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

            var ssomStandartValidationAsm = typeof(ImageRenditionDefinitionValidator).Assembly;

            foreach (var handlerType in ReflectionUtils.GetTypesFromAssembly<ModelHandlerBase>(ssomStandartValidationAsm))
                _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
                                  }));
            };
        }
        static void Main(string[] args)
        {
            var siteUrl = "http://portal";
            var consoleUtils = new ConsoleUtils();

            consoleUtils.WithSSOMContext(siteUrl, (site, web) =>
            {
                // replace it with your M2 models
                var siteModel = default(ModelNode);
                var rotWebModel = default(ModelNode);

                // create a provision service - SSOMProvisionService or StandardSSOMProvisionService
                var provisionService = new SSOMProvisionService();

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

                // deploy!
                provisionService.DeploySiteModel(site, siteModel);
                provisionService.DeployWebModel(web, rotWebModel);
            });
        }
Esempio n. 13
0
 public static void DeployWebModel(this SSOMProvisionService modelHost, SPWeb web, ModelNode model)
 {
     modelHost.DeployModel(WebModelHost.FromWeb(web), model);
 }
Esempio n. 14
0
 public static void DeploySiteModel(this SSOMProvisionService modelHost, SPSite site, ModelNode model)
 {
     modelHost.DeployModel(SiteModelHost.FromSite(site), model);
 }
Esempio n. 15
0
 public static void DeployWebApplicationModel(this SSOMProvisionService modelHost, SPWebApplication webApplication, ModelNode model)
 {
     modelHost.DeployModel(WebApplicationModelHost.FromWebApplication(webApplication), model);
 }
Esempio n. 16
0
 public static void DeployFarmModel(this SSOMProvisionService modelHost, SPFarm farm, ModelNode model)
 {
     modelHost.DeployModel(FarmModelHost.FromFarm(farm), model);
 }