- ednclogs uses machineid FK instead of hostname - installedapps tracks installations (no separate edncstats table) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
136 lines
4.6 KiB
Markdown
136 lines
4.6 KiB
Markdown
# eDNC Special Character Fix - Claude Code Instructions
|
|
|
|
## Project Overview
|
|
|
|
PowerShell utility that monitors DNC folders and removes invalid special characters (0xFF) from .pun files in real-time. Deployed to CNC workstations via network share.
|
|
|
|
## Technology Stack
|
|
|
|
- **Language:** PowerShell 5.1+
|
|
- **Deployment:** Network share (S:\DT\cameron\eDNC-Fix\) → Local (C:\eDNC-Fix\)
|
|
- **Logging:** ShopDB API (http://geitshopdb/api.asp)
|
|
- **Version Control:** Gitea (localhost:3000/cproudlock/edncfix)
|
|
|
|
## IMPORTANT: After Making Changes
|
|
|
|
**Always do the following after any code changes:**
|
|
|
|
1. **Update version numbers** in ALL of these files:
|
|
- `eDNC-SpecialCharFix.ps1` - `$ScriptVersion` variable (line ~81)
|
|
- `eDNC-SpecialCharFix.ps1` - `.NOTES` section Version field
|
|
- `version.ini` - `Version=x.x.x`
|
|
- `README.md` - Version History table
|
|
|
|
2. **Commit and push to Gitea:**
|
|
```bash
|
|
cd /home/camp/projects/powershell/edncfix
|
|
git add -A
|
|
git commit -m "vX.X.X: Description of changes"
|
|
git push
|
|
```
|
|
|
|
3. **Version format:** Use semantic versioning (MAJOR.MINOR.PATCH)
|
|
- MAJOR: Breaking changes
|
|
- MINOR: New features
|
|
- PATCH: Bug fixes
|
|
|
|
## File Structure
|
|
|
|
```
|
|
/home/camp/projects/powershell/edncfix/
|
|
├── eDNC-SpecialCharFix.ps1 # Main script
|
|
├── Run-eDNCFix.bat # Manual launcher (auto-elevates)
|
|
├── Install-ScheduledTask.ps1 # Creates Windows scheduled task
|
|
├── Deploy.bat # Copies from S: to C:\eDNC-Fix\
|
|
├── version.ini # Version file for auto-updates
|
|
├── README.md # Documentation
|
|
└── CLAUDE.md # This file
|
|
```
|
|
|
|
## Configuration (Hardcoded)
|
|
|
|
| Setting | Value | Location |
|
|
|---------|-------|----------|
|
|
| Watch Folder | `C:\Dnc_Files\Q` | eDNC-SpecialCharFix.ps1 |
|
|
| File Filter | `*.pun` | eDNC-SpecialCharFix.ps1 |
|
|
| Update Source | `S:\DT\cameron\eDNC-Fix` | eDNC-SpecialCharFix.ps1 |
|
|
| API URL | `http://geitshopdb/api.asp` | eDNC-SpecialCharFix.ps1 |
|
|
| Update Interval | 300 seconds (5 min) | eDNC-SpecialCharFix.ps1 |
|
|
|
|
## ShopDB API Integration
|
|
|
|
The script logs events to ShopDB via the API. Reference the ShopDB API documentation at:
|
|
- **ShopDB Project:** `/home/camp/projects/windows/shopdb/`
|
|
- **API File:** `/home/camp/projects/windows/shopdb/api.asp`
|
|
- **Standards Doc:** `/home/camp/projects/windows/shopdb/docs/STANDARDS.md`
|
|
|
|
### API Endpoint: logDNCEvent
|
|
|
|
**Method:** POST
|
|
**URL:** `http://geitshopdb/api.asp`
|
|
|
|
**Parameters:**
|
|
| Parameter | Type | Required | Description |
|
|
|-----------|------|----------|-------------|
|
|
| action | string | Yes | Must be "logDNCEvent" |
|
|
| hostname | string | Yes | PC hostname |
|
|
| eventType | string | Yes | Event type: started, cleaned, ok, failed, error, stopped |
|
|
| filename | string | No | File being processed |
|
|
| bytesRemoved | int | No | Number of bytes removed |
|
|
| version | string | No | Script version |
|
|
| message | string | No | Additional details |
|
|
| watchFolder | string | No | Folder being watched |
|
|
| fileFilter | string | No | File filter pattern |
|
|
|
|
**Database Tables:**
|
|
- `ednclogs` - Event log entries (uses machineid FK to machines table)
|
|
- `installedapps` - Tracks installations (appid=79 for eDNC)
|
|
|
|
### API Endpoint: getDNCStats
|
|
|
|
**Method:** GET
|
|
**URL:** `http://geitshopdb/api.asp?action=getDNCStats`
|
|
|
|
Returns JSON with all eDNC installations and their stats.
|
|
|
|
## Deployment Workflow
|
|
|
|
1. **Development:** Edit files in `/home/camp/projects/powershell/edncfix/`
|
|
2. **Update versions:** Bump all version numbers
|
|
3. **Commit:** Push to Gitea
|
|
4. **Stage:** Copy files to `S:\DT\cameron\eDNC-Fix\`
|
|
5. **Deploy:** On target PC, run `Deploy.bat` from S: drive
|
|
6. **Install:** Run `Install-ScheduledTask.ps1` as Admin
|
|
|
|
## Auto-Update Mechanism
|
|
|
|
Running instances check `S:\DT\cameron\eDNC-Fix\version.ini` every 5 minutes.
|
|
If a newer version is found, they automatically:
|
|
1. Copy new files from S: to C:\eDNC-Fix\
|
|
2. Restart themselves
|
|
|
|
**To deploy an update to all PCs:**
|
|
1. Update version.ini with new version number
|
|
2. Copy updated files to S:\DT\cameron\eDNC-Fix\
|
|
3. Wait up to 5 minutes for auto-update
|
|
|
|
## Quick Reference
|
|
|
|
### Test API endpoint:
|
|
```bash
|
|
curl -X POST http://192.168.122.151:8080/api.asp \
|
|
-d "action=logDNCEvent&hostname=TESTPC&eventType=started&version=1.5.0"
|
|
```
|
|
|
|
### Check installations:
|
|
```bash
|
|
curl "http://192.168.122.151:8080/api.asp?action=getDNCStats"
|
|
```
|
|
|
|
### View logs in database:
|
|
```sql
|
|
SELECT l.*, m.hostname FROM ednclogs l
|
|
JOIN machines m ON l.machineid = m.machineid
|
|
ORDER BY l.created DESC LIMIT 20;
|
|
```
|