43 lines
1.6 KiB
PowerShell
43 lines
1.6 KiB
PowerShell
function Merge-Templates {
|
|
$Errors = @()
|
|
[System.Collections.Hashtable] $ConfigurationData = @{}
|
|
#[System.Collections.Specialized.OrderedDictionary] $ConfigurationData = @{}
|
|
|
|
for ($i = 0; $i -lt $selectionList.Items.Count; $i++) {
|
|
$item = $selectionList.Items[$i]
|
|
$file = $item.FullName
|
|
if (-not (Test-Path $file)) { $Errors += "Datei nicht gefunden: $file"; continue }
|
|
|
|
try {
|
|
try {
|
|
$TemplateData = Import-OrderedPowerShellDataFile -Path $file -ErrorAction Stop
|
|
}
|
|
catch {
|
|
$Errors += "Datei konnte nicht importiert werden"
|
|
}
|
|
|
|
$ConfigurationData = Merge-ConfigurationData -Template $ConfigurationData -Deployment $TemplateData
|
|
}
|
|
catch {
|
|
$Errors += "Fehler beim Verarbeiten $($file): $($_.Exception.Message)"
|
|
}
|
|
}
|
|
|
|
if ($null -ne $ConfigurationData) {
|
|
Update-TreeView -ConfigurationData $([TemplateBuilder]::new($ConfigurationData).ResolveDeploymentDataVariables())
|
|
$statusBar.SetText("Status", "Merge erfolgreich: $($selectionList.Items.Count) Dateien")
|
|
}
|
|
else {
|
|
|
|
Update-TreeView -ConfigurationData $ConfigurationData
|
|
$statusLabel.Text = "Merge ergab kein Ergebnis"
|
|
}
|
|
|
|
if ($Errors.Count -gt 0) {
|
|
[System.Windows.Forms.MessageBox]::Show(($Errors -join "`r`n"), "Merge Warnungen", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Warning)
|
|
return
|
|
}
|
|
else {
|
|
return $ConfigurationData
|
|
}
|
|
} |