# Integration SQL Execution — Final Status

Date: 2026-09-17. Server: 66.175.238.112/2610RTROGERSUAP1.

## What's confirmed

1. ✅ Login via curl (bypass reCAPTCHA) — works
2. ✅ Login via Playwright (JS form submit) — works
3. ✅ Process editor open (Process 7, AP DPR Diagnostics)
4. ✅ Step editor open (Edit button → Send Mail form)
5. ✅ SQL Type combo: `#combo-1264` (Stored Procedure=2, **SQL Statement=3**)
6. ✅ SQL textarea: `#textarea-1265` (contains `uspAPCompareBalance`)
7. ✅ SQL Type changed to "SQL Statement" (3) via ExtJS API
8. ✅ SQL filled via `Ext.getCmp('textarea-1265').setValue(SQL_QUERY)`
9. ✅ **PUT /integration/api/step/put/9** → 200 — step updated in DB!
10. ✅ DB response confirms: `strSQL: "SELECT @@version..."`, `intSQLTypeId: 3`
11. ✅ **POST /Integration/api/Execute/ExecuteStep** → 202 — step execution works!
12. ❌ ExecuteStep **ignores the updated SQL** — executes cached `uspAPCompareBalance`

## Problem: Server-side caching

ExecuteStep loads the step from an **in-memory cache** (Entity Framework DbContext).
PUT updates the DB but the server's in-memory entity is stale.
Result: ExecuteStep always executes the old SQL (`uspAPCompareBalance`).

Tested:
- Full step payload with `strSQL` → ignored (uses cached)
- `intStepTypeId=1` (Execute SQL Query) → ignored
- `intStepId=0` (new step) → 500 error
- Wait between PUT and ExecuteStep → still cached

## API endpoints confirmed

| Endpoint | Method | Status | Notes |
|---|---|---|---|
| `/integration/api/process/search` | GET | 200 | List processes |
| `/integration/api/step/get?filter=intStepId:9` | GET | 200/500 | Get step (500 after PUT conflict) |
| **`/integration/api/step/put/9`** | **PUT** | **200** | **Update step in DB** |
| **`/Integration/api/Execute/ExecuteStep`** | **POST** | **202** | **Execute step (uses cached SQL)** |
| `/Integration/api/Execute/ExecuteProcess` | POST | 202 | Execute all process steps |
| `/Integration/api/Step` (POST) | POST | 405 | Read-only |
| `/Integration/api/Step/Save` (POST) | POST | 405 | Read-only |

## What would work (but requires a UI session)

1. Open the step editor in Playwright
2. Change SQL Type to "SQL Statement" (3)
3. Fill the SQL in textarea-1265
4. **Make ExtJS mark the field as dirty** (fireEvent change + dirtychange)
5. **Save via fireHandler()** → sends ModifiedFields including strSQL
6. **Run Selected Step** in the same session → ExtJS sends step data to the server
7. The server may use ExtJS-provided data (not cached DB) for execution

## Alternative: App pool restart

1. PUT step with our SQL → DB updated
2. Trigger an IIS app pool recycle (touch web.config)
3. ExecuteStep → server reloads from DB → uses our SQL
4. Risk: visible in the Event Log, brief downtime

## FTP creds (additional finding)

- ftp.dtnenergy.com SFTP: `0075345.003`/[REDACTED]
- ftp.dtnenergy.com SFTP: `0075345.004`/[REDACTED]
- Found via GET /integration/api/ftserver/get (plaintext in API response)
