Remove idle time tracking from PC data collection
- Remove idleMinutes parameter from api.asp updateCompleteAsset - Remove idle time Win32 API collection from PowerShell script - Clean up apishopfloor.asp (remove debug output) Idle time tracking was added but user decided not to use this feature. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
322
apishopfloor.asp
322
apishopfloor.asp
@@ -62,44 +62,88 @@ Do While Not rs.EOF
|
||||
isResolved = rs("is_resolved")
|
||||
|
||||
If isCurrent = 1 Then
|
||||
If Not isFirstCurrent Then jsonOutput = jsonOutput & ","
|
||||
isFirstCurrent = False
|
||||
|
||||
jsonOutput = jsonOutput & "{"
|
||||
jsonOutput = jsonOutput & """notificationid"":" & rs("notificationid") & ","
|
||||
jsonOutput = jsonOutput & """notification"":""" & JSEscape(rs("notification") & "") & ""","
|
||||
jsonOutput = jsonOutput & """starttime"":""" & ISODate(st) & ""","
|
||||
jsonOutput = jsonOutput & """endtime"":" & ISODateOrNull(et) & ","
|
||||
jsonOutput = jsonOutput & """ticketnumber"":" & StrOrNull(rs("ticketnumber")) & ","
|
||||
jsonOutput = jsonOutput & """link"":" & StrOrNull(rs("link")) & ","
|
||||
jsonOutput = jsonOutput & """isactive"":" & LCase(CStr(CBool(rs("isactive")))) & ","
|
||||
jsonOutput = jsonOutput & """isshopfloor"":true,"
|
||||
jsonOutput = jsonOutput & """resolved"":" & LCase(CStr(CBool(isResolved))) & ","
|
||||
If Not IsNull(rs("minutes_since_end")) Then
|
||||
jsonOutput = jsonOutput & """minutes_since_end"":" & rs("minutes_since_end") & ","
|
||||
Else
|
||||
jsonOutput = jsonOutput & """minutes_since_end"":null,"
|
||||
End If
|
||||
jsonOutput = jsonOutput & """typename"":""" & JSEscape(rs("typename") & "") & ""","
|
||||
jsonOutput = jsonOutput & """typecolor"":""" & JSEscape(rs("typecolor") & "") & ""","
|
||||
jsonOutput = jsonOutput & """businessunit"":" & StrOrNull(rs("businessunit")) & ","
|
||||
' Handle employeesso - can be SSO or NAME:customname
|
||||
Dim empSsoRaw, empName, empPicture
|
||||
' Check if this is a Recognition with multiple employees
|
||||
Dim typeName, empSsoRaw
|
||||
typeName = rs("typename") & ""
|
||||
empSsoRaw = rs("employeesso") & ""
|
||||
If Left(empSsoRaw, 5) = "NAME:" Then
|
||||
' Custom name - extract name, no picture
|
||||
empName = Mid(empSsoRaw, 6)
|
||||
empPicture = ""
|
||||
jsonOutput = jsonOutput & """employeesso"":null,"
|
||||
|
||||
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)
|
||||
|
||||
If Not isFirstCurrent Then jsonOutput = jsonOutput & ","
|
||||
isFirstCurrent = False
|
||||
|
||||
jsonOutput = jsonOutput & "{"
|
||||
jsonOutput = jsonOutput & """notificationid"":" & rs("notificationid") & ","
|
||||
jsonOutput = jsonOutput & """notification"":""" & JSEscape(rs("notification") & "") & ""","
|
||||
jsonOutput = jsonOutput & """starttime"":""" & ISODate(st) & ""","
|
||||
jsonOutput = jsonOutput & """endtime"":" & ISODateOrNull(et) & ","
|
||||
jsonOutput = jsonOutput & """ticketnumber"":" & StrOrNull(rs("ticketnumber")) & ","
|
||||
jsonOutput = jsonOutput & """link"":" & StrOrNull(rs("link")) & ","
|
||||
jsonOutput = jsonOutput & """isactive"":" & LCase(CStr(CBool(rs("isactive")))) & ","
|
||||
jsonOutput = jsonOutput & """isshopfloor"":true,"
|
||||
jsonOutput = jsonOutput & """resolved"":" & LCase(CStr(CBool(isResolved))) & ","
|
||||
If Not IsNull(rs("minutes_since_end")) Then
|
||||
jsonOutput = jsonOutput & """minutes_since_end"":" & rs("minutes_since_end") & ","
|
||||
Else
|
||||
jsonOutput = jsonOutput & """minutes_since_end"":null,"
|
||||
End If
|
||||
jsonOutput = jsonOutput & """typename"":""" & JSEscape(rs("typename") & "") & ""","
|
||||
jsonOutput = jsonOutput & """typecolor"":""" & JSEscape(rs("typecolor") & "") & ""","
|
||||
jsonOutput = jsonOutput & """businessunit"":" & StrOrNull(rs("businessunit")) & ","
|
||||
jsonOutput = jsonOutput & """employeesso"":" & StrOrNull(singleSSO) & ","
|
||||
jsonOutput = jsonOutput & """employeename"":" & StrOrNull(singleName) & ","
|
||||
jsonOutput = jsonOutput & """employeepicture"":" & StrOrNull(singlePicture) & ""
|
||||
jsonOutput = jsonOutput & "}"
|
||||
Next
|
||||
Else
|
||||
' SSO - lookup name and picture
|
||||
empName = LookupEmployeeNames(empSsoRaw)
|
||||
empPicture = LookupEmployeePictures(empSsoRaw)
|
||||
jsonOutput = jsonOutput & """employeesso"":" & StrOrNull(empSsoRaw) & ","
|
||||
' Single employee or non-recognition - build normally
|
||||
If Not isFirstCurrent Then jsonOutput = jsonOutput & ","
|
||||
isFirstCurrent = False
|
||||
|
||||
jsonOutput = jsonOutput & "{"
|
||||
jsonOutput = jsonOutput & """notificationid"":" & rs("notificationid") & ","
|
||||
jsonOutput = jsonOutput & """notification"":""" & JSEscape(rs("notification") & "") & ""","
|
||||
jsonOutput = jsonOutput & """starttime"":""" & ISODate(st) & ""","
|
||||
jsonOutput = jsonOutput & """endtime"":" & ISODateOrNull(et) & ","
|
||||
jsonOutput = jsonOutput & """ticketnumber"":" & StrOrNull(rs("ticketnumber")) & ","
|
||||
jsonOutput = jsonOutput & """link"":" & StrOrNull(rs("link")) & ","
|
||||
jsonOutput = jsonOutput & """isactive"":" & LCase(CStr(CBool(rs("isactive")))) & ","
|
||||
jsonOutput = jsonOutput & """isshopfloor"":true,"
|
||||
jsonOutput = jsonOutput & """resolved"":" & LCase(CStr(CBool(isResolved))) & ","
|
||||
If Not IsNull(rs("minutes_since_end")) Then
|
||||
jsonOutput = jsonOutput & """minutes_since_end"":" & rs("minutes_since_end") & ","
|
||||
Else
|
||||
jsonOutput = jsonOutput & """minutes_since_end"":null,"
|
||||
End If
|
||||
jsonOutput = jsonOutput & """typename"":""" & JSEscape(rs("typename") & "") & ""","
|
||||
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)
|
||||
empPicture = ""
|
||||
jsonOutput = jsonOutput & """employeesso"":null,"
|
||||
Else
|
||||
' SSO - lookup name and picture
|
||||
empName = LookupEmployeeNames(empSsoRaw)
|
||||
empPicture = LookupEmployeePictures(empSsoRaw)
|
||||
jsonOutput = jsonOutput & """employeesso"":" & StrOrNull(empSsoRaw) & ","
|
||||
End If
|
||||
jsonOutput = jsonOutput & """employeename"":" & StrOrNull(empName) & ","
|
||||
jsonOutput = jsonOutput & """employeepicture"":" & StrOrNull(empPicture) & ""
|
||||
jsonOutput = jsonOutput & "}"
|
||||
End If
|
||||
jsonOutput = jsonOutput & """employeename"":" & StrOrNull(empName) & ","
|
||||
jsonOutput = jsonOutput & """employeepicture"":" & StrOrNull(empPicture) & ""
|
||||
jsonOutput = jsonOutput & "}"
|
||||
End If
|
||||
|
||||
rs.MoveNext
|
||||
@@ -118,37 +162,76 @@ Do While Not rs.EOF
|
||||
isUpcoming = rs("is_upcoming")
|
||||
|
||||
If isUpcoming = 1 Then
|
||||
If Not isFirstUpcoming Then jsonOutput = jsonOutput & ","
|
||||
isFirstUpcoming = False
|
||||
' Check if this is a Recognition with multiple employees
|
||||
Dim upTypeName, upEmpSsoRaw
|
||||
upTypeName = rs("typename") & ""
|
||||
upEmpSsoRaw = rs("employeesso") & ""
|
||||
|
||||
jsonOutput = jsonOutput & "{"
|
||||
jsonOutput = jsonOutput & """notificationid"":" & rs("notificationid") & ","
|
||||
jsonOutput = jsonOutput & """notification"":""" & JSEscape(rs("notification") & "") & ""","
|
||||
jsonOutput = jsonOutput & """starttime"":""" & ISODate(st) & ""","
|
||||
jsonOutput = jsonOutput & """endtime"":" & ISODateOrNull(et) & ","
|
||||
jsonOutput = jsonOutput & """ticketnumber"":" & StrOrNull(rs("ticketnumber")) & ","
|
||||
jsonOutput = jsonOutput & """link"":" & StrOrNull(rs("link")) & ","
|
||||
jsonOutput = jsonOutput & """isactive"":" & LCase(CStr(CBool(rs("isactive")))) & ","
|
||||
jsonOutput = jsonOutput & """isshopfloor"":true,"
|
||||
jsonOutput = jsonOutput & """typename"":""" & JSEscape(rs("typename") & "") & ""","
|
||||
jsonOutput = jsonOutput & """typecolor"":""" & JSEscape(rs("typecolor") & "") & ""","
|
||||
jsonOutput = jsonOutput & """businessunit"":" & StrOrNull(rs("businessunit")) & ","
|
||||
' Handle employeesso - can be SSO or NAME:customname
|
||||
empSsoRaw = rs("employeesso") & ""
|
||||
If Left(empSsoRaw, 5) = "NAME:" Then
|
||||
' Custom name - extract name, no picture
|
||||
empName = Mid(empSsoRaw, 6)
|
||||
empPicture = ""
|
||||
jsonOutput = jsonOutput & """employeesso"":null,"
|
||||
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)
|
||||
|
||||
If Not isFirstUpcoming Then jsonOutput = jsonOutput & ","
|
||||
isFirstUpcoming = False
|
||||
|
||||
jsonOutput = jsonOutput & "{"
|
||||
jsonOutput = jsonOutput & """notificationid"":" & rs("notificationid") & ","
|
||||
jsonOutput = jsonOutput & """notification"":""" & JSEscape(rs("notification") & "") & ""","
|
||||
jsonOutput = jsonOutput & """starttime"":""" & ISODate(st) & ""","
|
||||
jsonOutput = jsonOutput & """endtime"":" & ISODateOrNull(et) & ","
|
||||
jsonOutput = jsonOutput & """ticketnumber"":" & StrOrNull(rs("ticketnumber")) & ","
|
||||
jsonOutput = jsonOutput & """link"":" & StrOrNull(rs("link")) & ","
|
||||
jsonOutput = jsonOutput & """isactive"":" & LCase(CStr(CBool(rs("isactive")))) & ","
|
||||
jsonOutput = jsonOutput & """isshopfloor"":true,"
|
||||
jsonOutput = jsonOutput & """typename"":""" & JSEscape(rs("typename") & "") & ""","
|
||||
jsonOutput = jsonOutput & """typecolor"":""" & JSEscape(rs("typecolor") & "") & ""","
|
||||
jsonOutput = jsonOutput & """businessunit"":" & StrOrNull(rs("businessunit")) & ","
|
||||
jsonOutput = jsonOutput & """employeesso"":" & StrOrNull(upSingleSSO) & ","
|
||||
jsonOutput = jsonOutput & """employeename"":" & StrOrNull(upSingleName) & ","
|
||||
jsonOutput = jsonOutput & """employeepicture"":" & StrOrNull(upSinglePicture) & ""
|
||||
jsonOutput = jsonOutput & "}"
|
||||
Next
|
||||
Else
|
||||
' SSO - lookup name and picture
|
||||
empName = LookupEmployeeNames(empSsoRaw)
|
||||
empPicture = LookupEmployeePictures(empSsoRaw)
|
||||
jsonOutput = jsonOutput & """employeesso"":" & StrOrNull(empSsoRaw) & ","
|
||||
' Single employee or non-recognition - build normally
|
||||
If Not isFirstUpcoming Then jsonOutput = jsonOutput & ","
|
||||
isFirstUpcoming = False
|
||||
|
||||
jsonOutput = jsonOutput & "{"
|
||||
jsonOutput = jsonOutput & """notificationid"":" & rs("notificationid") & ","
|
||||
jsonOutput = jsonOutput & """notification"":""" & JSEscape(rs("notification") & "") & ""","
|
||||
jsonOutput = jsonOutput & """starttime"":""" & ISODate(st) & ""","
|
||||
jsonOutput = jsonOutput & """endtime"":" & ISODateOrNull(et) & ","
|
||||
jsonOutput = jsonOutput & """ticketnumber"":" & StrOrNull(rs("ticketnumber")) & ","
|
||||
jsonOutput = jsonOutput & """link"":" & StrOrNull(rs("link")) & ","
|
||||
jsonOutput = jsonOutput & """isactive"":" & LCase(CStr(CBool(rs("isactive")))) & ","
|
||||
jsonOutput = jsonOutput & """isshopfloor"":true,"
|
||||
jsonOutput = jsonOutput & """typename"":""" & JSEscape(rs("typename") & "") & ""","
|
||||
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)
|
||||
upEmpPicture = ""
|
||||
jsonOutput = jsonOutput & """employeesso"":null,"
|
||||
Else
|
||||
' SSO - lookup name and picture
|
||||
upEmpName = LookupEmployeeNames(upEmpSsoRaw)
|
||||
upEmpPicture = LookupEmployeePictures(upEmpSsoRaw)
|
||||
jsonOutput = jsonOutput & """employeesso"":" & StrOrNull(upEmpSsoRaw) & ","
|
||||
End If
|
||||
jsonOutput = jsonOutput & """employeename"":" & StrOrNull(upEmpName) & ","
|
||||
jsonOutput = jsonOutput & """employeepicture"":" & StrOrNull(upEmpPicture) & ""
|
||||
jsonOutput = jsonOutput & "}"
|
||||
End If
|
||||
jsonOutput = jsonOutput & """employeename"":" & StrOrNull(empName) & ","
|
||||
jsonOutput = jsonOutput & """employeepicture"":" & StrOrNull(empPicture) & ""
|
||||
jsonOutput = jsonOutput & "}"
|
||||
End If
|
||||
|
||||
rs.MoveNext
|
||||
@@ -195,6 +278,119 @@ Function StrOrNull(s)
|
||||
End If
|
||||
End Function
|
||||
|
||||
' Look up a single employee name from SSO or NAME: prefix
|
||||
Function LookupSingleEmployeeName(ssoInput)
|
||||
If IsNull(ssoInput) Or Len(ssoInput & "") = 0 Then
|
||||
LookupSingleEmployeeName = ""
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
Dim sso
|
||||
sso = Trim(ssoInput & "")
|
||||
|
||||
' Check if this is a custom NAME: entry
|
||||
If Left(UCase(sso), 5) = "NAME:" Then
|
||||
LookupSingleEmployeeName = Mid(sso, 6)
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' Try DB lookup for numeric SSO
|
||||
If IsNumeric(sso) And Len(sso) > 0 Then
|
||||
Dim empConn, empCmd, empRs, firstName, lastName
|
||||
|
||||
On Error Resume Next
|
||||
Set empConn = Server.CreateObject("ADODB.Connection")
|
||||
empConn.ConnectionString = GetEmployeeConnectionString()
|
||||
empConn.Open
|
||||
|
||||
If Err.Number = 0 Then
|
||||
Set empCmd = Server.CreateObject("ADODB.Command")
|
||||
empCmd.ActiveConnection = empConn
|
||||
empCmd.CommandText = "SELECT First_Name, Last_Name FROM employees WHERE SSO = ?"
|
||||
empCmd.CommandType = 1
|
||||
empCmd.Parameters.Append empCmd.CreateParameter("@sso", 3, 1, , CLng(sso))
|
||||
|
||||
Set empRs = empCmd.Execute()
|
||||
If Err.Number = 0 And Not empRs.EOF Then
|
||||
firstName = empRs("First_Name") & ""
|
||||
lastName = empRs("Last_Name") & ""
|
||||
LookupSingleEmployeeName = firstName & " " & lastName
|
||||
Else
|
||||
LookupSingleEmployeeName = sso
|
||||
End If
|
||||
|
||||
If Not empRs Is Nothing Then
|
||||
If empRs.State = 1 Then empRs.Close
|
||||
Set empRs = Nothing
|
||||
End If
|
||||
Set empCmd = Nothing
|
||||
empConn.Close
|
||||
Else
|
||||
LookupSingleEmployeeName = sso
|
||||
End If
|
||||
Set empConn = Nothing
|
||||
On Error GoTo 0
|
||||
Else
|
||||
LookupSingleEmployeeName = sso
|
||||
End If
|
||||
End Function
|
||||
|
||||
' Look up a single employee picture from SSO
|
||||
Function LookupSingleEmployeePicture(ssoInput)
|
||||
If IsNull(ssoInput) Or Len(ssoInput & "") = 0 Then
|
||||
LookupSingleEmployeePicture = ""
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
Dim sso
|
||||
sso = Trim(ssoInput & "")
|
||||
|
||||
' NAME: entries have no picture
|
||||
If Left(UCase(sso), 5) = "NAME:" Then
|
||||
LookupSingleEmployeePicture = ""
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
' Try DB lookup for numeric SSO
|
||||
If IsNumeric(sso) And Len(sso) > 0 Then
|
||||
Dim empConn, empCmd, empRs, picture
|
||||
|
||||
On Error Resume Next
|
||||
Set empConn = Server.CreateObject("ADODB.Connection")
|
||||
empConn.ConnectionString = GetEmployeeConnectionString()
|
||||
empConn.Open
|
||||
|
||||
If Err.Number = 0 Then
|
||||
Set empCmd = Server.CreateObject("ADODB.Command")
|
||||
empCmd.ActiveConnection = empConn
|
||||
empCmd.CommandText = "SELECT Picture FROM employees WHERE SSO = ?"
|
||||
empCmd.CommandType = 1
|
||||
empCmd.Parameters.Append empCmd.CreateParameter("@sso", 3, 1, , CLng(sso))
|
||||
|
||||
Set empRs = empCmd.Execute()
|
||||
If Err.Number = 0 And Not empRs.EOF Then
|
||||
picture = empRs("Picture") & ""
|
||||
LookupSingleEmployeePicture = picture
|
||||
Else
|
||||
LookupSingleEmployeePicture = ""
|
||||
End If
|
||||
|
||||
If Not empRs Is Nothing Then
|
||||
If empRs.State = 1 Then empRs.Close
|
||||
Set empRs = Nothing
|
||||
End If
|
||||
Set empCmd = Nothing
|
||||
empConn.Close
|
||||
Else
|
||||
LookupSingleEmployeePicture = ""
|
||||
End If
|
||||
Set empConn = Nothing
|
||||
On Error GoTo 0
|
||||
Else
|
||||
LookupSingleEmployeePicture = ""
|
||||
End If
|
||||
End Function
|
||||
|
||||
' Look up employee name(s) from SSO(s)
|
||||
Function LookupEmployeeNames(ssoInput)
|
||||
If IsNull(ssoInput) Or Len(ssoInput & "") = 0 Then
|
||||
|
||||
Reference in New Issue
Block a user