diff --git a/api.asp b/api.asp index be7ca55..354d9f0 100644 --- a/api.asp +++ b/api.asp @@ -61,6 +61,8 @@ Select Case action GetUDCManualTiming() Case "getDeployableApps" GetDeployableApps() + Case "getPCMachineRelationships" + GetPCMachineRelationships() Case Else SendError "Invalid action: " & action End Select @@ -943,6 +945,73 @@ Sub GetShopfloorPCs() Response.Write "{""success"":true,""count"":" & pcCount & ",""data"":[" & pcList & "]}" End Sub +Sub GetPCMachineRelationships() + ' Returns PCs that have relationships to machines (equipment) with machine numbers + ' Used for identifying which PCs control which shop floor machines + On Error Resume Next + + Dim rsRel, strSQL, relList, relCount, relData + + strSQL = "SELECT " & _ + "pc.machineid AS pc_id, " & _ + "pc.machinenumber AS hostname, " & _ + "c.address AS ip, " & _ + "eq.machineid AS machine_id, " & _ + "eq.machinenumber AS machine_number, " & _ + "v.vendor AS vendor, " & _ + "m.modelnumber AS model " & _ + "FROM machinerelationships mr " & _ + "JOIN machines eq ON mr.machineid = eq.machineid " & _ + "JOIN machines pc ON mr.related_machineid = pc.machineid " & _ + "LEFT JOIN communications c ON pc.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _ + "LEFT JOIN models m ON eq.modelnumberid = m.modelnumberid " & _ + "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ + "WHERE mr.isactive = 1 " & _ + "AND pc.pctypeid IS NOT NULL " & _ + "AND eq.machinenumber IS NOT NULL AND eq.machinenumber != '' " & _ + "AND eq.machinenumber REGEXP '^[0-9]{4}$' " & _ + "AND eq.machinenumber NOT IN ('0612', '0613', '0614', '0615') " & _ + "AND (v.vendor IS NULL OR v.vendor != 'WJDT') " & _ + "AND (m.modelnumber IS NULL OR m.modelnumber != 'TBD') " & _ + "ORDER BY eq.machinenumber" + + Set rsRel = objConn.Execute(strSQL) + + If Err.Number <> 0 Then + SendError "Database error: " & Err.Description + Exit Sub + End If + + ' Build JSON array + relList = "" + relCount = 0 + + Do While Not rsRel.EOF + If relList <> "" Then relList = relList & "," + + relData = "{" + relData = relData & """pc_id"":" & rsRel("pc_id") & "," + relData = relData & """hostname"":""" & EscapeJSON(rsRel("hostname") & "") & """," + relData = relData & """ip"":""" & EscapeJSON(rsRel("ip") & "") & """," + relData = relData & """machine_id"":" & rsRel("machine_id") & "," + relData = relData & """machine_number"":""" & EscapeJSON(rsRel("machine_number") & "") & """," + relData = relData & """vendor"":""" & EscapeJSON(rsRel("vendor") & "") & """," + relData = relData & """model"":""" & EscapeJSON(rsRel("model") & "") & """" + relData = relData & "}" + + relList = relList & relData + relCount = relCount + 1 + + rsRel.MoveNext + Loop + + rsRel.Close + Set rsRel = Nothing + + ' Send response + Response.Write "{""success"":true,""count"":" & relCount & ",""data"":[" & relList & "]}" +End Sub + Sub GetHighUptimePCs() ' Returns list of PCs with uptime >= specified days (for reboot management) On Error Resume Next diff --git a/apishopfloor.asp b/apishopfloor.asp index e31f3fd..99915f2 100644 --- a/apishopfloor.asp +++ b/apishopfloor.asp @@ -8,6 +8,13 @@ Response.AddHeader "Cache-Control", "no-cache, no-store, must-revalidate" Dim strSQL, jsonOutput, isFirstCurrent, isFirstUpcoming Dim businessUnitFilter +Dim st, et, isCurrent, isResolved, isUpcoming +Dim typeName, empSsoRaw, ssoArr, idx +Dim singleSSO, singleName, singlePicture +Dim empName, empPicture +Dim upTypeName, upEmpSsoRaw, upSsoArr, upIdx +Dim upSingleSSO, upSingleName, upSinglePicture +Dim upEmpName, upEmpPicture ' Get business unit filter from query string businessUnitFilter = Request.QueryString("businessunit") @@ -16,11 +23,12 @@ strSQL = "SELECT n.notificationid, n.notification, n.starttime, n.endtime, " & _ "n.ticketnumber, n.link, n.isactive, n.isshopfloor, n.businessunitid, " & _ "n.employeesso, nt.typename, nt.typecolor, bu.businessunit, " & _ "CASE " & _ - " WHEN n.starttime <= NOW() AND (n.endtime IS NULL OR n.endtime >= NOW()) THEN 1 " & _ + " WHEN n.starttime <= NOW() AND (n.endtime IS NULL OR n.endtime >= NOW()) AND n.isactive = 1 THEN 1 " & _ " WHEN n.endtime IS NOT NULL AND n.endtime < NOW() AND DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW() THEN 1 " & _ " ELSE 0 " & _ "END as is_current, " & _ "CASE " & _ + " WHEN n.isactive = 0 THEN 1 " & _ " WHEN n.endtime IS NOT NULL AND n.endtime < NOW() THEN 1 " & _ " ELSE 0 " & _ "END as is_resolved, " & _ @@ -32,10 +40,9 @@ strSQL = "SELECT n.notificationid, n.notification, n.starttime, n.endtime, " & _ "FROM notifications n " & _ "LEFT JOIN notificationtypes nt ON n.notificationtypeid = nt.notificationtypeid " & _ "LEFT JOIN businessunits bu ON n.businessunitid = bu.businessunitid " & _ - "WHERE n.isshopfloor = 1 AND (" & _ - " n.isactive = 1 OR " & _ - " (n.isactive = 0 AND n.endtime IS NOT NULL AND " & _ - " DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW())" & _ + "WHERE n.isshopfloor = 1 AND n.isactive = 1 AND (" & _ + " n.endtime IS NULL OR " & _ + " DATE_ADD(n.endtime, INTERVAL 30 MINUTE) >= NOW()" & _ ")" ' Add business unit filter @@ -51,11 +58,10 @@ strSQL = strSQL & " ORDER BY n.notificationid DESC" Set rs = objConn.Execute(strSQL) -jsonOutput = "{""success"":true,""timestamp"":""" & FormatDateTime(Now(), 2) & " " & FormatDateTime(Now(), 4) & """,""current"":[" +jsonOutput = "{""success"":true,""version"":""v2"",""timestamp"":""" & FormatDateTime(Now(), 2) & " " & FormatDateTime(Now(), 4) & """,""current"":[" isFirstCurrent = True Do While Not rs.EOF - Dim st, et, isCurrent, isResolved st = rs("starttime") et = rs("endtime") isCurrent = rs("is_current") @@ -63,17 +69,14 @@ Do While Not rs.EOF If isCurrent = 1 Then ' Check if this is a Recognition with multiple employees - Dim typeName, empSsoRaw typeName = rs("typename") & "" empSsoRaw = rs("employeesso") & "" If LCase(typeName) = "recognition" And Len(empSsoRaw) > 0 And InStr(empSsoRaw, ",") > 0 Then ' Split into individual cards for each employee - Dim ssoArr, idx ssoArr = Split(empSsoRaw, ",") For idx = 0 To UBound(ssoArr) - Dim singleSSO, singleName, singlePicture singleSSO = Trim(ssoArr(idx)) singleName = LookupSingleEmployeeName(singleSSO) singlePicture = LookupSingleEmployeePicture(singleSSO) @@ -128,7 +131,6 @@ Do While Not rs.EOF jsonOutput = jsonOutput & """typecolor"":""" & JSEscape(rs("typecolor") & "") & """," jsonOutput = jsonOutput & """businessunit"":" & StrOrNull(rs("businessunit")) & "," ' Handle employeesso - can be SSO or NAME:customname - Dim empName, empPicture If Left(empSsoRaw, 5) = "NAME:" Then ' Custom name - extract name, no picture empName = Mid(empSsoRaw, 6) @@ -156,24 +158,20 @@ jsonOutput = jsonOutput & "],""upcoming"":[" isFirstUpcoming = True Do While Not rs.EOF - Dim isUpcoming st = rs("starttime") et = rs("endtime") isUpcoming = rs("is_upcoming") If isUpcoming = 1 Then ' Check if this is a Recognition with multiple employees - Dim upTypeName, upEmpSsoRaw upTypeName = rs("typename") & "" upEmpSsoRaw = rs("employeesso") & "" If LCase(upTypeName) = "recognition" And Len(upEmpSsoRaw) > 0 And InStr(upEmpSsoRaw, ",") > 0 Then ' Split into individual cards for each employee - Dim upSsoArr, upIdx upSsoArr = Split(upEmpSsoRaw, ",") For upIdx = 0 To UBound(upSsoArr) - Dim upSingleSSO, upSingleName, upSinglePicture upSingleSSO = Trim(upSsoArr(upIdx)) upSingleName = LookupSingleEmployeeName(upSingleSSO) upSinglePicture = LookupSingleEmployeePicture(upSingleSSO) @@ -216,7 +214,6 @@ Do While Not rs.EOF jsonOutput = jsonOutput & """typecolor"":""" & JSEscape(rs("typecolor") & "") & """," jsonOutput = jsonOutput & """businessunit"":" & StrOrNull(rs("businessunit")) & "," ' Handle employeesso - can be SSO or NAME:customname - Dim upEmpName, upEmpPicture If Left(upEmpSsoRaw, 5) = "NAME:" Then ' Custom name - extract name, no picture upEmpName = Mid(upEmpSsoRaw, 6) diff --git a/devicefirewall.asp b/devicefirewall.asp index f8acae8..e589ec1 100644 --- a/devicefirewall.asp +++ b/devicefirewall.asp @@ -240,7 +240,10 @@ strSQL2 = "SELECT machinetypeid, machinetype FROM machinetypes WHERE isactive = 1 ORDER BY machinetype ASC" Set rsMachineTypes = objConn.Execute(strSQL2) While Not rsMachineTypes.EOF - Response.Write("") + ' Pre-select Firewall (46) as the default for this form + Dim mtSelected + If CStr(rsMachineTypes("machinetypeid")) = "46" Then mtSelected = " selected" Else mtSelected = "" + Response.Write("") rsMachineTypes.MoveNext Wend rsMachineTypes.Close diff --git a/machinemap.asp b/machinemap.asp index 92aae54..ec884b3 100644 --- a/machinemap.asp +++ b/machinemap.asp @@ -297,7 +297,7 @@ strSQL = "SELECT m.machineid, m.machinenumber, m.alias, m.serialnumber, " &_ "AND m.isactive = 1 " &_ "AND m.mapleft IS NOT NULL " &_ "AND m.maptop IS NOT NULL " &_ - "AND mt.machinetypeid NOT IN (1, 16, 17, 18, 19, 20) " &_ + "AND mt.machinetypeid NOT IN (1, 16, 17, 18, 19, 20, 46) " &_ "AND mt.machinetypeid < 33 " &_ "ORDER BY mt.machinetype, m.machinenumber ASC" diff --git a/machinemapeditor.asp b/machinemapeditor.asp index fbd8176..e0a4f7c 100644 --- a/machinemapeditor.asp +++ b/machinemapeditor.asp @@ -262,7 +262,7 @@ Set rsM = objConn.Execute("SELECT m.machineid, m.machinenumber, m.alias, m.maple "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " &_ "WHERE m.pctypeid IS NULL " &_ "AND m.isactive = 1 " &_ - "AND mt.machinetypeid NOT IN (1, 16, 17, 18, 19, 20) " &_ + "AND mt.machinetypeid NOT IN (1, 16, 17, 18, 19, 20, 46) " &_ "AND mt.machinetypeid < 33 " &_ "ORDER BY m.machinenumber") Do While Not rsM.EOF diff --git a/networkdevices.asp b/networkdevices.asp index 62c17ba..a2bc0f2 100644 --- a/networkdevices.asp +++ b/networkdevices.asp @@ -40,6 +40,7 @@ Add IDF Add Server Add Switch + Add Firewall Add Camera Add Access Point Add Printer @@ -47,6 +48,107 @@ + + <% + ' Check for devices that need model fixes + Dim rsModelIssues, modelIssueCount + Dim strModelIssueSQL + strModelIssueSQL = "SELECT " & _ + "ma.machineid, " & _ + "COALESCE(ma.alias, ma.machinenumber) as device_name, " & _ + "mt_machine.machinetype as current_type, " & _ + "ma.machinetypeid as machine_typeid, " & _ + "mo.modelnumber, " & _ + "CASE " & _ + " WHEN ma.modelnumberid IS NULL THEN 'No model assigned' " & _ + " WHEN mo.machinetypeid IS NULL THEN 'Model has no type set' " & _ + " WHEN mo.machinetypeid NOT IN (16,17,18,19,20,46) THEN 'Model has incorrect type' " & _ + " ELSE 'OK' " & _ + "END as issue " & _ + "FROM machines ma " & _ + "JOIN machinetypes mt_machine ON ma.machinetypeid = mt_machine.machinetypeid " & _ + "LEFT JOIN models mo ON ma.modelnumberid = mo.modelnumberid " & _ + "WHERE ma.machinetypeid IN (16,17,18,19,20,46) " & _ + "AND ma.isactive = 1 " & _ + "AND (ma.modelnumberid IS NULL OR mo.machinetypeid IS NULL OR mo.machinetypeid NOT IN (16,17,18,19,20,46)) " & _ + "ORDER BY mt_machine.machinetype, ma.alias" + Set rsModelIssues = objConn.Execute(strModelIssueSQL) + + ' Count issues + modelIssueCount = 0 + If Not rsModelIssues.EOF Then + rsModelIssues.MoveFirst + Do While Not rsModelIssues.EOF + modelIssueCount = modelIssueCount + 1 + rsModelIssues.MoveNext + Loop + rsModelIssues.MoveFirst + End If + + If modelIssueCount > 0 Then + %> +
<%=modelIssueCount%> device(s) need vendor/model updates to complete the migration from machine-level type assignment to model-level type assignment.
++ + Show Devices Needing Updates + +
+| Device | +Type | +Current Model | +Issue | +Action | +
|---|---|---|---|---|
| <%=Server.HTMLEncode(rsModelIssues("device_name") & "")%> | +<%=Server.HTMLEncode(rsModelIssues("current_type") & "")%> | +<%If IsNull(rsModelIssues("modelnumber")) Or rsModelIssues("modelnumber") = "" Then Response.Write("None") Else Response.Write(Server.HTMLEncode(rsModelIssues("modelnumber") & ""))%> | +<%=Server.HTMLEncode(rsModelIssues("issue") & "")%> | +Edit | +
PCs with relationships to shop floor machines
+ + + + + +| Machine # | +Vendor | +Model | +PC Hostname | +PC IP | +
|---|---|---|---|---|
| <%= Server.HTMLEncode(rs("machine_number") & "") %> | +<%= Server.HTMLEncode(rs("vendor") & "") %> | +<%= Server.HTMLEncode(rs("model") & "") %> | +<%= Server.HTMLEncode(rs("hostname") & "") %> | +<%= Server.HTMLEncode(rs("ip") & "") %> | +
<%= rowCount %> records found
+