Files
inquiry_robot/deploy/_remote_verify_preview_dl.ps1
T

45 lines
2.0 KiB
PowerShell

$ErrorActionPreference = 'Continue'
Start-Sleep -Seconds 5
$bodyPath = Join-Path $env:TEMP 'login-body.json'
Set-Content $bodyPath '{"username":"admin","password":"123456","captcha":"","checkKey":""}' -Encoding ASCII
try {
$login = Invoke-RestMethod -Uri 'http://127.0.0.1:8180/jeecgboot/sys/login' -Method POST -InFile $bodyPath -ContentType 'application/json;charset=UTF-8'
Write-Host ("login=" + $login.success + " code=" + $login.code)
} catch {
Write-Host ("login_fail=" + $_.Exception.Message)
exit 1
}
$h = @{ 'X-Access-Token' = $login.result.token }
try {
$list = Invoke-RestMethod -Uri 'http://127.0.0.1:8180/jeecgboot/inquiry/quoteTemplate/list?pageNo=1&pageSize=3' -Headers $h
Write-Host ("list_success=" + $list.success + " total=" + $list.result.total)
} catch {
Write-Host ("list_fail=" + $_.Exception.Message)
try {
$r = Invoke-WebRequest -Uri 'http://127.0.0.1:8180/jeecgboot/inquiry/quoteTemplate/list?pageNo=1&pageSize=3' -Headers $h -UseBasicParsing
Write-Host ("list_raw=" + $r.Content.Substring(0, [Math]::Min(300, $r.Content.Length)))
} catch {
Write-Host ("list_raw_fail=" + $_.Exception.Message)
}
}
$ok = 0; $fail = 0
$list2 = Invoke-RestMethod -Uri 'http://127.0.0.1:8180/jeecgboot/inquiry/quoteTemplate/list?pageNo=1&pageSize=20' -Headers $h -ErrorAction SilentlyContinue
foreach ($rec in @($list2.result.records)) {
if (-not $rec.versionId) { continue }
try {
$r = Invoke-WebRequest -Uri ("http://127.0.0.1:8180/jeecgboot/inquiry/quoteTemplate/previewSample?versionId=" + $rec.versionId) -Headers $h -UseBasicParsing -TimeoutSec 90
$ct = $r.Headers['Content-Type']
if ($ct -like '*sheet*' -or $r.RawContentLength -gt 2000) {
Write-Host ("OK " + $rec.versionId + " len=" + $r.RawContentLength)
$ok++
} else {
Write-Host ("BAD " + $rec.versionId + " ct=" + $ct)
$fail++
}
} catch {
Write-Host ("FAIL " + $rec.versionId + " " + $_.Exception.Message)
$fail++
}
}
Write-Host ("VERIFY_PREVIEW ok=" + $ok + " fail=" + $fail)