Consolidate PC machinetypeid: all PCs use 33, pctypeid determines type
- Simplified GetMachineTypeIdFromPCType() to always return 33 (PC) - PC type differentiation now handled entirely by pctypeid - Updated savedevice.asp: 28 -> 33 - Updated savedevice_direct.asp: 36 -> 33, added pctypeid - Removed redundant machinetypeid mapping logic (36-43) - All 317 existing PCs already use machinetypeid=33 Schema simplified: machinetypeid=33 (PC) + pctypeid determines specific type pctypeid: 1=Standard, 2=Engineer, 3=Shopfloor, 5=CMM, etc. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
53
api.asp
53
api.asp
@@ -833,20 +833,19 @@ Function InsertOrUpdatePC(conn, hostname, serialnumber, manufacturer, model, pcT
|
||||
Dim pctypeId
|
||||
pctypeId = GetPCTypeIdFromPCType(pcType)
|
||||
|
||||
' Override types based on machinenumber pattern
|
||||
' WJPRT* = Wax Trace PC (machinetypeid 42, pctypeid 6)
|
||||
' Override pctypeid based on machinenumber pattern
|
||||
' WJPRT* = Wax Trace PC (pctypeid 6)
|
||||
If machinenumber <> "" Then
|
||||
If UCase(Left(machinenumber, 5)) = "WJPRT" Then
|
||||
machineTypeId = 42 ' PC - Wax Trace
|
||||
pctypeId = 6 ' Wax / Trace
|
||||
LogToFile "Detected WJPRT pattern in machinenumber, setting machineTypeId to 42, pctypeid to 6"
|
||||
LogToFile "Detected WJPRT pattern in machinenumber, setting pctypeid to 6 (Wax/Trace)"
|
||||
End If
|
||||
End If
|
||||
|
||||
' Ensure all IDs are numeric (fallback to safe defaults if empty)
|
||||
If Not IsNumeric(vendorId) Or vendorId = "" Then vendorId = 0
|
||||
If Not IsNumeric(modelId) Or modelId = "" Then modelId = 1 ' TBD model
|
||||
If Not IsNumeric(machineTypeId) Or machineTypeId = "" Then machineTypeId = 36 ' PC - Standard
|
||||
If Not IsNumeric(machineTypeId) Or machineTypeId = "" Then machineTypeId = 33 ' PC
|
||||
If Not IsNumeric(pctypeId) Or pctypeId = "" Then pctypeId = 1 ' Standard
|
||||
|
||||
LogToFile "Vendor ID: " & vendorId & ", Model ID: " & modelId & ", Machine Type ID: " & machineTypeId & ", PC Type ID: " & pctypeId
|
||||
@@ -1627,8 +1626,9 @@ End Function
|
||||
|
||||
' ============================================================================
|
||||
' LEGACY FUNCTION REMOVED: GetOrCreatePCType
|
||||
' This function was replaced by GetMachineTypeIdFromPCType which maps
|
||||
' PC type strings directly to machinetypeid (33=Standard, 34=Engineer, 35=Shopfloor)
|
||||
' All PCs now use machinetypeid=33, with pctypeid determining the specific type
|
||||
' GetMachineTypeIdFromPCType returns 33 for all PCs
|
||||
' GetPCTypeIdFromPCType maps pcType string to pctypeid (1=Standard, 2=Engineer, etc.)
|
||||
' Removed: 2025-11-17 during Phase 2 migration from pc/pctype to machines/machinetypes
|
||||
' ============================================================================
|
||||
|
||||
@@ -1853,41 +1853,10 @@ Function GetOrCreateAppVersion(conn, appId, appVersion)
|
||||
End Function
|
||||
|
||||
Function GetMachineTypeIdFromPCType(pcTypeString)
|
||||
On Error Resume Next
|
||||
|
||||
' Direct mapping from pcType parameter to machinetypeid (Phase 2 schema)
|
||||
' Phase 2 PC Machine Types:
|
||||
' 36=PC - Standard, 37=PC - Shopfloor, 38=PC - Engineer
|
||||
' 41=PC - CMM, 42=PC - Wax Trace, 43=PC - Measuring Tool
|
||||
|
||||
Dim pcTypeClean
|
||||
pcTypeClean = Trim(UCase(pcTypeString))
|
||||
|
||||
Select Case pcTypeClean
|
||||
Case "ENGINEER", "ENGINEERING"
|
||||
GetMachineTypeIdFromPCType = 38 ' PC - Engineer
|
||||
Case "SHOPFLOOR", "SHOP FLOOR"
|
||||
GetMachineTypeIdFromPCType = 37 ' PC - Shopfloor
|
||||
Case "CMM"
|
||||
GetMachineTypeIdFromPCType = 41 ' PC - CMM (runs PC-DMIS, goCMM, DODA)
|
||||
Case "WAX TRACE", "WAXTRACE", "WAX"
|
||||
GetMachineTypeIdFromPCType = 42 ' PC - Wax Trace (runs Formtracepak, FormStatusMonitor)
|
||||
Case "KEYENCE"
|
||||
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool - Keyence (runs Keyence VR Series)
|
||||
Case "EAS1000", "GENSPECT"
|
||||
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool - EAS1000/Genspect (runs GageCal, NI Software)
|
||||
Case "PART MARKER", "PARTMARKER"
|
||||
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool - Part Marker (0615 machines)
|
||||
Case "MEASURING", "MEASURING TOOL"
|
||||
GetMachineTypeIdFromPCType = 43 ' PC - Measuring Tool (generic)
|
||||
Case "STANDARD", ""
|
||||
GetMachineTypeIdFromPCType = 36 ' PC - Standard
|
||||
Case Else
|
||||
LogToFile "Unknown pcType '" & pcTypeString & "', defaulting to PC - Standard (36)"
|
||||
GetMachineTypeIdFromPCType = 36 ' Default to PC - Standard
|
||||
End Select
|
||||
|
||||
LogToFile "Mapped pcType '" & pcTypeString & "' to machinetypeid: " & GetMachineTypeIdFromPCType
|
||||
' All PCs use machinetypeid = 33 (PC)
|
||||
' The specific PC type is determined by pctypeid, not machinetypeid
|
||||
GetMachineTypeIdFromPCType = 33
|
||||
LogToFile "All PCs use machinetypeid 33, pcType '" & pcTypeString & "' -> pctypeid handles type"
|
||||
End Function
|
||||
|
||||
Function GetPCTypeIdFromPCType(pcTypeString)
|
||||
|
||||
@@ -42,11 +42,10 @@
|
||||
' modelnumberid = 1 (default model)
|
||||
' requires_manual_machine_config = 0 (no manual config needed)
|
||||
' osid = 1 (default OS)
|
||||
' machinetypeid = 28 (PC - Standard default)
|
||||
' pctypeid = 1 (Standard PC type)
|
||||
' machinetypeid = 33 (PC), pctypeid = 1 (Standard)
|
||||
Dim insertSQL, recordsAffected
|
||||
insertSQL = "INSERT INTO machines (serialnumber, machinestatusid, isactive, modelnumberid, requires_manual_machine_config, osid, machinetypeid, pctypeid, lastupdated) " & _
|
||||
"VALUES (?, 2, 1, 1, 0, 1, 28, 1, NOW())"
|
||||
"VALUES (?, 2, 1, 1, 0, 1, 33, 1, NOW())"
|
||||
|
||||
recordsAffected = ExecuteParameterizedInsert(objConn, insertSQL, Array(serialnumber))
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
' FILE: savedevice_direct.asp
|
||||
' PURPOSE: Create new PC with minimal required fields (PC-only scanner)
|
||||
' SECURITY: Parameterized queries, HTML encoding, input validation
|
||||
' UPDATED: 2025-12-04 - Changed to PC-only (machinetypeid 36 = PC - Standard)
|
||||
' UPDATED: 2025-12-09 - All PCs use machinetypeid 33, pctypeid determines type
|
||||
'=============================================================================
|
||||
%>
|
||||
<!--#include file="./includes/sql.asp"-->
|
||||
@@ -55,15 +55,15 @@
|
||||
Set cmdCheck = Nothing
|
||||
|
||||
' Insert new PC with minimal required fields - PHASE 2: Use machines table
|
||||
' machinetypeid = 36 (PC - Standard)
|
||||
' machinetypeid = 33 (PC), pctypeid = 1 (Standard)
|
||||
' machinestatusid = 2 (Inventory)
|
||||
' modelnumberid = 1 (default model)
|
||||
' maptop = 1519, mapleft = 1896 (default map location)
|
||||
' hostname = serialnumber (default)
|
||||
' isactive = 1
|
||||
Dim insertSQL, cmdInsert
|
||||
insertSQL = "INSERT INTO machines (serialnumber, hostname, machinetypeid, machinestatusid, modelnumberid, maptop, mapleft, isactive, lastupdated) " & _
|
||||
"VALUES (?, ?, 36, 2, 1, 1519, 1896, 1, NOW())"
|
||||
insertSQL = "INSERT INTO machines (serialnumber, hostname, machinetypeid, pctypeid, machinestatusid, modelnumberid, maptop, mapleft, isactive, lastupdated) " & _
|
||||
"VALUES (?, ?, 33, 1, 2, 1, 1519, 1896, 1, NOW())"
|
||||
Set cmdInsert = Server.CreateObject("ADODB.Command")
|
||||
cmdInsert.ActiveConnection = objConn
|
||||
cmdInsert.CommandText = insertSQL
|
||||
|
||||
Reference in New Issue
Block a user