diff --git a/api.asp b/api.asp index a57214c..399ff3f 100644 --- a/api.asp +++ b/api.asp @@ -115,6 +115,13 @@ Sub UpdateCompleteAsset() Dim hasWinRM hasWinRM = Trim(Request.Form("hasWinRM") & "") + ' Last boot time (optional) - accepts both lastBootUpTime and lastBootTime + Dim lastBootTime + lastBootTime = Trim(Request.Form("lastBootUpTime") & "") + If lastBootTime = "" Then + lastBootTime = Trim(Request.Form("lastBootTime") & "") + End If + ' DNC/GE registry data dncDualPathEnabled = Request.Form("dncDualPathEnabled") dncPath1Name = Trim(Request.Form("dncPath1Name") & "") @@ -290,7 +297,14 @@ Sub UpdateCompleteAsset() winrmValue = 0 End If - strSQL = "UPDATE machines SET serialnumber='" & safeSerial & "', modelnumberid=" & modelId & ", machinetypeid=" & machineTypeId & ", osid=" & osid & ", isvnc=" & vncValue & ", iswinrm=" & winrmValue & ", lastupdated=NOW() WHERE machineid=" & machineid + ' Build UPDATE with optional lastboottime + Dim lastBootPart + If lastBootTime <> "" Then + lastBootPart = ", lastboottime='" & Replace(lastBootTime, "'", "''") & "'" + Else + lastBootPart = "" + End If + strSQL = "UPDATE machines SET serialnumber='" & safeSerial & "', modelnumberid=" & modelId & ", machinetypeid=" & machineTypeId & ", osid=" & osid & ", isvnc=" & vncValue & ", iswinrm=" & winrmValue & lastBootPart & ", lastupdated=NOW() WHERE machineid=" & machineid objConn.Execute strSQL If Err.Number <> 0 Then SendError debugMsg & "10-UPDATE failed: " & Err.Description @@ -321,7 +335,16 @@ Sub UpdateCompleteAsset() winrmValueInsert = 0 End If - strSQL = "INSERT INTO machines (hostname, serialnumber, modelnumberid, machinetypeid, osid, machinestatusid, isvnc, iswinrm, lastupdated) VALUES ('" & safeHostname & "', '" & safeSerial & "', " & modelId & ", " & machineTypeId & ", " & osid & ", " & pcstatusid & ", " & vncValueInsert & ", " & winrmValueInsert & ", NOW())" + ' Build INSERT with optional lastboottime + Dim lastBootColInsert, lastBootValInsert + If lastBootTime <> "" Then + lastBootColInsert = ", lastboottime" + lastBootValInsert = ", '" & Replace(lastBootTime, "'", "''") & "'" + Else + lastBootColInsert = "" + lastBootValInsert = "" + End If + strSQL = "INSERT INTO machines (hostname, serialnumber, modelnumberid, machinetypeid, osid, machinestatusid, isvnc, iswinrm, lastupdated" & lastBootColInsert & ") VALUES ('" & safeHostname & "', '" & safeSerial & "', " & modelId & ", " & machineTypeId & ", " & osid & ", " & pcstatusid & ", " & vncValueInsert & ", " & winrmValueInsert & ", NOW()" & lastBootValInsert & ")" objConn.Execute strSQL If Err.Number <> 0 Then SendError debugMsg & "10-INSERT failed: " & Err.Description @@ -922,6 +945,14 @@ Function InsertOrUpdatePC(conn, hostname, serialnumber, manufacturer, model, pcT sqlStatusId = "NULL" End If + ' Build lastboottime part for UPDATE + Dim sqlLastBoot + If lastBootTime <> "" Then + sqlLastBoot = "lastboottime = '" & Replace(lastBootTime, "'", "''") & "', " + Else + sqlLastBoot = "" + End If + strSQL = "UPDATE machines SET " & _ "serialnumber = '" & safeSerial & "', " & _ "modelnumberid = " & sqlModelId & ", " & _ @@ -930,6 +961,7 @@ Function InsertOrUpdatePC(conn, hostname, serialnumber, manufacturer, model, pcT "machinenumber = " & sqlMachineNum & ", " & _ "osid = " & sqlOsId & ", " & _ "machinestatusid = " & sqlStatusId & ", " & _ + sqlLastBoot & _ "lastupdated = NOW() " & _ "WHERE machineid = " & CLng(machineid) & " AND pctypeid IS NOT NULL" @@ -967,7 +999,16 @@ Function InsertOrUpdatePC(conn, hostname, serialnumber, manufacturer, model, pcT ' Build SQL in parts to isolate error Dim sqlPart1, sqlPart2, sqlPart3 - sqlPart1 = "INSERT INTO machines (hostname, serialnumber, modelnumberid, machinetypeid, pctypeid, loggedinuser, machinenumber, osid, machinestatusid, isactive, lastupdated) VALUES (" + ' Add lastboottime column if provided + Dim sqlLastBootCol, sqlLastBootVal + If lastBootTime <> "" Then + sqlLastBootCol = ", lastboottime" + sqlLastBootVal = ", '" & Replace(lastBootTime, "'", "''") & "'" + Else + sqlLastBootCol = "" + sqlLastBootVal = "" + End If + sqlPart1 = "INSERT INTO machines (hostname, serialnumber, modelnumberid, machinetypeid, pctypeid, loggedinuser, machinenumber, osid, machinestatusid, isactive, lastupdated" & sqlLastBootCol & ") VALUES (" sqlPart2 = "'" & safeHostname & "', '" & safeSerial & "', " If modelId > 0 Then @@ -998,9 +1039,9 @@ Function InsertOrUpdatePC(conn, hostname, serialnumber, manufacturer, model, pcT End If If pcstatusid > 0 Then - sqlPart3 = sqlPart3 & CLng(pcstatusid) & ", 1, NOW())" + sqlPart3 = sqlPart3 & CLng(pcstatusid) & ", 1, NOW()" & sqlLastBootVal & ")" Else - sqlPart3 = sqlPart3 & "NULL, 1, NOW())" + sqlPart3 = sqlPart3 & "NULL, 1, NOW()" & sqlLastBootVal & ")" End If strSQL = sqlPart1 & sqlPart2 & sqlPart3 diff --git a/displaypcs.asp b/displaypcs.asp index 3dc54ce..4fd3188 100644 --- a/displaypcs.asp +++ b/displaypcs.asp @@ -39,11 +39,12 @@ <% -Dim currentPCStatus, recentFilter, deviceTypeFilter, pcTypeFilter, sel +Dim currentPCStatus, recentFilter, deviceTypeFilter, pcTypeFilter, uptimeFilter, sel currentPCStatus = Request.QueryString("pcstatus") recentFilter = Request.QueryString("recent") deviceTypeFilter = Request.QueryString("devicetype") pcTypeFilter = Request.QueryString("pctype") +uptimeFilter = Request.QueryString("uptime") ' Check for specialized PCs (CMM, Wax Trace, Measuring Tool) without equipment relationships Dim rsUnlinked, unlinkedCount @@ -110,7 +111,13 @@ Set rsStatus = Nothing - <% If currentPCStatus <> "" Or recentFilter <> "" Or deviceTypeFilter <> "" Or pcTypeFilter <> "" Or Request.QueryString("needsrelationship") <> "" Then %> + + <% If currentPCStatus <> "" Or recentFilter <> "" Or deviceTypeFilter <> "" Or pcTypeFilter <> "" Or uptimeFilter <> "" Or Request.QueryString("needsrelationship") <> "" Then %> Clear @@ -129,6 +136,7 @@ Set rsStatus = Nothing