public override void Traverse(object modelHost, ModelNode modelNode) { try { var modelDefinition = modelNode.Value as DefinitionBase; var modelHandler = OnModelHandlerResolve(modelNode); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelFullyProcessing for model: [{0}].", modelNode); if (OnModelFullyProcessing != null) OnModelFullyProcessing(modelNode); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelProcessing for model: [{0}].", modelNode); if (OnModelProcessing != null) OnModelProcessing(modelNode); //var requireselfProcessing = modelDefinition.RequireSelfProcessing || modelNode.Options.RequireSelfProcessing; var requireselfProcessing = modelNode.Options.RequireSelfProcessing; TraceService.InformationFormat((int)LogEventId.ModelProcessing, "Deploying model [{0}] RSP: [{1}] : [{2}].", new[] { modelNode.Value.GetType().Name, requireselfProcessing.ToString(), modelNode.Value.ToString() }); if (requireselfProcessing) { modelHandler.DeployModel(modelHost, modelNode.Value); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelProcessed for model: [{0}].", modelNode); if (OnModelProcessed != null) OnModelProcessed(modelNode); var childModelTypes = GetSortedChildModelTypes(modelNode); foreach (var childModelType in childModelTypes) { TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Starting processing child models of type: [{0}].", new object[] { childModelType.Key }); var childModels = modelNode.GetChildModels(childModelType.Key).ToList(); ModelWeighService.SortChildModelNodes(modelNode, childModels); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Found [{0}] models of type: [{1}].", new object[] { childModels.Count(), childModelType.Key }); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnChildModelsProcessing of type: [{0}].", new object[] { childModelType.Key }); if (OnChildModelsProcessing != null) OnChildModelsProcessing(modelNode, childModelType.Key, childModels); foreach (var childModel in childModels) { TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Starting resolving model host of type: [{0}].", new object[] { childModelType.Key }); modelHandler.WithResolvingModelHost(new ModelHostResolveContext { ModelHost = modelHost, Model = modelDefinition, ChildModelType = childModelType.Key, ModelNode = modelNode, Action = childModelHost => { Traverse(childModelHost, childModel); } }); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Finishing resolving model host of type: [{0}].", new object[] { childModelType.Key }); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnChildModelsProcessed of type: [{0}].", new object[] { childModelType.Key }); if (OnChildModelsProcessed != null) OnChildModelsProcessed(modelNode, childModelType.Key, childModels); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Finishing processing child models of type: [{0}].", new object[] { childModelType.Key }); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelFullyProcessed for model: [{0}].", modelNode); if (OnModelFullyProcessed != null) OnModelFullyProcessed(modelNode); } catch (Exception e) { if (e is SPMeta2ModelDeploymentException) throw; throw new SPMeta2ModelDeploymentException("There was an error while provisioning definition. Check ModelNode prop.", e) { ModelNode = modelNode, }; } }
public override void Traverse(object modelHost, ModelNode modelNode) { try { var modelDefinition = modelNode.Value as DefinitionBase; var modelHandler = OnModelHandlerResolve(modelNode); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelFullyProcessing for model: [{0}].", modelNode); if (OnModelFullyProcessing != null) { OnModelFullyProcessing(modelNode); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelProcessing for model: [{0}].", modelNode); if (OnModelProcessing != null) { OnModelProcessing(modelNode); } var requireselfProcessing = modelDefinition.RequireSelfProcessing || modelNode.Options.RequireSelfProcessing; TraceService.InformationFormat((int)LogEventId.ModelProcessing, "Deploying model [{0}] RSP: [{1}] : [{2}].", new[] { modelNode.Value.GetType().Name, requireselfProcessing.ToString(), modelNode.Value.ToString() }); if (requireselfProcessing) { modelHandler.DeployModel(modelHost, modelNode.Value); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelProcessed for model: [{0}].", modelNode); if (OnModelProcessed != null) { OnModelProcessed(modelNode); } var childModelTypes = GetSortedChildModelTypes(modelNode); foreach (var childModelType in childModelTypes) { TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Starting processing child models of type: [{0}].", new object[] { childModelType.Key }); var childModels = modelNode.GetChildModels(childModelType.Key).ToList(); ModelWeighService.SortChildModelNodes(modelNode, childModels); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Found [{0}] models of type: [{1}].", new object[] { childModels.Count(), childModelType.Key }); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnChildModelsProcessing of type: [{0}].", new object[] { childModelType.Key }); if (OnChildModelsProcessing != null) { OnChildModelsProcessing(modelNode, childModelType.Key, childModels); } foreach (var childModel in childModels) { TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Starting resolving model host of type: [{0}].", new object[] { childModelType.Key }); modelHandler.WithResolvingModelHost(new ModelHostResolveContext { ModelHost = modelHost, Model = modelDefinition, ChildModelType = childModelType.Key, ModelNode = modelNode, Action = childModelHost => { Traverse(childModelHost, childModel); } }); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Finishing resolving model host of type: [{0}].", new object[] { childModelType.Key }); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnChildModelsProcessed of type: [{0}].", new object[] { childModelType.Key }); if (OnChildModelsProcessed != null) { OnChildModelsProcessed(modelNode, childModelType.Key, childModels); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Finishing processing child models of type: [{0}].", new object[] { childModelType.Key }); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelFullyProcessed for model: [{0}].", modelNode); if (OnModelFullyProcessed != null) { OnModelFullyProcessed(modelNode); } } catch (Exception e) { if (e is SPMeta2ModelDeploymentException) { throw; } throw new SPMeta2ModelDeploymentException("There was an error while provisioning definition. Check ModelNode prop.", e) { ModelNode = modelNode, }; } }
public override void Traverse(object modelHost, ModelNode modelNode) { try { if (CurrentModelPath.Count == 0) { OnBeforeDeployModel(modelHost, modelNode); } CurrentModelPath.Push(modelNode); var modelDefinition = modelNode.Value as DefinitionBase; var modelHandler = OnModelHandlerResolve(modelNode); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelFullyProcessing for model: [{0}].", modelNode); if (OnModelFullyProcessing != null) { OnModelFullyProcessing(modelNode); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelProcessing for model: [{0}].", modelNode); OnBeforeDeployModelNode(modelHost, modelNode); if (OnModelProcessing != null) { OnModelProcessing(modelNode); } //var requireselfProcessing = modelDefinition.RequireSelfProcessing || modelNode.Options.RequireSelfProcessing; var requireselfProcessing = modelNode.Options.RequireSelfProcessing; TraceService.InformationFormat((int)LogEventId.ModelProcessing, "Deploying model [{0}] RSP: [{1}] : [{2}].", new[] { modelNode.Value.GetType().Name, requireselfProcessing.ToString(), modelNode.Value.ToString() }); if (requireselfProcessing) { try { modelHandler.DeployModel(modelHost, modelNode.Value); } catch (Exception e) { var onExceptionArgs = new ModelTreeTraverseServiceExceptionEventArgs { Handled = false, Exception = e }; if (OnException != null) { OnException(this, onExceptionArgs); } if (!onExceptionArgs.Handled) { throw; } } } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelProcessed for model: [{0}].", modelNode); // call up before OnModelProcessed // Incremental provision real time trace problems #978 // https://github.com/SubPointSolutions/spmeta2/issues/978 OnAfterDeployModelNode(modelHost, modelNode); if (OnModelProcessed != null) { OnModelProcessed(modelNode); } var childModelTypes = GetSortedChildModelTypes(modelNode); foreach (var childModelType in childModelTypes) { TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Starting processing child models of type: [{0}].", new object[] { childModelType.Key }); var childModels = modelNode.GetChildModels(childModelType.Key).ToList(); ModelWeighService.SortChildModelNodes(modelNode, childModels); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Found [{0}] models of type: [{1}].", new object[] { childModels.Count(), childModelType.Key }); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnChildModelsProcessing of type: [{0}].", new object[] { childModelType.Key }); if (OnChildModelsProcessing != null) { OnChildModelsProcessing(modelNode, childModelType.Key, childModels); } foreach (var childModel in childModels) { TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Starting resolving model host of type: [{0}].", new object[] { childModelType.Key }); modelHandler.WithResolvingModelHost(new ModelHostResolveContext { ModelHost = modelHost, Model = modelDefinition, ChildModelType = childModelType.Key, ModelNode = modelNode, Action = childModelHost => { Traverse(childModelHost, childModel); } }); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Finishing resolving model host of type: [{0}].", new object[] { childModelType.Key }); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnChildModelsProcessed of type: [{0}].", new object[] { childModelType.Key }); if (OnChildModelsProcessed != null) { OnChildModelsProcessed(modelNode, childModelType.Key, childModels); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Finishing processing child models of type: [{0}].", new object[] { childModelType.Key }); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelFullyProcessed for model: [{0}].", modelNode); if (OnModelFullyProcessed != null) { OnModelFullyProcessed(modelNode); } } catch (Exception e) { var onExceptionArgs = new ModelTreeTraverseServiceExceptionEventArgs { Handled = false, Exception = e }; if (OnException != null) { OnException(this, onExceptionArgs); } if (!onExceptionArgs.Handled) { if (e is SPMeta2ModelDeploymentException) { throw; } throw new SPMeta2ModelDeploymentException( "There was an error while provisioning definition. Check ModelNode prop.", e) { ModelNode = modelNode, }; } } finally { if (CurrentModelPath.Count != 0) { CurrentModelPath.Pop(); } if (CurrentModelPath.Count == 0) { OnAfterDeployModel(modelHost, modelNode); } } }
public override void Traverse(object modelHost, ModelNode modelNode) { var modelDefinition = modelNode.Value as DefinitionBase; var modelHandler = OnModelHandlerResolve(modelNode); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelFullyProcessing for model: [{0}].", modelNode); if (OnModelFullyProcessing != null) { OnModelFullyProcessing(modelNode); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelProcessing for model: [{0}].", modelNode); if (OnModelProcessing != null) { OnModelProcessing(modelNode); } if (modelDefinition.RequireSelfProcessing || modelNode.Options.RequireSelfProcessing) { modelHandler.DeployModel(modelHost, modelNode.Value); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelProcessed for model: [{0}].", modelNode); if (OnModelProcessed != null) { OnModelProcessed(modelNode); } var childModelTypes = GetSortedChildModelTypes(modelNode); foreach (var childModelType in childModelTypes) { TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Starting processing child models of type: [{0}].", new object[] { childModelType.Key }); var childModels = modelNode.GetChildModels(childModelType.Key); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Found [{0}] models of type: [{1}].", new object[] { childModels.Count(), childModelType.Key }); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnChildModelsProcessing of type: [{0}].", new object[] { childModelType.Key }); if (OnChildModelsProcessing != null) { OnChildModelsProcessing(modelNode, childModelType.Key, childModels); } foreach (var childModel in childModels) { TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Starting resolving model host of type: [{0}].", new object[] { childModelType.Key }); modelHandler.WithResolvingModelHost(new ModelHostResolveContext { ModelHost = modelHost, Model = modelDefinition, ChildModelType = childModelType.Key, ModelNode = modelNode, Action = childModelHost => { Traverse(childModelHost, childModel); } }); TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Finishing resolving model host of type: [{0}].", new object[] { childModelType.Key }); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnChildModelsProcessed of type: [{0}].", new object[] { childModelType.Key }); if (OnChildModelsProcessed != null) { OnChildModelsProcessed(modelNode, childModelType.Key, childModels); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Finishing processing child models of type: [{0}].", new object[] { childModelType.Key }); } TraceService.VerboseFormat((int)LogEventId.ModelProcessing, "Raising OnModelFullyProcessed for model: [{0}].", modelNode); if (OnModelFullyProcessed != null) { OnModelFullyProcessed(modelNode); } }
private void ProcessModelDeployment(object modelHost, ModelNode modelNode) { InvokeOnModelNodeProcessing(this, new OnModelNodeProcessingEventArgs { ModelNode = modelNode, ModelHost = modelHost }); var modelDefinition = modelNode.Value as DefinitionBase; var modelHandler = ResolveModelHandler(modelDefinition.GetType()); if (modelHandler == null) { throw new ArgumentNullException( string.Format("Can't find model handler for type:[{0}]. Current ModelService type: [{1}].", modelDefinition.GetType(), GetType())); } // modelHandler might change a model host to allow continiuation // spsite -> spweb -> spcontentype -> spcontentypelink // process current model if (modelDefinition.RequireSelfProcessing) { _activeModelNode = modelNode; modelNode.State = ModelNodeState.Processing; modelHandler.DeployModel(modelHost, modelDefinition); modelNode.State = ModelNodeState.Processed; _activeModelNode = null; } InvokeOnModelNodeProcessed(this, new OnModelNodeProcessedEventArgs { ModelNode = modelNode, ModelHost = modelHost }); // TODO // here must be a "context change" to provide an ability to continue the // deployment chain with changes from SPWeb to SPList // sort out child models by types var childModelTypes = modelNode.ChildModels .Select(m => m.Value.GetType()) .GroupBy(t => t); foreach (var childModelType in childModelTypes) { modelHandler.WithResolvingModelHost(modelHost, modelDefinition, childModelType.Key, childModelHost => { var childModels = modelNode.GetChildModels(childModelType.Key); foreach (var childModel in childModels) { ProcessModelDeployment(childModelHost, childModel); } }); } }