16. Juni 2016 11:17
function SetModifiedFlagForAllObjects
{
[CmdletBinding()]
Param
(
[String][Parameter(Mandatory=$True)]
$PathObjectPack
)
$argspath = resolve-path $PathObjectPack
$WorkingFolder = split-path $argspath -Parent
$ObjectPackFileBaseName = (Get-Item $PathObjectPack).Basename
$NewObjectPackFullName = (Get-Item $PathObjectPack).DirectoryName + '\' + (Get-Item $PathObjectPack).Basename + '_IsModifiedFlag' + (Get-Item $PathObjectPack).Extension
New-Item -Path $WorkingFolder -type directory -Name TempNAVobjects -Force
$WorkingSubFolder = "$WorkingFolder\TempNAVobjects\"
remove-item $WorkingSubFolder\*.* -Recurse
Split-NAVApplicationObjectFile -Source $argspath -Destination $WorkingFolder\TempNAVobjects -PreserveFormatting -Force
foreach ($file in get-ChildItem -Path $WorkingSubFolder\ | Where {$_.extension -eq '.TXT'})
{
Set-NAVApplicationObjectProperty -Target $file.FullName -modifiedproperty Yes
}
Write-Host "Deleting old object files…"
IF (Test-Path $WorkingSubFolder\allobjects.txt) {Remove-Item $WorkingSubFolder\allobjects.txt}
IF (Test-Path $WorkingSubFolder\alltables.txt) {Remove-Item $WorkingSubFolder\alltables.txt}
IF (Test-Path $WorkingSubFolder\allreports.txt) {Remove-Item $WorkingSubFolder\allreports.txt}
IF (Test-Path $WorkingSubFolder\allcodeunits.txt) {Remove-Item $WorkingSubFolder\allcodeunits.txt}
IF (Test-Path $WorkingSubFolder\allxmlports.txt) {Remove-Item $WorkingSubFolder\allxmlports.txt}
IF (Test-Path $WorkingSubFolder\allmenusuites.txt) {Remove-Item $WorkingSubFolder\allmenusuites.txt}
IF (Test-Path $WorkingSubFolder\allpages.txt) {Remove-Item $WorkingSubFolder\allpages.txt}
IF (Test-Path $WorkingSubFolder\allqueries.txt) {Remove-Item $WorkingSubFolder\allqueries.txt}
Write-Host "Joining discrete NAV object files…"
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\TAB*.txt -Destination $WorkingSubFolder\alltables.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\REP*.txt -Destination $WorkingSubFolder\allreports.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\COD*.txt -Destination $WorkingSubFolder\allcodeunits.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\XML*.txt -Destination $WorkingSubFolder\allxmlports.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\MEN*.txt -Destination $WorkingSubFolder\allmenusuites.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\PAG*.txt -Destination $WorkingSubFolder\allpages.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\QUE*.txt -Destination $WorkingSubFolder\allqueries.txt
Write-Host "Concatenating object files…"
IF (Test-Path $WorkingSubFolder\alltables.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\alltables.txt)}
IF (Test-Path $WorkingSubFolder\allreports.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allreports.txt)}
IF (Test-Path $WorkingSubFolder\allcodeunits.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allcodeunits.txt)}
IF (Test-Path $WorkingSubFolder\allxmlports.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allxmlports.txt)}
IF (Test-Path $WorkingSubFolder\allmenusuites.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allmenusuites.txt)}
IF (Test-Path $WorkingSubFolder\allpages.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allpages.txt)}
IF (Test-Path $WorkingSubFolder\allqueries.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allqueries.txt)}
IF (Test-Path $WorkingSubFolder\alltables.txt) {Remove-Item $WorkingSubFolder\alltables.txt}
IF (Test-Path $WorkingSubFolder\allreports.txt) {Remove-Item $WorkingSubFolder\allreports.txt}
IF (Test-Path $WorkingSubFolder\allcodeunits.txt) {Remove-Item $WorkingSubFolder\allcodeunits.txt}
IF (Test-Path $WorkingSubFolder\allxmlports.txt) {Remove-Item $WorkingSubFolder\allxmlports.txt}
IF (Test-Path $WorkingSubFolder\allmenusuites.txt) {Remove-Item $WorkingSubFolder\allmenusuites.txt}
IF (Test-Path $WorkingSubFolder\allpages.txt) {Remove-Item $WorkingSubFolder\allpages.txt}
IF (Test-Path $WorkingSubFolder\allqueries.txt) {Remove-Item $WorkingSubFolder\allqueries.txt}
Move-Item $WorkingSubFolder\AllObjects.txt $NewObjectPackFullName -Force
}
Set-NAVApplicationObjectProperty -Target $file.FullName -modifiedproperty Yes
Set-NAVApplicationObjectProperty -Target $file.FullName -modifiedproperty No
Function DeleteModifiedFlagForAllObjects
{
[CmdletBinding()]
Param
(
[String][Parameter(Mandatory=$True)]
$PathObjectPack
)
$argspath = resolve-path $PathObjectPack
$WorkingFolder = split-path $argspath -Parent
$ObjectPackFileBaseName = (Get-Item $PathObjectPack).Basename
$NewObjectPackFullName = (Get-Item $PathObjectPack).DirectoryName + '\' + (Get-Item $PathObjectPack).Basename + '_ModifiedFlagDeleted' + (Get-Item $PathObjectPack).Extension
New-Item -Path $WorkingFolder -type directory -Name TempNAVobjects -Force
$WorkingSubFolder = "$WorkingFolder\TempNAVobjects\"
remove-item $WorkingSubFolder\*.* -Recurse
Split-NAVApplicationObjectFile -Source $argspath -Destination $WorkingFolder\TempNAVobjects -PreserveFormatting -Force
foreach ($file in get-ChildItem -Path $WorkingSubFolder\ | Where {$_.extension -eq '.TXT'})
{
Set-NAVApplicationObjectProperty -Target $file.FullName -modifiedproperty No
}
Write-Host "Deleting old object files…"
IF (Test-Path $WorkingSubFolder\allobjects.txt) {Remove-Item $WorkingSubFolder\allobjects.txt}
IF (Test-Path $WorkingSubFolder\alltables.txt) {Remove-Item $WorkingSubFolder\alltables.txt}
IF (Test-Path $WorkingSubFolder\allreports.txt) {Remove-Item $WorkingSubFolder\allreports.txt}
IF (Test-Path $WorkingSubFolder\allcodeunits.txt) {Remove-Item $WorkingSubFolder\allcodeunits.txt}
IF (Test-Path $WorkingSubFolder\allxmlports.txt) {Remove-Item $WorkingSubFolder\allxmlports.txt}
IF (Test-Path $WorkingSubFolder\allmenusuites.txt) {Remove-Item $WorkingSubFolder\allmenusuites.txt}
IF (Test-Path $WorkingSubFolder\allpages.txt) {Remove-Item $WorkingSubFolder\allpages.txt}
IF (Test-Path $WorkingSubFolder\allqueries.txt) {Remove-Item $WorkingSubFolder\allqueries.txt}
Write-Host "Joining discrete NAV object files…"
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\TAB*.txt -Destination $WorkingSubFolder\alltables.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\REP*.txt -Destination $WorkingSubFolder\allreports.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\COD*.txt -Destination $WorkingSubFolder\allcodeunits.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\XML*.txt -Destination $WorkingSubFolder\allxmlports.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\MEN*.txt -Destination $WorkingSubFolder\allmenusuites.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\PAG*.txt -Destination $WorkingSubFolder\allpages.txt
Join-NAVApplicationObjectFile -Source $WorkingSubFolder\QUE*.txt -Destination $WorkingSubFolder\allqueries.txt
Write-Host "Concatenating object files…"
IF (Test-Path $WorkingSubFolder\alltables.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\alltables.txt)}
IF (Test-Path $WorkingSubFolder\allreports.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allreports.txt)}
IF (Test-Path $WorkingSubFolder\allcodeunits.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allcodeunits.txt)}
IF (Test-Path $WorkingSubFolder\allxmlports.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allxmlports.txt)}
IF (Test-Path $WorkingSubFolder\allmenusuites.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allmenusuites.txt)}
IF (Test-Path $WorkingSubFolder\allpages.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allpages.txt)}
IF (Test-Path $WorkingSubFolder\allqueries.txt) {Add-Content -path $WorkingSubFolder\AllObjects.txt -value(Get-Content $WorkingSubFolder\allqueries.txt)}
IF (Test-Path $WorkingSubFolder\alltables.txt) {Remove-Item $WorkingSubFolder\alltables.txt}
IF (Test-Path $WorkingSubFolder\allreports.txt) {Remove-Item $WorkingSubFolder\allreports.txt}
IF (Test-Path $WorkingSubFolder\allcodeunits.txt) {Remove-Item $WorkingSubFolder\allcodeunits.txt}
IF (Test-Path $WorkingSubFolder\allxmlports.txt) {Remove-Item $WorkingSubFolder\allxmlports.txt}
IF (Test-Path $WorkingSubFolder\allmenusuites.txt) {Remove-Item $WorkingSubFolder\allmenusuites.txt}
IF (Test-Path $WorkingSubFolder\allpages.txt) {Remove-Item $WorkingSubFolder\allpages.txt}
IF (Test-Path $WorkingSubFolder\allqueries.txt) {Remove-Item $WorkingSubFolder\allqueries.txt}
Move-Item $WorkingSubFolder\AllObjects.txt $NewObjectPackFullName -Force
}