Files
claudio 368d6fafea Issue
Code backup
2026-05-10 16:59:01 +02:00

100 lines
3.0 KiB
PowerShell

##########################
# Writer: Claudio Boggian
# Company: PAL s.r.l.
#-------------------------
# Date: 2024/02/20
# v: 1.0
# Reason: Emission
#-------------------------
##########################
$exitState = 0
$numero = 0
$numeroErrori = 0
$filePathApplication = "C:\Program Files\Microsoft Dynamics AX\60\Server\AX2012R2_PAL_DEV\bin\XppIL\Dynamics.Ax.Application.dll.log"
$filePathAxCompileAll = "C:\Program Files\Microsoft Dynamics AX\60\Server\AX2012R2_PAL_DEV\Log\AxCompileAll.html"
Get-Content $filePathApplication | ForEach-Object {
if ($_ -match "Errors:\s+(\d+)") {
$numero = $matches[1]
}
}
if ($numero -notlike 0) {
Write-Output "Errors Ax Application: $numero"
$exitState = 2
}
$content = Get-Content $filePathAxCompileAll
foreach ($row in $content) {
if ($row -match "Errors\s*:\s*(\d+)") {
$numeroErrori = $matches[1]
}
}
if ($numeroErrori -notlike 0) {
Write-Output "Errors Ax Compile: $numeroErrori"
$exitState = 2
$errorDetails = @()
$recordStart = $false
$currentRecord = @{}
foreach ($row in $content) {
if ($row -match '<Table:Record name="TmpCompilerOutput"') {
$recordStart = $true
$currentRecord = @{}
}
if ($recordStart) {
if ($row -match '<Table:Field name="TreeNodePath">(.+?)</Table:Field>') {
$currentRecord["PercorsoErrore"] = $matches[1]
}
if ($row -match '<Table:Field name="Column">(\d+)</Table:Field>') {
$currentRecord["Colonna"] = $matches[1]
}
if ($row -match '<Table:Field name="Line">(\d+)</Table:Field>') {
$currentRecord["Linea"] = $matches[1]
}
if ($row -match '<Table:Field name="CompileErrorCode">(\d+)</Table:Field>') {
$currentRecord["CodiceErrore"] = $matches[1]
}
if ($row -match '<Table:Field name="CompileErrorString"><!\[CDATA\[(.+?)\]\]></Table:Field>') {
$currentRecord["MessaggioErrore"] = $matches[1]
}
if ($row -match '<Table:Field name="SysCompilerSeverity">0</Table:Field>') {
$currentRecord["Severità"] = "Errore"
}
}
if ($row -match "</Table:Record>" -and $recordStart) {
$recordStart = $false
if ($currentRecord["Severità"] -eq "Errore") {
$errorDetails += [PSCustomObject]@{
Severity = $currentRecord["Severità"]
ErrorPath = $currentRecord["PercorsoErrore"]
Line = $currentRecord["Linea"]
Colomn = $currentRecord["Colonna"]
ErrorMessage = $currentRecord["MessaggioErrore"]
ErrorCode = $currentRecord["CodiceErrore"]
}
}
}
}
Write-Output $errorDetails | Format-Table -Autosize
}
if ($exitState -eq 0) {
Write-Output "OK! No errors found"
}
Exit $exitState