What about Vocabularies?
The process is somewhat similar, but the methods are a little different. In a Policy, you need to add the Policy, and then deploy it (optional) if you want it active. For a Vocabulary, you just need to add it, since Vocabularies don't get deployed.
Also, if a Policy uses a Vocabulary, the Vocabulary needs to be added first (much like an assembly reference).
The code snippet below gives an overview of how I accomplished this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# determine if Policy or Vocabulary - makes a difference on how we import it | |
[xml]$breFileXml = Get-Content $fileLocation | |
# node in Policy or Vocabulary. If one exists, the other will be null | |
$testPolicy = $breFileXml.brl.ruleset | |
$testVocab = $breFileXml.brl.vocabulary | |
if($testPolicy) | |
{ | |
# BRE Policy code here | |
} | |
elseif($testVocab) | |
{ | |
Write-Verbose "Beginning to import BRE Vocabulary file $($fileLocation)" -Verbose | |
$dd = New-Object Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver | |
[Microsoft.RuleEngine.SqlRuleStore]$sqlRuleStore = $dd.GetRuleStore() | |
$fileRuleStore = [Microsoft.RuleEngine.FileRuleStore]::new($fileLocation) | |
[Microsoft.RuleEngine.VocabularyInfoCollection]$vic = $fileRuleStore.GetVocabularies($RuleStore_Filter_All) | |
foreach($vi in $vic) | |
{ | |
[Microsoft.RuleEngine.Vocabulary] $vocabulary = $fileRuleStore.GetVocabulary($vi) | |
$publishedVocabulary = $true | |
$sqlRuleStore.Add($vocabulary, $publishedVocabulary) | |
# Vocabs can only be added/published, no need to deploy | |
Write-Verbose "Successfully imported: $($vi.Name), Version $($vi.MajorRevision).$($vi.MinorRevision)" -Verbose | |
} | |
} | |
else | |
{ | |
#??? | |
} |