Web Access Single Site Alarms

SiteAlarms.asp

SiteAlarms.asp

 

 

ASP Code:

 

<%response.Charset="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>AlarmTraq - Alarms by Site</title> <meta http-equiv="refresh" content="60" /> <style type="text/css"><!--a{text-decoration:none}//--></style> <style type="text/css"><!--a:hover{color:Red; }--></style> </head> <% ' Dimension Local variables Dim objConn, objRSAlarms, objRSCompanyName, objOutgoing, strDSN, strSQL, intTotalColumns, intCounter, MyDate, PBXID, CompanyNotes, i Dim strAltColor ' To hold alternating color values Dim bColor ' Boolean we use to alternate colors dim IsMobileDevice bColor = False ' Set the ADO Constants if you are not including ' the adovbs.inc file Const adOpenStatic = 3 Const adLockReadOnly = 1 Set objConn = Server.CreateObject("ADODB.Connection") Set objRSAlarms = Server.CreateObject("ADODB.Recordset") Set objRSCompanyName = Server.CreateObject("ADODB.Recordset") Set objOutgoing = Server.CreateObject("ADODB.Recordset") 'strDSN = "DSN=AlarmTraqODBC" strDSN = "DSN=AlarmTraqODBC;uid=;pwd=;" objConn.ConnectionTimeout=60 objConn.Open strDSN dim fs dim FileObject dim FileName dim ConfigFileName set fs=Server.CreateObject("Scripting.FileSystemObject") 'Check for Windows CE (Pocket PC, Palm-size PC, Handheld PC, Handheld PC Pro) if (InStr(Request.ServerVariables("HTTP_USER_AGENT"), "Windows CE")) then Response.Write "<body style=""background-color:#ffffff; font-family:Arial; font-size:8pt;" IsMobileDevice = 1 else Response.Write "<body style=""background-color:#ffffff; font-family:Arial; font-size:10pt;" IsMobileDevice = 0 end if 'print out the background image if exists... FileName = Server.MapPath ("BackGround.gif") if fs.FileExists(FileName)=true and IsMobileDevice = 0 then Response.Write " background-image:url(BackGround.gif); background-attachment:fixed;" end if 'close the opening body tag Response.Write """>" FileName = Server.MapPath ("Logo1.gif") if fs.FileExists(FileName)=true and IsMobileDevice = 0 then Response.Write "<p align=""center"" style=""margin-bottom: 0""><img border=""0"" src=""Logo1.gif"" alt="""" />" elseif IsMobileDevice = 1 then 'Response.Write "<p><b><font size=4 color=#CC0000>alarm</font><font size=4>traq </font></b>" end if FileName = Server.MapPath ("Logo2.gif") if fs.FileExists(FileName)=true and IsMobileDevice = 0 then Response.Write "<p align=""center"" style=""margin-bottom: 0""><img border=""0"" src=""Logo2.gif"" alt="""" />" end if PBXID = CStr(Request("productid")) 'set the date 30 dats from today var1 = Now()-30 MyDate = FormatDateTime(var1,2) if PBXID="" then PBXID="1234567890" end if 'Open the CompanyName table strSQL = "SELECT PBXID,CompanyName,CompanySystem,CompanySoftwareVer,CompanyNotes2,AccountNumber FROM CompanyName WHERE PBXID = '" & PBXID & "' ORDER BY ID DESC" objRSCompanyName.Open strSQL, objConn, adOpenStatic, adLockReadOnly CompanyNotes = objRSCompanyName(4).Value if IsMobileDevice = 0 then Response.Write "<div style=""text-align:center; font-family:Arial;""><span style=""font-size:12pt; color:#000080;"">" & objRSCompanyName(1).Value & "</span><br />" if len(objRSCompanyName(2).Value) > 4 then Response.Write "<span style=""font-size:9pt""><i>" & objRSCompanyName(2).Value & " - " & objRSCompanyName(3).Value & "</span></div></i></b>" end if else Response.Write "<div style=""text-align:left; font-family:Arial;""><span style=""font-size:10pt; color:#000080;"">" & objRSCompanyName(1).Value & " </span><br />" if len(objRSCompanyName(2).Value) > 4 then Response.Write "<span style=""font-size:6pt""><i>" & objRSCompanyName(2).Value & " " & objRSCompanyName(3).Value & "</span></div></i></b>" end if end if ' Close CompanyName Recordset objRSCompanyName.Close Set objRSCompanyName = Nothing if IsMobileDevice = 0 then objRSAlarms.PageSize=15 else objRSAlarms.PageSize=5 end if filterwarnings = cint(Request.QueryString("filterwarnings")) if filterwarnings = 0 then strSQL = "select Date,Time,PBXID,PBXCompanyName,Cleared,ID,OutDialAttempted,PBXAlarmType,AlarmCode,AlarmData from Alarms WHERE PBXID = '" & PBXID & "' ORDER by ID DESC" else strSQL = "select Date,Time,PBXID,PBXCompanyName,Cleared,ID,OutDialAttempted,PBXAlarmType,AlarmCode,AlarmData from Alarms WHERE PBXID = '" & PBXID & "' AND AlarmData <> 'TESTING INADS LINK' AND AlarmData <> 'TEST INADS LINK' ORDER by ID DESC" end if objRSAlarms.Open strSQL, objConn, adOpenStatic,adLockReadOnly Dim MyPage Dim MyPages MyPages = cint(objRSAlarms.PageCount) MyPage = cint(Request.QueryString("pg")) if MyPages = 1 then MyPage = 1 objRSAlarms.AbsolutePage = 1 elseif MyPage = "" or MyPage = 0 or MyPage = 1 then MyPage = 1 objRSAlarms.AbsolutePage = 1 elseif MyPage >= MyPages then MyPage = MyPages objRSAlarms.AbsolutePage = MyPage else objRSAlarms.AbsolutePage = MyPage end if MyPageLink = "sitealarms.asp?productid=" & PBXID & "&pg=" & MyPage & "&filterwarnings=" & filterwarnings NextPageLink = "sitealarms.asp?productid=" & PBXID & "&pg=" & MyPage+1 & "&filterwarnings=" & filterwarnings PrevPageLink = "sitealarms.asp?productid=" & PBXID & "&pg=" & MyPage-1 & "&filterwarnings=" & filterwarnings FilterWarningsLink = "sitealarms.asp?productid=" & PBXID & "&pg=" & MyPage & "&filterwarnings=1" UnFilterWarningsLink = "sitealarms.asp?productid=" & PBXID & "&pg=" & MyPage & "&filterwarnings=0" if IsMobileDevice = 0 then Response.Write "<hr />" Response.Write "<table cellSpacing=1 border=0 id=table3 width=100% align=left>" Response.Write "<SCRIPT language=javascript>init(document.F1)</SCRIPT>" Response.Write "<tr>" Response.Write "<td align=""left"" width=""300""><font size=1>" Response.Write "<input onclick=window.location.replace('" & PrevPageLink & "') type=button value=""<< Prev Page"" id=button1 name=button1>&nbsp;" Response.Write "<input onclick=window.location.replace('" & NextPageLink & "') type=button value=""Next Page >>"" id=button1 name=button1></td>" Response.Write "<td align=center><font size=3 color=#000080><i>Alarms Page " & MyPage & " of " & MyPages & "</b></i></td>" if filterwarnings = 0 then Response.Write "<td align=""center"" width=""300"" ><font size=1><input onclick=window.location.replace('" & FilterWarningsLink & "') type=button value=""Hide Link Tests"" id=button1 name=button1></td>" else Response.Write "<td align=""center"" width=""300""><font size=1><input onclick=window.location.replace('" & UnFilterWarningsLink & "') type=button value=""Show Link Tests"" id=button1 name=button1></td>" end if Response.Write "</td></tr></table></center><br>" else Response.Write "</p></a><font size=1>Page "& MyPage & " of " & MyPages & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=""alarmtraq.asp?" & PBXID & "pg=" & MyPage-1 & """>[&lt;&lt;Prev]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=""alarmtraq.asp?" & PBXID & "pg=" & MyPage+1 & """>[Next &gt;&gt;]</a></p>" end if Response.Write "</tr><br>" if IsMobileDevice = 0 then %> <P style="margin-top: 0; margin-bottom: 0"></P> <table border="0" cellpadding="1" cellspacing="2" style="border-collapse: collapse" id="Table1"> <tr style="background-color:#0000cc; color:#ffffff;"> <th width="60" nowrap><font size="1">Date</th> <th width="65" nowrap><font size="1">Time</th> <th width="25" nowrap><font size="1">CLR</th> <th width="40" nowrap><font size="1">Tests</th> <th width="45" nowrap><font size="1">Type</th> <th width="35" nowrap><font size="1">Code</th> <th width="450"><font size="1">Alarm Data</th> </tr> <% else %> <P style="margin-top: 0; margin-bottom: 0"></P> <table border="0" cellpadding="0" cellspacing="1" style="border-collapse: collapse" id="Table1"> <tr style="background-color:#0000cc; color:#ffffff;"> <th nowrap><font size="1">Date</th> <th nowrap><font size="1">Time</th> <th nowrap><font size="1">CLR</th> <th nowrap><font size="1">Tests</th> <th nowrap><font size="1">Type</th> <th nowrap><font size="1">Code</th> <th nowrap><font size="1">Alarm.Data.....................................................</th> </tr> <% end if ' get the total number of columns intTotalColumns = objRSAlarms.Fields.Count - 1 dim MyFormattedAlarm ' now loop through the recordset and display the data i = 0 Do while i < objRSAlarms.PageSize and not objRSAlarms.EOF i = i+1 Response.Write "<tr>" & vbcrlf ' Toggle to the opposite color as the last row.</FONT> bColor = Not bColor If bColor Then strAltColor = "#FFFFFF" ' White Else strAltColor = "#FFFFE0" ' Light tan End If For intCounter = 0 To intTotalColumns if intCounter = 0 then 'Date if IsMobileDevice = 1 then MyFormattedDate = mid(objRSAlarms(intCounter).Value, 1, len(objRSAlarms(intCounter).Value) -5) Response.Write "<td align=""center""><font size=1>" & MyFormattedDate & "</td>" & vbcrlf else Response.Write "<td bgcolor=" & strAltColor & " align=""center""><font size=1>" & objRSAlarms(intCounter).Value & "</td>" & vbcrlf end if elseif intCounter = 1 then 'Time if IsMobileDevice = 1 then Response.Write "<td align=""center""><font size=1>" & formatdatetime(objRSAlarms(intCounter).Value, 4) & "</td>" & vbcrlf else Response.Write "<td bgcolor=" & strAltColor & " align=""right""><font size=1>" & objRSAlarms(intCounter).Value & "</td>" & vbcrlf end if elseif intCounter = 4 then 'Cleared if objRSAlarms(intCounter).Value = 0 then Response.Write "<td bgcolor=" & strAltColor & " align=""center""><font size=1>n</td>" & vbcrlf else Response.Write "<td bgcolor=" & strAltColor & " align=""center""><font size=1>y</td>" & vbcrlf end if elseif intCounter = 5 then 'ID if clng(objRSAlarms(6).Value) <> 0 then dim IndexPathHTM, IndexFileHTM IndexPathHTM="/alarms/Logs/" & PBXID & "/" & objRSAlarms(5).Value & ".htm" IndexFileHTM=Server.MapPath(IndexPathHTM) if fs.FileExists(IndexFileHTM)=true then Response.Write "<td bgcolor=" & strAltColor & " align=""center"" style=""color:#0000ff""><font size=1><a target=_blank href=""" & IndexPathHTM & """>View</a></td>" & vbcrlf else Response.Write "<td bgcolor=" & strAltColor & "><font size=1>&nbsp;</td>" & vbcrlf end if else Response.Write "<td bgcolor=" & strAltColor & "><font size=1>&nbsp;</td>" & vbcrlf end if elseif intCounter = 7 then 'Alarm Type if objRSAlarms(intCounter).Value = "Major" then Response.Write "<td align=""center"" style=""color:#ffffff; background-color:#ff0000""><font size=1>" & objRSAlarms(intCounter).Value & "</td>" & vbcrlf Response.Write "<td align=""center"" style=""color:#ffffff; background-color:#ff0000""><font size=1>" & objRSAlarms(8).Value & "</td>" & vbcrlf Response.Write "<td style=""color:#ffffff; background-color:#ff0000""><font size=1>" & objRSAlarms(9).Value & "</td></b>" & vbcrlf elseif objRSAlarms(intCounter).Value = "Minor" then Response.Write "<td align=""center"" style=""color:#000000; background-color:#FFFF00;""><font size=1>" & objRSAlarms(intCounter).Value & "</td>" & vbcrlf Response.Write "<td align=""center"" style=""color:#000000; background-color:#FFFF00;""><font size=1>" & objRSAlarms(8).Value & "</td>" & vbcrlf Response.Write "<td style=""color:#000000; background-color:#FFFF00;""><font size=1>" & objRSAlarms(9).Value & "</td>" & vbcrlf elseif objRSAlarms(intCounter).Value = "Warning" then if instr(objRSAlarms(9).Value, "ALL ALARMS RESOLVED") then Response.Write "<td align=""center"" style=""color:#ffffff; background-color:#008000""><font size=1>" & objRSAlarms(intCounter).Value & "</td>" & vbcrlf Response.Write "<td align=""center"" style=""color:#ffffff; background-color:#008000""><font size=1>" & objRSAlarms(8).Value & "</td>" & vbcrlf Response.Write "<td style=""color:#ffffff; background-color:#008000""><font size=1>" & objRSAlarms(9).Value & "</td>" & vbcrlf elseif instr(objRSAlarms(9).Value, "ipoGenAppOperational") then Response.Write "<td align=""center"" style=""color:#ffffff; background-color:#008000""><font size=1>" & objRSAlarms(intCounter).Value & "</td>" & vbcrlf Response.Write "<td align=""center"" style=""color:#ffffff; background-color:#008000""><font size=1>" & objRSAlarms(8).Value & "</td>" & vbcrlf Response.Write "<td style=""color:#ffffff; background-color:#008000""><font size=1>" & objRSAlarms(9).Value & "</td>" & vbcrlf else Response.Write "<td bgcolor=" & strAltColor & " align=""center"" style=""color:#808080""><font size=1>" & objRSAlarms(intCounter).Value & "</td>" & vbcrlf Response.Write "<td bgcolor=" & strAltColor & " align=""center"" style=""color:#808080""><font size=1>" & objRSAlarms(8).Value & "</td>" & vbcrlf Response.Write "<td bgcolor=" & strAltColor & " style=""color:#808080""><font size=1>" & objRSAlarms(9).Value & "</td>" & vbcrlf end if end if end if Next objRSAlarms.Movenext Loop %> </table> <% ' Close Recordset objRSAlarms.Close Set objRSAlarms = Nothing objConn.Close Set objConn = Nothing %> <% dim sPathTXT, sPathHTM, sFileTXT, sFileHTM, tmpLoop sPathTXT="/alarms/Logs/" & PBXID & "/AutoReport"& PBXID & ".txt" sPathHTM="/alarms/Logs/" & PBXID & "/AutoReport"& PBXID & ".htm" sFileTXT=Server.MapPath(sPathTXT) sFileHTM=Server.MapPath(sPathHTM) dim tmp, pos, bookmark, command, ReportDate, HTMReportDate Response.Write "<hr />" if fs.FileExists(sFileTXT)=true then Set FileObject = fs.GetFile(Server.MapPath(sPathTXT)) Set HTM_FileObject = fs.GetFile(Server.MapPath(sPathHTM)) Set textStreamObject = FileObject.OpenAsTextStream(1,0) %> <table border="0" width="500" cellpadding="1" cellspacing="1" style="border-collapse: collapse" id="Table2"> <% Do While textStreamObject.AtEndOfStream <> True tmp = textStreamObject.ReadLine pos=InStr(1,tmp,"Command: ") if pos > 0 then command = mid(tmp, 9) bookmark = Replace(command, " ", "") ReportDate = fileObject.DateLastModified HTMReportDate = HTM_FileObject.DateLastModified if tmpLoop = "" then ' Add header Response.Write "<td><b><i><p style=""font-family:Arial; font-size:9pt; text-align:left"">Available Configuration Reports:</f></b><font size=1><font color=#666666>&nbsp;&nbsp;" & FormatDateTime(HTMReportDate, 1) & "&nbsp;" & FormatDateTime(HTMReportDate, 3) & "</a></b></i></td></tr>" Response.Write "<td><p style=""font-family:Arial; font-size:8pt; text-align:left""><a href=" & sPathHTM & ">full configuration report</a></b></td>" Response.Write "</tr></a>" & vbcrlf tmpLoop = tmpLoop + 1 end if Response.Write "<td><p style=""font-family:Arial; font-size:8pt; text-align:left""><a target=_blank href=" & sPathHTM & "#" & bookmark & ">" & command & "</td>" '& ReportDate Response.Write "</tr></a>" & vbcrlf end if Loop 'Response.Write "<hr />" Response.Write "</table><BR></a>" textStreamObject.Close end if Set textStreamObject = nothing Set FileObject = nothing set fs=nothing 'Response.Write "<hr />" Response.Write "<p style=""font-family:Arial; font-size:8pt; text-align:left""><b>Notes: </b>" & CompanyNotes & "<br>" Response.Write "<p style=""font-family:Arial; font-size:8pt; text-align:center""><a href=""http://www.alarmtraq.com/"">www.alarmtraq.com</a></p>" %> </body> </html>