Erweitere README mit Informationen zu WssId und Taxonomie-Feldverarbeitung; füge Kontextmenü zum Löschen von Mapping-Zeilen in der GUI hinzu
This commit is contained in:
@@ -808,6 +808,7 @@ $script:MigrationStreamPositions = @{}
|
||||
$script:MigrationCompletedHandler = $null
|
||||
$script:MigrationActionLabel = ""
|
||||
$script:LastMigrationErrorMessage = ""
|
||||
$script:PendingExportMappingPath = ""
|
||||
|
||||
function Get-ObjectPropertyValue {
|
||||
param(
|
||||
@@ -1257,6 +1258,7 @@ function Complete-MigrationScriptAsync {
|
||||
}
|
||||
}
|
||||
else {
|
||||
$script:PendingExportMappingPath = ""
|
||||
Show-UiMessage -Message $errorMessage -Caption ("{0} fehlgeschlagen" -f $actionLabel) -Icon ([System.Windows.Forms.MessageBoxIcon]::Error)
|
||||
}
|
||||
}
|
||||
@@ -1791,6 +1793,103 @@ function Set-DataTableRows {
|
||||
}
|
||||
}
|
||||
|
||||
function Add-MappingGridRowDeleteContextMenu {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[System.Windows.Forms.DataGridView]$Grid,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[System.Data.DataTable]$Table,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$MappingName
|
||||
)
|
||||
|
||||
$contextMenu = New-Object System.Windows.Forms.ContextMenuStrip
|
||||
$deleteRowItem = New-Object System.Windows.Forms.ToolStripMenuItem("Zeile loeschen")
|
||||
[void]$contextMenu.Items.Add($deleteRowItem)
|
||||
|
||||
$context = [PSCustomObject]@{
|
||||
Grid = $Grid
|
||||
Table = $Table
|
||||
MappingName = $MappingName
|
||||
ClickedRowIndex = -1
|
||||
}
|
||||
$contextMenu.Tag = $context
|
||||
|
||||
$Grid.Add_MouseDown({
|
||||
param($sender, $e)
|
||||
|
||||
if ($e.Button -ne [System.Windows.Forms.MouseButtons]::Right) {
|
||||
return
|
||||
}
|
||||
|
||||
$menuContext = $sender.ContextMenuStrip.Tag
|
||||
$hit = $sender.HitTest($e.X, $e.Y)
|
||||
$menuContext.ClickedRowIndex = $hit.RowIndex
|
||||
|
||||
if ($hit.RowIndex -lt 0) {
|
||||
$sender.ClearSelection()
|
||||
return
|
||||
}
|
||||
|
||||
$columnIndex = if ($hit.ColumnIndex -ge 0) { $hit.ColumnIndex } else { 0 }
|
||||
$sender.ClearSelection()
|
||||
$sender.CurrentCell = $sender.Rows[$hit.RowIndex].Cells[$columnIndex]
|
||||
$sender.Rows[$hit.RowIndex].Selected = $true
|
||||
})
|
||||
|
||||
$contextMenu.Add_Opening({
|
||||
param($sender, $e)
|
||||
|
||||
$menuContext = $sender.Tag
|
||||
if ($menuContext.ClickedRowIndex -lt 0 -or $menuContext.ClickedRowIndex -ge $menuContext.Grid.Rows.Count) {
|
||||
$e.Cancel = $true
|
||||
}
|
||||
})
|
||||
|
||||
$deleteRowItem.Add_Click({
|
||||
param($sender, $e)
|
||||
|
||||
$menuContext = $sender.Owner.Tag
|
||||
$rowIndex = [int]$menuContext.ClickedRowIndex
|
||||
if ($rowIndex -lt 0 -or $rowIndex -ge $menuContext.Grid.Rows.Count) {
|
||||
return
|
||||
}
|
||||
|
||||
$gridRow = $menuContext.Grid.Rows[$rowIndex]
|
||||
if ($gridRow.IsNewRow) {
|
||||
return
|
||||
}
|
||||
|
||||
$rowLabel = "Zeile {0}" -f ($rowIndex + 1)
|
||||
$dataRowView = $gridRow.DataBoundItem -as [System.Data.DataRowView]
|
||||
if ($null -ne $dataRowView) {
|
||||
foreach ($candidateColumn in @("SourceTitle", "SourceInternalName", "DisplayName")) {
|
||||
if (-not $menuContext.Table.Columns.Contains($candidateColumn)) {
|
||||
continue
|
||||
}
|
||||
|
||||
$candidateValue = [string]$dataRowView.Row[$candidateColumn]
|
||||
if (-not [string]::IsNullOrWhiteSpace($candidateValue)) {
|
||||
$rowLabel = "{0}='{1}'" -f $candidateColumn, $candidateValue
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
$menuContext.Table.Rows.Remove($dataRowView.Row)
|
||||
}
|
||||
else {
|
||||
$menuContext.Grid.Rows.Remove($gridRow)
|
||||
}
|
||||
|
||||
$menuContext.ClickedRowIndex = -1
|
||||
Write-UILog -Message ("Mapping-Zeile geloescht: Bereich='{0}'; {1}" -f $menuContext.MappingName, $rowLabel)
|
||||
})
|
||||
|
||||
$Grid.ContextMenuStrip = $contextMenu
|
||||
}
|
||||
|
||||
function Configure-MappingGrid {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
@@ -1800,7 +1899,10 @@ function Configure-MappingGrid {
|
||||
[System.Data.DataTable]$Table,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object[]]$Schema
|
||||
[object[]]$Schema,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$MappingName
|
||||
)
|
||||
|
||||
$Grid.DataSource = $Table
|
||||
@@ -1816,6 +1918,8 @@ function Configure-MappingGrid {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Add-MappingGridRowDeleteContextMenu -Grid $Grid -Table $Table -MappingName $MappingName
|
||||
}
|
||||
|
||||
function Convert-DataTableToObjects {
|
||||
@@ -2418,18 +2522,27 @@ function Invoke-ExportFromGui {
|
||||
}
|
||||
|
||||
$mappingPath = Join-Path -Path $outputPath -ChildPath "MappingTable.json"
|
||||
$script:PendingExportMappingPath = $mappingPath
|
||||
$onCompleted = {
|
||||
if (Test-Path -LiteralPath $mappingPath) {
|
||||
Load-MappingTableFromPath -Path $mappingPath
|
||||
Apply-ColumnDefaultsIfAvailable
|
||||
Save-MappingTableToPath -Path $mappingPath
|
||||
Show-MappingTab
|
||||
$completedMappingPath = [string]$script:PendingExportMappingPath
|
||||
|
||||
try {
|
||||
if (Test-Path -LiteralPath $completedMappingPath) {
|
||||
Load-MappingTableFromPath -Path $completedMappingPath
|
||||
Apply-ColumnDefaultsIfAvailable
|
||||
Save-MappingTableToPath -Path $completedMappingPath
|
||||
Show-MappingTab
|
||||
}
|
||||
}
|
||||
}.GetNewClosure()
|
||||
finally {
|
||||
$script:PendingExportMappingPath = ""
|
||||
}
|
||||
}
|
||||
|
||||
Invoke-MigrationScript -Parameters $parameters -ActionLabel "Export" -OnCompleted $onCompleted
|
||||
}
|
||||
catch {
|
||||
$script:PendingExportMappingPath = ""
|
||||
Write-UILog -Message $_.Exception.Message -Level "ERROR"
|
||||
Show-UiMessage -Message $_.Exception.Message -Caption "Export fehlgeschlagen" -Icon ([System.Windows.Forms.MessageBoxIcon]::Error)
|
||||
}
|
||||
@@ -2653,7 +2766,7 @@ $mappingLayout.ColumnCount = 1
|
||||
[void]$mappingLayout.RowStyles.Add((New-Object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Absolute, 34)))
|
||||
[void]$mappingLayout.RowStyles.Add((New-Object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 100)))
|
||||
|
||||
$mappingInfoLabel = ([LabelBuilder]::new("TargetTitle und TargetInternalName koennen hier direkt angepasst werden. Vor dem Import wird die MappingTable automatisch gespeichert.")).Build()
|
||||
$mappingInfoLabel = ([LabelBuilder]::new("TargetTitle und TargetInternalName koennen hier direkt angepasst werden. Mit Rechtsklick kann eine ganze Mapping-Zeile geloescht werden. Vor dem Import wird automatisch gespeichert.")).Build()
|
||||
$mappingInfoLabel.Dock = [System.Windows.Forms.DockStyle]::Fill
|
||||
|
||||
$mappingTabs = ([TabControlBuilder]::new()).SetDock("Fill").Build()
|
||||
@@ -2670,10 +2783,10 @@ $script:gridCustomColumns = ([DataGridViewBuilder]::new()).SetDock("Fill").SetAl
|
||||
|
||||
Initialize-MappingTables
|
||||
|
||||
Configure-MappingGrid -Grid $script:gridLibraryMappings -Table $script:LibraryMappingsTable -Schema $script:GridSchemas.LibraryMappings
|
||||
Configure-MappingGrid -Grid $script:gridListMappings -Table $script:ListMappingsTable -Schema $script:GridSchemas.ListMappings
|
||||
Configure-MappingGrid -Grid $script:gridSystemColumns -Table $script:SystemColumnsTable -Schema $script:GridSchemas.SystemColumns
|
||||
Configure-MappingGrid -Grid $script:gridCustomColumns -Table $script:CustomColumnsTable -Schema $script:GridSchemas.CustomColumns
|
||||
Configure-MappingGrid -Grid $script:gridLibraryMappings -Table $script:LibraryMappingsTable -Schema $script:GridSchemas.LibraryMappings -MappingName "Bibliotheken"
|
||||
Configure-MappingGrid -Grid $script:gridListMappings -Table $script:ListMappingsTable -Schema $script:GridSchemas.ListMappings -MappingName "Listen"
|
||||
Configure-MappingGrid -Grid $script:gridSystemColumns -Table $script:SystemColumnsTable -Schema $script:GridSchemas.SystemColumns -MappingName "System Columns"
|
||||
Configure-MappingGrid -Grid $script:gridCustomColumns -Table $script:CustomColumnsTable -Schema $script:GridSchemas.CustomColumns -MappingName "Custom Columns"
|
||||
|
||||
$libraryMappingTab.Controls.Add($script:gridLibraryMappings)
|
||||
$listMappingTab.Controls.Add($script:gridListMappings)
|
||||
|
||||
Reference in New Issue
Block a user