Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GUIConstantsEx.au3>
- #include <SQLite.au3>
- #include <SQLite.dll.au3>
- #include <string.au3>
- ;-VARIABLES TO UNCOMMENT FOR PRODUCTION -------------------------------------------------
- $DBPath = "C:\Program Files\Spiceworks\db\" ;PROD:: For Production Use
- $OutputPath = @ScriptDir & "\" ;PROD:: For Production Use
- ;-VARIABLES TO UNCOMMENT FOR DEBUGGING --------------------------------------------------
- ;~ $OutputPath = "C:\Documents and Settings\all users\Desktop\" ;DEBUG:: For Debugging
- ;~ $DBPath = "\\spiceworks-server\c$\program files\spiceworks\db\" ;DEBUG:: For Debugging
- ;-VARIABLES TO LEAVE UNCHANGED ----------------------------------------------------------
- $DBFilename = "spiceworks_prod.db"
- $hQuery = 1
- $LastRunMinutes = 0
- Dim $ResultRow[15] = ["1", "2"]
- ;----------------------------------------------------------------------------------------
- ;This is the timekeeper & runner script. Be careful when changing! ---------------------
- While 1
- If @MIN <> $LastRunMinutes Then
- UpdateTicketDetails()
- $LastRunMinutes = @MIN
- EndIf
- MouseMove(@DesktopWidth,@DesktopHeight,30)
- Sleep(60000)
- WEnd
- ;----------------------------------------------------------------------------------------
- Func UpdateTicketDetails()
- $TicketCount = FileOpen($OutputPath & "ticketcount.txt",2)
- $TicketDetail = FileOpen($OutputPath & "ticketdump.txt",2)
- $StartupCall = _SQLite_Startup()
- $SWDB = _SQLite_Open($DBPath & $DBFilename, 0x01)
- ;This is total ticket count
- _SQLite_Query($SWDB, "SELECT COUNT(*) AS TicketCount FROM tickets WHERE status <> 'closed'", $hQuery)
- If @Error Then
- ConsoleWrite("Query: @Error = " & @Error&@CRLF&"@Extended = "&@Extended&@CRLF)
- EndIf
- While _SQLite_FetchData($hQuery, $ResultRow) = $SQLITE_OK
- FileWriteLine($TicketCount, "Total: <"&$ResultRow[0]&">")
- WEnd
- ;Low Priority
- _SQLite_Query($SWDB, "SELECT COUNT(*) AS TicketCount FROM tickets WHERE status <> 'closed' AND priority = 3", $hQuery)
- If @Error Then
- ConsoleWrite("Query: @Error = " & @Error&@CRLF&"@Extended = "&@Extended&@CRLF)
- EndIf
- While _SQLite_FetchData($hQuery, $ResultRow) = $SQLITE_OK
- FileWriteLine($TicketCount, "Hold: <"&$ResultRow[0]&">")
- WEnd
- ;Normal Priority
- _SQLite_Query($SWDB, "SELECT COUNT(*) AS TicketCount FROM tickets WHERE status <> 'closed' AND priority = 2", $hQuery)
- If @Error Then
- ConsoleWrite("Query: @Error = " & @Error&@CRLF&"@Extended = "&@Extended&@CRLF)
- EndIf
- While _SQLite_FetchData($hQuery, $ResultRow) = $SQLITE_OK
- FileWriteLine($TicketCount, "Normal: <"&$ResultRow[0]&">")
- WEnd
- ;High Priority
- _SQLite_Query($SWDB, "SELECT COUNT(*) AS TicketCount FROM tickets WHERE status <> 'closed' AND priority = 1", $hQuery)
- If @Error Then
- ConsoleWrite("Query: @Error = " & @Error&@CRLF&"@Extended = "&@Extended&@CRLF)
- EndIf
- While _SQLite_FetchData($hQuery, $ResultRow) = $SQLITE_OK
- FileWriteLine($TicketCount, "High: <"&$ResultRow[0]&">")
- WEnd
- FileClose($TicketCount)
- $TicketsTxt = FileOpen($OutputPath & "ticketdump.txt",2)
- _SQLite_Query($SWDB, "SELECT * FROM tickets WHERE status <>'closed'", $hQuery)
- If @Error Then
- ConsoleWrite("@Error = " & @Error&@CRLF&"@Extended = "&@Extended&@CRLF)
- EndIf
- #cs
- $ResultRow[0] = Ticket Number
- $ResultRow[1] = Summary of Ticket
- $ResultRow[2] = Ticket Status
- $ResultRow[3] = Full Text of Ticket
- $ResultRow[4] = Ticket Priorty (3 = Hold, 2 = Normal 1 = High)
- $ResultRow[5] = Time Spent on Ticket
- $ResultRow[6] = Due Date
- $ResultRow[7] = Ticket Creation Date
- $ResultRow[8] = Ticket Last Updated Date
- $ResultRow[9] = Ticket Close Date
- $ResultRow[10]= Created By
- $$ResultRow[11]=Assigned to
- #ce
- While _SQLite_FetchData($hQuery, $ResultRow) = $SQLITE_OK
- ConsoleWrite("Ticket # "&$ResultRow[0]&"|"&$ResultRow[1]&"|"&$ResultRow[2]&"|"&$ResultRow[4]&"|"&$ResultRow[7]&"|"&$ResultRow[8]&"|"&$ResultRow[10]&"|"&$ResultRow[11]&@CRLF)
- FileWriteLine($TicketsTxt, "sol|"&$ResultRow[0]&"|"&$ResultRow[1]&"|"&$ResultRow[2]&"|"&$ResultRow[4]&"|"&$ResultRow[7]&"|"&$ResultRow[8]&"|"&$ResultRow[10]&"|"&$ResultRow[11]&"-tech|eol")
- WEnd
- FileClose($TicketsTxt)
- _SQLite_Shutdown()
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement