<% On Error Resume Next Dim deviceType, deviceId, machineid, mapleft, maptop, deviceName, strSQL, rs ' Support both old (machineid) and new (type+id) parameters machineid = Request.Querystring("machineid") deviceType = Trim(Request.Querystring("type")) deviceId = Trim(Request.Querystring("id")) ' Determine which query to use If machineid <> "" Then ' Old format: machineid parameter (for backwards compatibility) strSQL = "SELECT mapleft, maptop, machinenumber AS devicename FROM machines WHERE machineid = " & CLng(machineid) ElseIf deviceType <> "" And deviceId <> "" And IsNumeric(deviceId) Then ' New format: type + id parameters ' All network devices now stored in machines table (machinetypeid 16-20) ' Printers have their own maptop/mapleft in the printers table Select Case LCase(deviceType) Case "printer" ' Printers have their own location in the printers table strSQL = "SELECT p.mapleft, p.maptop, p.printerwindowsname AS devicename FROM printers p WHERE p.printerid = " & CLng(deviceId) Case "idf", "server", "switch", "camera", "accesspoint", "access point" ' Query machines table for all network devices strSQL = "SELECT mapleft, maptop, COALESCE(alias, machinenumber) AS devicename FROM machines WHERE machineid = " & CLng(deviceId) Case "machine" strSQL = "SELECT mapleft, maptop, COALESCE(alias, machinenumber) AS devicename FROM machines WHERE machineid = " & CLng(deviceId) Case Else Response.Write("

Unknown device type

") objConn.Close Response.End End Select Else Response.Write("

Invalid parameters

") objConn.Close Response.End End If Set rs = objConn.Execute(strSQL) If Not rs.EOF Then mapleft = rs("mapleft") maptop = rs("maptop") deviceName = rs("devicename") ' Check if location is set If IsNull(mapleft) Or IsNull(maptop) Or mapleft = "" Or maptop = "" Then Response.Write("

No location set

") rs.Close Set rs = Nothing objConn.Close Response.End End If ' Invert Y coordinate for Leaflet maptop = 2550 - maptop Else Response.Write("

Device not found

") rs.Close Set rs = Nothing objConn.Close Response.End End If rs.Close Set rs = Nothing objConn.Close %>