eDNC: Use machineid instead of hostname for proper FK relationship
- ednclogs table now uses machineid to link to machines table - Removed redundant hostname storage (derive from machines table) - Updated LogDNCEvent to look up and insert machineid - Updated GetDNCStats to join machines table for hostname - Updated displaypc.asp queries to use machineid directly - sql/ednc_tables.sql is now a migration script for existing production 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -737,20 +737,22 @@ End If
|
||||
<!-- eDNC Special Character Fix Stats -->
|
||||
<%
|
||||
'=============================================================================
|
||||
' eDNC-Fix Installation Stats for this PC
|
||||
' eDNC-Fix Installation Stats for this PC (derived from ednclogs)
|
||||
'=============================================================================
|
||||
Dim edncSQL, rsEdnc, hasEdnc
|
||||
hasEdnc = False
|
||||
edncSQL = "SELECT i.version, i.watch_folder, i.file_filter, i.first_seen, i.last_seen, " & _
|
||||
"i.total_cleaned, i.total_failed, " & _
|
||||
"(SELECT COUNT(*) FROM ednc_logs l WHERE l.hostname = i.hostname AND l.created > DATE_SUB(NOW(), INTERVAL 24 HOUR)) AS events_24h, " & _
|
||||
"(SELECT MAX(created) FROM ednc_logs l WHERE l.hostname = i.hostname AND l.action = 'cleaned') AS last_cleaned " & _
|
||||
"FROM ednc_installations i " & _
|
||||
"INNER JOIN machines m ON UPPER(i.hostname) = UPPER(m.hostname) " & _
|
||||
"WHERE m.machineid = ?"
|
||||
Set rsEdnc = ExecuteParameterizedQuery(objConn, edncSQL, Array(machineid))
|
||||
If Not rsEdnc.EOF Then
|
||||
hasEdnc = True
|
||||
|
||||
edncSQL = "SELECT " & _
|
||||
"(SELECT version FROM ednclogs WHERE machineid = ? ORDER BY created DESC LIMIT 1) AS version, " & _
|
||||
"(SELECT MIN(created) FROM ednclogs WHERE machineid = ?) AS first_seen, " & _
|
||||
"(SELECT MAX(created) FROM ednclogs WHERE machineid = ?) AS last_seen, " & _
|
||||
"(SELECT COUNT(*) FROM ednclogs WHERE machineid = ? AND action = 'cleaned') AS total_cleaned, " & _
|
||||
"(SELECT COUNT(*) FROM ednclogs WHERE machineid = ? AND action IN ('failed', 'error')) AS total_failed, " & _
|
||||
"(SELECT COUNT(*) FROM ednclogs WHERE machineid = ? AND created > DATE_SUB(NOW(), INTERVAL 24 HOUR)) AS events_24h, " & _
|
||||
"(SELECT MAX(created) FROM ednclogs WHERE machineid = ? AND action = 'cleaned') AS last_cleaned"
|
||||
Set rsEdnc = ExecuteParameterizedQuery(objConn, edncSQL, Array(machineid, machineid, machineid, machineid, machineid, machineid, machineid))
|
||||
If Not rsEdnc.EOF And Not IsNull(rsEdnc("first_seen")) Then
|
||||
hasEdnc = True
|
||||
%>
|
||||
<h6 class="mt-4 mb-3"><i class="zmdi zmdi-settings"></i> eDNC Special Character Fix</h6>
|
||||
<div class="table-responsive">
|
||||
@@ -760,14 +762,6 @@ End If
|
||||
<td class="font-weight-bold" width="35%">Version</td>
|
||||
<td><%= Server.HTMLEncode(rsEdnc("version") & "") %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-weight-bold">Watch Folder</td>
|
||||
<td><code><%= Server.HTMLEncode(rsEdnc("watch_folder") & "") %></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-weight-bold">File Filter</td>
|
||||
<td><code><%= Server.HTMLEncode(rsEdnc("file_filter") & "") %></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-weight-bold">First Seen</td>
|
||||
<td><%= rsEdnc("first_seen") %></td>
|
||||
@@ -777,19 +771,19 @@ End If
|
||||
<td><%= rsEdnc("last_seen") %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-weight-bold">Files Cleaned (Total)</td>
|
||||
<td class="font-weight-bold">Files Cleaned</td>
|
||||
<td><span class="badge badge-success"><%= rsEdnc("total_cleaned") %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-weight-bold">Files Failed (Total)</td>
|
||||
<td class="font-weight-bold">Files Failed</td>
|
||||
<td><span class="badge badge-<%= IIf(CLng(rsEdnc("total_failed") & "0") > 0, "danger", "secondary") %>"><%= rsEdnc("total_failed") %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-weight-bold">Events (Last 24h)</td>
|
||||
<td class="font-weight-bold">Events (24h)</td>
|
||||
<td><%= rsEdnc("events_24h") %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-weight-bold">Last File Cleaned</td>
|
||||
<td class="font-weight-bold">Last Cleaned</td>
|
||||
<td><%= rsEdnc("last_cleaned") & "" %></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -798,10 +792,10 @@ End If
|
||||
<%
|
||||
' Show recent log entries
|
||||
Dim logSQL, rsLog
|
||||
logSQL = "SELECT filename, action, bytes_removed, created FROM ednc_logs " & _
|
||||
"WHERE UPPER(hostname) = UPPER(?) AND action IN ('cleaned', 'ok', 'failed', 'error') " & _
|
||||
logSQL = "SELECT filename, action, bytes_removed, created FROM ednclogs " & _
|
||||
"WHERE machineid = ? AND action IN ('cleaned', 'ok', 'failed', 'error') " & _
|
||||
"ORDER BY created DESC LIMIT 10"
|
||||
Set rsLog = ExecuteParameterizedQuery(objConn, logSQL, Array(rsEdnc("hostname") & ""))
|
||||
Set rsLog = ExecuteParameterizedQuery(objConn, logSQL, Array(machineid))
|
||||
%>
|
||||
<h6 class="mt-4 mb-2">Recent Activity</h6>
|
||||
<div class="table-responsive" style="max-height: 300px; overflow-y: auto;">
|
||||
@@ -851,9 +845,10 @@ End If
|
||||
</table>
|
||||
</div>
|
||||
<%
|
||||
End If
|
||||
rsEdnc.Close
|
||||
Set rsEdnc = Nothing
|
||||
End If
|
||||
rsEdnc.Close
|
||||
Set rsEdnc = Nothing
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user