Monday, December 1, 2008

Fun with Peregrine/HP ServiceCenter and USB7 LCD Display

ITIL isn't really fun until you learn the difference between calls, incidents and problems. I have a queue of incidents for which I am responsible, but I can't count on reliable notifications in the form of emails, and the client times me out after about 15 minutes, so I can't see if I have a new incident without logging in again.

I bought the super-cool USB7 7-segment LED kit and soldered it together in about an hour. It's a six-digit display, like you would see on clocks or a calculator. The included driver makes it appear to Windows (or Mac, or Linux) as a serial port. Thus, you write a line to the serial port and it appears on the LCD display. Simple enough.

The trick is getting useful information to the LCD display. How do I get the number of incidents in my queue to the USB7? (A better question might be, how am I supposed to know when there's a new ticket in my queue at all?)

We use Windows at work, so I needed to write this in some kind of dotNet mumbo-jumbo, which is slightly more complicated than PHP, Java ,or VB6, because you need to do things the dotNet way. This uses dotNet 2.0 or 3/3.5 and works in Visual Studio 2005 and Visual Studio 2008 on x86 and x64. It's a simple console application that runs a query and writes it to the com port. Everything is hard coded. Feel free to use it and change it as you wish. Now I need a larger LCD display. SQL query for ServiceCenter 6.1 tables in bold. (the thing with ServiceCenter, at least v6.1, is that incidents are in the probsummary tables. Calls are in the incidents tables.)


'Simple VB.Net 2008/2005 Code to write a single line to the USB7
'available from
'Tested on Win2k3 x86 amd x64 using avrcdc.inf
'11.20.2008 Larry
'release 1.1
'.Net sure is different than good old VB6. Everything's an object.

Imports System
Imports System.Text
Imports System.IO.Ports
Imports System.Data.SqlClient

Module USB7
Dim intTixCount As Int32 = 0
Sub Main()
'this is a standard ServiceCenter 6.1 query to list all the incidents in queue "My Queue"
Dim sql As String = "select count(dbo.probsummarym1.assignment)from dbo.probsummarym1 inner join dbo.probsummarym2 on dbo.probsummarym1.number = dbo.probsummarym2.number and dbo.probsummarym2.close_time is null where probsummarym1.assignment = 'My Queue';"
Using conn As New SqlConnection("Data Source=mydbserver;Initial Catalog=mydatabase;Integrated Security=True")
'you could hard-code a password in that string, but you know better.
Dim cmd As New SqlCommand(sql, conn)
Try
conn.Open()
intTixCount = Convert.ToInt32(cmd.ExecuteScalar())
'ExecuteScalar returns an int -- a regular cmd.execute would result in a recordset
'which would be a problem.
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
conn.Close()
'keep your DBAs happy and close those connections

End Using

Using com1 As IO.Ports.SerialPort = _
My.Computer.Ports.OpenSerialPort("COM2", 9600)

com1.WriteLine(intTixCount)

com1.Close()
'it really is that simple, because we're not reading anything back from the USB7

End Using
End Sub

End Module




Free 411 Service with Asterisk

Google has launched a free 411-style information service. It's not the first free one, by any means, but since it's Google's, I'll have higher expectations about its usability. There's another one available -- that's even older than Google's service. It's too bad you have to pay for e911 service, because doing the same won't send your name and address to your local PSAP.

The catch is, when you're dialing for information, you're at the phone, not the computer, and you may not have memorized the number. (1-800-GOOG-411.) If you're running Asterisk, you can easily reprogram 411 to go to the free 411 service of your choice. Just add the following lines to your extensions_custom.conf in /etc/asterisk:

[from-internal-custom]
exten => 411,1,Answer
exten => 411,2,Dial(SIP/mytrunkname/18004664411|300|)
exten => 411,4,Hangup