private void DeployDefinition(object modelHost, WebModelHost webModelHost, PageLayoutAndSiteTemplateSettingsDefinition definition) { var web = webModelHost.HostWeb; var publishingWeb = PublishingWeb.GetPublishingWeb(web); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = definition, ModelHost = modelHost }); ProcessWebTemplateSettings(publishingWeb, definition); ProcessPageLayoutSettings(publishingWeb, definition); ProcessNewPageDefaultSettings(publishingWeb, definition); ProcessConverBlankSpacesIntoHyphenSetting(publishingWeb, definition); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = definition, ModelHost = modelHost }); publishingWeb.Update(); }
protected WebNavigationSettings GetWebNavigationSettings(WebModelHost webModelHost, WebNavigationSettingsDefinition navigationModel) { var web = webModelHost.HostWeb; var thisWebNavSettings = new WebNavigationSettings(web); return thisWebNavSettings; }
protected virtual SPAppPrincipal FindExistingAppPrincipal(WebModelHost webHost, AppPrincipalDefinition appPrincipalModel) { var appPrincipalManager = SPAppPrincipalManager.GetManager(webHost.HostWeb); var appPrincipalProvider = SPAppPrincipalIdentityProvider.External; var appPrincipalName = SPAppPrincipalName.CreateFromAppPrincipalIdentifier(appPrincipalModel.AppId); return appPrincipalManager.LookupAppPrincipal(appPrincipalProvider, appPrincipalName); }
private void DeployClearRecycleUnderWeb(object modelHost, WebModelHost typedModelHost, ClearRecycleBinDefinition typedDefinition) { var web = typedModelHost.HostWeb; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = typedDefinition, ModelHost = modelHost }); if (typedDefinition.RestoreAll) { web.RecycleBin.RestoreAll(); } if (typedDefinition.DeleteAll) { web.RecycleBin.DeleteAll(); } if (typedDefinition.MoveAllToSecondStage) { web.RecycleBin.MoveAllToSecondStage(); } if (typedDefinition.DeleteAllInSecondStage) { web.Site.RecycleBin.DeleteAll(); } InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = typedDefinition, ModelHost = modelHost }); }
private void DeployDefinition(object modelHost, WebModelHost typedModelHost, DeleteTopNavigationNodesDefinition typedDefinition) { var web = typedModelHost.HostWeb; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = typedDefinition, ModelHost = modelHost }); if (typedDefinition.NavigationNodes != null && typedDefinition.NavigationNodes.Any()) { var nodesCollection = GetNavigationNodeCollection(web); DeleteNavigationNodesService.DeleteNodesByMatch(typedDefinition, nodesCollection, url => { return ResolveTokenizedUrl(typedModelHost, url); }); } InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = typedDefinition, ModelHost = modelHost }); }
private void DeployWebDependentLookup(object modelHost, WebModelHost webModelHost, DependentLookupFieldDefinition definition) { DeployDependentLookupField(modelHost, webModelHost.HostWeb.Fields, definition); }
private void DeployApp(object modelHost, WebModelHost webHost, AppDefinition appModel) { var web = webHost.HostWeb; Guid appId = Guid.Empty; TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Creating memory stream on appModel.Content"); using (var appPackage = new MemoryStream(appModel.Content)) { var currentApplications = FindExistingApps(webHost, appModel); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = currentApplications.FirstOrDefault(), ObjectType = typeof(SPAppInstance), ObjectDefinition = appModel, ModelHost = modelHost }); if (currentApplications == null || currentApplications.Count == 0) { TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Cannot find application by productId. Loading and installing new instance."); // install new var newAppInstance = web.LoadAndInstallApp(appPackage); if (newAppInstance != null && newAppInstance.Status == SPAppInstanceStatus.Initialized) { appId = newAppInstance.Id; var count = 0; SPAppInstance localInstance = null; do { TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Waiting while app is being installed for [{0}] milliseconds.", WaitTimeInMillliseconds); Thread.Sleep(WaitTimeInMillliseconds); localInstance = web.GetAppInstanceById(appId); count++; } while (localInstance != null && localInstance.Status != SPAppInstanceStatus.Installed && count < MaxInstallAttempCount); } newAppInstance = web.GetAppInstanceById(appId); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = newAppInstance, ObjectType = typeof(SPAppInstance), ObjectDefinition = appModel, ModelHost = modelHost }); } else { TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing application"); for (int i = 0; i < currentApplications.Count; i++) { var upApp = currentApplications[i]; var upVersion = new Version(upApp.App.VersionString); var targetVersion = new Version(appModel.Version); if (upVersion < targetVersion) currentApplications[i].Upgrade(appPackage); } InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = currentApplications.FirstOrDefault(), ObjectType = typeof(SPAppInstance), ObjectDefinition = appModel, ModelHost = modelHost }); } } }
protected IList<SPAppInstance> FindExistingApps(WebModelHost webHost, AppDefinition appModel) { return webHost.HostWeb.GetAppInstancesByProductId(appModel.ProductId); }
private void DeployWebWorkflowAssociationDefinition(WebModelHost modelHost, Microsoft.SharePoint.SPWeb web, WorkflowAssociationDefinition definition) { var existingWorkflowAssotiation = FindExistringWorkflowAssotiation(modelHost, definition); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = existingWorkflowAssotiation, ObjectType = typeof(SPWorkflowAssociation), ObjectDefinition = definition, ModelHost = modelHost }); bool isNew = false; if (existingWorkflowAssotiation == null) { var workflowTemplate = GetWorkflowTemplate(modelHost, definition); if (workflowTemplate == null) { throw new SPMeta2Exception( string.Format("Cannot find workflow template by definition:[{0}]", definition)); } existingWorkflowAssotiation = SPWorkflowAssociation.CreateListAssociation(workflowTemplate, definition.Name, web.Lists[definition.TaskListTitle], web.Lists[definition.HistoryListTitle]); isNew = true; } MapProperties(definition, existingWorkflowAssotiation); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = existingWorkflowAssotiation, ObjectType = typeof(SPWorkflowAssociation), ObjectDefinition = definition, ModelHost = modelHost }); if (isNew) { web.WorkflowAssociations.Add(existingWorkflowAssotiation); web.Update(); } else { web.WorkflowAssociations.Update(existingWorkflowAssotiation); } }
private void DeployApp(object modelHost, WebModelHost webHost, AppDefinition appModel) { var web = webHost.HostWeb; Guid appId = Guid.Empty; TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Creating memory stream on appModel.Content"); using (var appPackage = new MemoryStream(appModel.Content)) { var currentApplications = FindExistingApps(webHost, appModel); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = currentApplications.FirstOrDefault(), ObjectType = typeof(SPAppInstance), ObjectDefinition = appModel, ModelHost = modelHost }); if (currentApplications.Count == 0) { TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Cannot find application by productId. Loading and installing new instance."); // install new var newAppInstance = web.LoadAndInstallApp(appPackage); if (newAppInstance != null && newAppInstance.Status == SPAppInstanceStatus.Initialized) { appId = newAppInstance.Id; var count = 0; SPAppInstance localInstance = null; do { TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Waiting while app is being installed for [{0}] milliseconds.", WaitTimeInMillliseconds); Thread.Sleep(WaitTimeInMillliseconds); localInstance = web.GetAppInstanceById(appId); count++; } while (localInstance != null && localInstance.Status != SPAppInstanceStatus.Installed && count < MaxInstallAttempCount); } newAppInstance = web.GetAppInstanceById(appId); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = newAppInstance, ObjectType = typeof(SPAppInstance), ObjectDefinition = appModel, ModelHost = modelHost }); } else { //we had check early var currentApp = currentApplications.FirstOrDefault(); TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, string.Format("Processing existing application. Upgrading from [{0}] to [{1}]", currentApp.App.VersionString, appModel.Version)); var hasUpdate = false; for (int i = 0; i < currentApplications.Count; i++) { var spApp = currentApplications[i]; var spAppVersion = new Version(spApp.App.VersionString); var definitionVersion = new Version(appModel.Version); if (definitionVersion > spAppVersion) { TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Performing upgrade"); var updateAppInstance = currentApplications[i]; var updateAppId = updateAppInstance.Id; var count = 0; SPAppInstance localUpdateAppInstance = null; updateAppInstance.Upgrade(appPackage); do { TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Waiting while app is being installed for [{0}] milliseconds.", WaitTimeInMillliseconds); Thread.Sleep(WaitTimeInMillliseconds); localUpdateAppInstance = web.GetAppInstanceById(updateAppId); count++; } while (localUpdateAppInstance != null && localUpdateAppInstance.Status != SPAppInstanceStatus.Installed && count < MaxInstallAttempCount); hasUpdate = true; } else { TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Skipping upgrade due to the lower version"); } } if (hasUpdate) { // refreshing the app collection after update // the .App.VersionString property will be refreshed currentApplications = FindExistingApps(webHost, appModel); } InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = currentApplications.FirstOrDefault(), ObjectType = typeof(SPAppInstance), ObjectDefinition = appModel, ModelHost = modelHost }); } } }
private void DeployWebWorkflowAssociationDefinition(WebModelHost webModelHost, Microsoft.SharePoint.SPWeb web, WorkflowAssociationDefinition workflowAssociationModel) { // TODO }
private void DeployWebEventReceiver(object modelHost, WebModelHost listModelHost, EventReceiverDefinition definition) { DeployEventReceiver(modelHost, listModelHost.HostWeb.EventReceivers, definition); }
private void DeployAppPrincipal(object modelHost, WebModelHost webHost, AppPrincipalDefinition appPrincipalModel) { var appPrincipalManager = SPAppPrincipalManager.GetManager(webHost.HostWeb); var principal = FindExistingAppPrincipal(webHost, appPrincipalModel); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = principal, ObjectType = typeof(SPAppPrincipal), ObjectDefinition = appPrincipalModel, ModelHost = modelHost }); if (principal == null) { TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing app principal"); var endpoints = new List<string>(); endpoints.Add(appPrincipalModel.RedirectURI); var secureString = new SecureString(); for (int i = 0; i < appPrincipalModel.AppSecret.Length; i++) { char c = appPrincipalModel.AppSecret[i]; secureString.AppendChar(c); } secureString.MakeReadOnly(); var now = DateTime.Now; var credential = SPAppPrincipalCredential.CreateFromSymmetricKey(secureString, now, now.AddYears(1)); var externalAppPrincipalCreationParameters = new SPExternalAppPrincipalCreationParameters(appPrincipalModel.AppId, appPrincipalModel.Title, endpoints, credential) { SkipExternalDirectoryRegistration = false }; principal = appPrincipalManager.CreateAppPrincipal(externalAppPrincipalCreationParameters); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = principal, ObjectType = typeof(SPAppPrincipal), ObjectDefinition = appPrincipalModel, ModelHost = modelHost }); } else { TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing app principal"); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = principal, ObjectType = typeof(SPAppPrincipal), ObjectDefinition = appPrincipalModel, ModelHost = modelHost }); } }
private void ApplyComposedLookUnderWeb(object modelHost, WebModelHost typedModelHost, ComposedLookItemLinkDefinition typedDefinition) { var web = typedModelHost.HostWeb; var rootWeb = typedModelHost.HostWeb.Site.RootWeb; var siteRelativeUrl = web.Site.ServerRelativeUrl; var composedLookName = typedDefinition.ComposedLookItemName; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = typedDefinition, ModelHost = modelHost }); var composedLookList = web.GetCatalog(SPListTemplateType.DesignCatalog); var items = composedLookList.GetItems(new SPQuery { Query = CamlQueryUtils.WhereItemByFieldValueQuery("Name", composedLookName), RowLimit = 1 }); var targetComposedLookItem = items.Count > 0 ? items[0] : null; if (targetComposedLookItem == null) throw new SPMeta2Exception(string.Format("Can't find composed look by name: [{0}]", composedLookName)); var name = ConvertUtils.ToString(targetComposedLookItem["Name"]); var masterPageUrl = GetUrlValue(targetComposedLookItem, "MasterPageUrl"); if (!string.IsNullOrEmpty(masterPageUrl)) { var targetMasterPageUrl = masterPageUrl; if (SPUrlUtility.IsUrlFull(masterPageUrl)) targetMasterPageUrl = web.GetServerRelativeUrlFromUrl(masterPageUrl); web.CustomMasterUrl = targetMasterPageUrl; web.MasterUrl = targetMasterPageUrl; web.Update(); } var themeUrl = GetUrlValue(targetComposedLookItem, "ThemeUrl"); var fontSchemeUrl = GetUrlValue(targetComposedLookItem, "FontSchemeUrl"); var imageUrl = GetUrlValue(targetComposedLookItem, "ImageUrl"); var themeFile = rootWeb.GetFile(themeUrl); SPFile fontFile = null; if (!string.IsNullOrEmpty(fontSchemeUrl)) fontFile = rootWeb.GetFile(fontSchemeUrl); SPTheme theme = null; if (!string.IsNullOrEmpty(imageUrl)) { theme = SPTheme.Open(name, themeFile, fontFile != null && fontFile.Exists ? fontFile : null, new Uri(imageUrl)); } else { theme = SPTheme.Open(name, themeFile, fontFile != null && fontFile.Exists ? fontFile : null); } theme.ApplyTo(web, false); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = typedDefinition, ModelHost = modelHost }); // cirrent web was updated by theme engine // http://ehikioya.com/apply-themes-to-sharepoint/ typedModelHost.ShouldUpdateHost = false; }
private SPNavigationNode EnsureRootQuickLaunchNavigationNode( WebModelHost webModelHost, QuickLaunchNavigationNodeDefinition quickLaunchNode) { var web = webModelHost.HostWeb; var quickLaunch = web.Navigation.QuickLaunch; var existingNode = quickLaunch.OfType<SPNavigationNode>() .FirstOrDefault(n => n.Url == quickLaunchNode.Url); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = existingNode, ObjectType = typeof(SPNavigationNode), ObjectDefinition = quickLaunchNode, ModelHost = existingNode }); if (existingNode == null) { existingNode = new SPNavigationNode(quickLaunchNode.Title, quickLaunchNode.Url, quickLaunchNode.IsExternal); quickLaunch.AddAsLast(existingNode); } existingNode.Title = quickLaunchNode.Title; existingNode.Url = quickLaunchNode.Url; existingNode.IsVisible = quickLaunchNode.IsVisible; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = existingNode, ObjectType = typeof(SPNavigationNode), ObjectDefinition = quickLaunchNode, ModelHost = existingNode }); existingNode.Update(); return existingNode; }
private void DeployNavigationSettings(object modelHost, WebModelHost webModelHost, WebNavigationSettingsDefinition navigationModel) { var site = webModelHost.HostWeb.Site; var web = webModelHost.HostWeb; var thisWebNavSettings = GetWebNavigationSettings(webModelHost, navigationModel); var shouldUpdateWeb = false; var allProperties = web.AllProperties; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = thisWebNavSettings, ObjectType = typeof(WebNavigationSettings), ObjectDefinition = navigationModel, ModelHost = modelHost }); if (!string.IsNullOrEmpty(navigationModel.GlobalNavigationSource) || !string.IsNullOrEmpty(navigationModel.CurrentNavigationSource)) { if (!string.IsNullOrEmpty(navigationModel.GlobalNavigationSource)) { var globalSource = (StandardNavigationSource)Enum.Parse(typeof(StandardNavigationSource), navigationModel.GlobalNavigationSource); thisWebNavSettings.GlobalNavigation.Source = globalSource; if (globalSource == StandardNavigationSource.TaxonomyProvider) { var globalTermStore = TaxonomyTermStoreModelHandler.FindTermStore(site, navigationModel.GlobalNavigationTermStoreName, navigationModel.GlobalNavigationTermStoreId, navigationModel.GlobalNavigationUseDefaultSiteCollectionTermStore); var globalTermSet = TaxonomyFieldModelHandler.LookupTermSet(globalTermStore, null, null, null, null, navigationModel.GlobalNavigationTermSetName, navigationModel.GlobalNavigationTermSetId, navigationModel.GlobalNavigationTermSetLCID); thisWebNavSettings.GlobalNavigation.TermStoreId = globalTermStore.Id; thisWebNavSettings.GlobalNavigation.TermSetId = globalTermSet.Id; } else { int? globalNavigationIncludeTypes = GetGlobalNavigationIncludeTypes(navigationModel, ConvertUtils.ToInt(allProperties[BuiltInWebPropertyId.GlobalNavigationIncludeTypes])); if (globalNavigationIncludeTypes != null) { allProperties[BuiltInWebPropertyId.GlobalNavigationIncludeTypes] = globalNavigationIncludeTypes.Value; shouldUpdateWeb = true; } if (navigationModel.GlobalNavigationMaximumNumberOfDynamicItems.HasValue) { allProperties[BuiltInWebPropertyId.GlobalDynamicChildLimit] = navigationModel.GlobalNavigationMaximumNumberOfDynamicItems.Value; shouldUpdateWeb = true; } } } if (!string.IsNullOrEmpty(navigationModel.CurrentNavigationSource)) { var currentSource = (StandardNavigationSource)Enum.Parse(typeof(StandardNavigationSource), navigationModel.CurrentNavigationSource); thisWebNavSettings.CurrentNavigation.Source = currentSource; if (currentSource == StandardNavigationSource.TaxonomyProvider) { var currentTermStore = TaxonomyTermStoreModelHandler.FindTermStore(site, navigationModel.CurrentNavigationTermStoreName, navigationModel.CurrentNavigationTermStoreId, navigationModel.CurrentNavigationUseDefaultSiteCollectionTermStore); var currentTermSet = TaxonomyFieldModelHandler.LookupTermSet(currentTermStore, null, null, null, null, navigationModel.CurrentNavigationTermSetName, navigationModel.CurrentNavigationTermSetId, navigationModel.CurrentNavigationTermSetLCID); thisWebNavSettings.CurrentNavigation.TermStoreId = currentTermStore.Id; thisWebNavSettings.CurrentNavigation.TermSetId = currentTermSet.Id; } else { int? currentNavigationIncludeTypes = GetCurrentNavigationIncludeTypes(navigationModel, ConvertUtils.ToInt(allProperties[BuiltInWebPropertyId.CurrentNavigationIncludeTypes])); if (currentNavigationIncludeTypes != null) { allProperties[BuiltInWebPropertyId.CurrentNavigationIncludeTypes] = currentNavigationIncludeTypes.Value; shouldUpdateWeb = true; } if (navigationModel.CurrentNavigationMaximumNumberOfDynamicItems.HasValue) { allProperties[BuiltInWebPropertyId.CurrentDynamicChildLimit] = navigationModel.CurrentNavigationMaximumNumberOfDynamicItems.Value; shouldUpdateWeb = true; } } } } if (navigationModel.DisplayShowHideRibbonAction.HasValue) { allProperties["__DisplayShowHideRibbonActionId"] = navigationModel.DisplayShowHideRibbonAction.ToString(); shouldUpdateWeb = true; } InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = thisWebNavSettings, ObjectType = typeof(WebNavigationSettings), ObjectDefinition = navigationModel, ModelHost = modelHost }); if (shouldUpdateWeb) web.Update(); if (!string.IsNullOrEmpty(navigationModel.GlobalNavigationSource) || !string.IsNullOrEmpty(navigationModel.CurrentNavigationSource)) { thisWebNavSettings.Update(null); } }
private void DeployMasterPageSettings(object modelHost, WebModelHost webModelHost, MasterPageSettingsDefinition masterPageSettings) { var web = webModelHost.HostWeb; var site = web.Site; var siteRelativeUrl = site.ServerRelativeUrl; TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Resolving server relative URL: [{0}]", siteRelativeUrl); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = masterPageSettings, ModelHost = modelHost }); if (!string.IsNullOrEmpty(masterPageSettings.SiteMasterPageUrl)) { TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Setting web.MasterUrlL: [{0}]", masterPageSettings.SiteMasterPageUrl); web.CustomMasterUrl = SPUrlUtility.CombineUrl(siteRelativeUrl, masterPageSettings.SiteMasterPageUrl); } if (!string.IsNullOrEmpty(masterPageSettings.SystemMasterPageUrl)) { TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Setting web.CustomMasterUrl: [{0}]", masterPageSettings.SystemMasterPageUrl); web.MasterUrl = SPUrlUtility.CombineUrl(siteRelativeUrl, masterPageSettings.SystemMasterPageUrl); } if (!string.IsNullOrEmpty(masterPageSettings.SiteMasterPageUrl) || !string.IsNullOrEmpty(masterPageSettings.SystemMasterPageUrl)) { InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = masterPageSettings, ModelHost = modelHost }); TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Calling web.Update()"); web.Update(); } else { InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = web, ObjectType = typeof(SPWeb), ObjectDefinition = masterPageSettings, ModelHost = modelHost }); } }