Files
claudetools/clients/dataforth/scripts/check-new-records.ps1
Mike Swanson 5cbd49ce24 Reorganize repo: compartmentalize scripts by client/project
Move 150+ scripts from root and scripts/ into client/project directories:
- clients/dataforth/scripts/ (110 files: AD2, sync, SSH, DB, DOS scripts)
- clients/bg-builders/scripts/ (14 files: Lesley mgmt, Exchange, termination)
- clients/internal-infrastructure/scripts/ (10 files: GDAP, Gitea, backups)
- projects/msp-tools/scripts/ (9 files: CIPP, MSP onboarding, Datto)
- projects/gururmm-agent/scripts/ (3 files: API test, JWT, record counts)
- clients/glaztech/scripts/ (1 file: CentraStage removal)

Also reorganized:
- VPN scripts → infrastructure/vpn-configs/
- Retrieved API/JS files → api/
- Forum posts → projects/community-forum/forum-posts/
- SSH docs → clients/internal-infrastructure/docs/
- NWTOC/CTONW docs → projects/wrightstown-smarthome/docs/
- ACG website files → projects/internal/acg-website-2025/
- Dataforth docs → clients/dataforth/docs/
- schema-retrieved.sql → docs/database/

Deleted 24 tmp_*.ps1 one-off debug scripts (preserved in git history).
Root reduced from 220+ files to 62 items (docs + directories only).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 17:15:07 -07:00

90 lines
3.8 KiB
PowerShell

# Check for new test data files that need importing
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Test Data Import Status Check" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
Write-Host "[1/4] Mounting AD2 C$ share..." -ForegroundColor Green
New-PSDrive -Name AD2 -PSProvider FileSystem -Root "\\192.168.0.6\C$" -Credential $cred -ErrorAction Stop | Out-Null
# Check database last modified time
Write-Host "`n[2/4] Checking database status..." -ForegroundColor Green
$dbFile = Get-Item "AD2:\Shares\testdatadb\database\testdata.db"
Write-Host " Database last modified: $($dbFile.LastWriteTime)" -ForegroundColor Cyan
Write-Host " Database size: $([math]::Round($dbFile.Length/1MB,2)) MB" -ForegroundColor Cyan
# Check for new DAT files in test folders
Write-Host "`n[3/4] Checking for new test data files..." -ForegroundColor Green
$logTypes = @("8BLOG", "DSCLOG", "7BLOG", "5BLOG", "PWRLOG", "VASLOG", "SCTLOG", "HVLOG", "RMSLOG")
$testStations = @("TS-1L", "TS-3R", "TS-4L", "TS-4R", "TS-8R", "TS-10L", "TS-11L")
$newFiles = @()
$cutoffTime = $dbFile.LastWriteTime
foreach ($station in $testStations) {
foreach ($logType in $logTypes) {
$path = "AD2:\Shares\test\$station\LOGS\$logType"
if (Test-Path $path) {
$files = Get-ChildItem $path -Filter "*.DAT" -ErrorAction SilentlyContinue |
Where-Object { $_.LastWriteTime -gt $cutoffTime }
if ($files) {
foreach ($file in $files) {
$newFiles += [PSCustomObject]@{
Station = $station
LogType = $logType
FileName = $file.Name
Size = [math]::Round($file.Length/1KB, 2)
Modified = $file.LastWriteTime
Path = $file.FullName
}
}
}
}
}
}
if ($newFiles.Count -gt 0) {
Write-Host " [FOUND] $($newFiles.Count) new files since last import:" -ForegroundColor Yellow
$newFiles | Format-Table Station, LogType, FileName, @{Name='Size(KB)';Expression={$_.Size}}, Modified -AutoSize | Out-String | Write-Host
} else {
Write-Host " [OK] No new files found - database is up to date" -ForegroundColor Green
}
# Check sync script log
Write-Host "`n[4/4] Checking sync log..." -ForegroundColor Green
$syncLog = "AD2:\Shares\test\scripts\sync-from-nas.log"
if (Test-Path $syncLog) {
Write-Host " [OK] Sync log exists" -ForegroundColor Green
$logFile = Get-Item $syncLog
Write-Host " Last modified: $($logFile.LastWriteTime)" -ForegroundColor Cyan
Write-Host " Last 10 log entries:" -ForegroundColor Cyan
$lastLines = Get-Content $syncLog -Tail 10
$lastLines | ForEach-Object { Write-Host " $_" -ForegroundColor Gray }
} else {
Write-Host " [WARNING] Sync log not found at: $syncLog" -ForegroundColor Yellow
}
Remove-PSDrive -Name AD2 -ErrorAction SilentlyContinue
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host "Summary" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
if ($newFiles.Count -gt 0) {
Write-Host "[ACTION REQUIRED] Import new files:" -ForegroundColor Yellow
Write-Host " cd C:\Shares\testdatadb" -ForegroundColor Cyan
Write-Host " node database\import.js" -ForegroundColor Cyan
Write-Host "`n Or wait for automatic import (runs every 15 minutes)" -ForegroundColor Gray
} else {
Write-Host "[OK] Database is current - no import needed" -ForegroundColor Green
}
Write-Host "========================================`n" -ForegroundColor Cyan