AlarmTraq.asp
AlarmTraq.asp
ASP Code:
<head>
<title>AlarmTraq - All Alarms</title>
<meta http-equiv="refresh" content="60" />
<style type="text/css">
<!--
a{text-decoration:none}
a:hover{color:Red; }
a.nav{color:#FFFF00}
-->
</style>
</head>
<%
' Dimension Local variables
Dim objConn, objRSAlarms, objRSCompanyName, strDSN, strSQL,
intTotalColumns, intCounter, MyDate, i
Dim strAltColor ' To hold alternating color values
Dim bColor ' Boolean we use to alternate colors
dim fs ' File System
dim FileName
dim IsMobileDevice ' Check for Windows CE
dim NextPageLink
dim PrevPageLink
bColor = False
' Set the ADO Constants if you are not including the adovbs.inc file
Const adOpenStatic = 3
Const adLockReadOnly = 1
Session.timeout = 15
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRSAlarms = Server.CreateObject("ADODB.Recordset")
strDSN = "DSN=AlarmTraqODBC;uid=;pwd=;"
objConn.ConnectionTimeout=60
objConn.Open strDSN
var1 = Now()-30
MyDate = FormatDateTime(var1,2)
'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
if IsMobileDevice = 0 then
objRSAlarms.PageSize=25
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 ORDER BY ID DESC"
else
strSQL = "SELECT
Date,Time,PBXID,PBXCompanyName,Cleared,ID,OutDialAttempted,PBXAlarmType,AlarmCode,AlarmData
FROM Alarms WHERE AlarmData <> 'TESTING INADS LINK' AND AlarmData <>
'TEST INADS LINK' ORDER BY ID DESC"
end if
objRSAlarms.Open strSQL, objConn, adOpenStatic,adLockReadOnly
set fs=Server.CreateObject("Scripting.FileSystemObject")
'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
MyPages = cint(objRSAlarms.PageCount)
MyPage = cint(Request.QueryString("pg"))
If MyPage < 1 then
MyPage = 1
end if
If MyPage > MyPages then
MyPage = MyPages
end if
MyPageLink = "alarmtraq.asp?" & PBXID & "pg=" & MyPage & "&filterwarnings="
& filterwarnings
NextPageLink = "alarmtraq.asp?" & PBXID & "pg=" & MyPage+1 & "&filterwarnings="
& filterwarnings
PrevPageLink = "alarmtraq.asp?" & PBXID & "pg=" & MyPage-1 & "&filterwarnings="
& filterwarnings
FilterWarningsLink = "alarmtraq.asp?" & PBXID & "pg=" & MyPage & "&filterwarnings=1"
UnFilterWarningsLink = "alarmtraq.asp?" & 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> "
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><b><font size=1>Page "& MyPage & " of " &
MyPages & " <a href=""alarmtraq.asp?" & PBXID & "pg=" &
MyPage-1 & """>[<<Prev] <a href=""alarmtraq.asp?" &
PBXID & "pg=" & MyPage+1 & """>[Next >>]</a></p></b>"
end if
Response.Write "</tr><br>"
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
' get the total number of columns
intTotalColumns = objRSAlarms.Fields.Count - 1
if IsMobileDevice = 0 then
%>
<table border="0" cellpadding="1" cellspacing="1"
style="border-collapse: collapse" id="Table1">
<tbody>
<tr style="background-color:#0000cc; color:#ffffff;">
<th width="45" nowrap><font size=1>Date</th>
<th width="65" nowrap><font size=1>Time</th>
<th width="65" nowrap><font size=1>Product ID</th>
<th width="75" nowrap><font size=1>Site Name</th>
<th width="30" nowrap><font size=1>CLR</th>
<th width="40" nowrap><font size=1>Tests</th>
<th width="50" nowrap><font size=1>Type</th>
<th width="35" nowrap><font size=1>Code</th>
<th width="375" nowrap><font size=1>Alarm Data</th>
</tr>
<%
else
%>
<table border="0" cellpadding="1" cellspacing="0" width="600"
id="Table1">
<tbody>
<tr style="background-color:#0000cc; color:#ffffff;">
<th nowrap></b><font size=1>Date</th>
<th nowrap></b><font size=1>Time</th>
<th nowrap></b><font size=1>Site.Name.............</th>
<th nowrap></b><font size=1>Type</th>
<th nowrap></b><font size=1>Code</th>
<th nowrap></b><font size=1>Alarm.Data.....................................................................</th>
</tr>
<%
end if
dim MyFormattedDate
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 bgcolor=" & strAltColor & " align=""center""><font
size=1>" & MyFormattedDate & "</td>" & vbcrlf
else
Response.Write "<td bgcolor=" & strAltColor & " align=""right""><font
size=1>" & objRSAlarms(intCounter).Value & "</td>" & vbcrlf
end if
elseif intCounter = 1 then 'Time
if IsMobileDevice = 1 then
Response.Write "<td bgcolor=" & strAltColor & " 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 = 2 then 'ProductID
if IsMobileDevice = 1 then
else
Response.Write "<td bgcolor=" & strAltColor & " align=""center""><font
size=1>" & objRSAlarms(intCounter).Value & "</td>" & vbcrlf
end if
elseif intCounter = 3 then 'CompanyName
if IsMobileDevice = 1 then
Response.Write "<td bgcolor=" & strAltColor & " nowrap
style=""color:#0000ff""><font size=1><a target=_blank href=""sitealarms.asp?productid="
& cstr(objRSAlarms(2).Value) & """>" & trim(left(objRSAlarms(intCounter).Value,20))
& "</b></a></td>" & vbcrlf
else
Response.Write "<td nowrap bgcolor=" & strAltColor & "
style=""color:#0000ff""><font size=1><b><a target=_blank href=""sitealarms.asp?productid="
& cstr(objRSAlarms(2).Value) & """>" &
trim(objRSAlarms(intCounter).Value) & "</b></a></td>" & vbcrlf
end if
elseif intCounter = 4 then 'CLR
if IsMobileDevice = 1 then
else
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
end if
elseif intCounter = 5 then 'ID
if IsMobileDevice = 1 then
else
if objRSAlarms(6).Value <> 0 then
dim IndexPathHTM, IndexFileHTM
IndexPathHTM="/alarms/Logs/" & objRSAlarms(2).Value & "/" &
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> </td>"
& vbcrlf
end if
else
Response.Write "<td bgcolor=" & strAltColor & "><font size=1> </td>"
& vbcrlf
end if
end if
elseif intCounter = 7 then 'Alarm Type
if IsMobileDevice = 1 then
MyFormattedAlarm = replace(objRSAlarms(9).Value, " ","")
MyFormattedAlarm = replace(MyFormattedAlarm, "-","")
if objRSAlarms(intCounter).Value = "Major" then
Response.Write "<td style=""background-color:#ff0000; color:#ffffff;""><font
size=1>MAJ</td>" & vbcrlf
Response.Write "<td style=""background-color:#ff0000; color:#ffffff;""><font
size=1>" & objRSAlarms(8).Value & "</td>" & vbcrlf
Response.Write "<td style=""background-color:#ff0000; color:#ffffff;""><font
size=1>" & MyFormattedAlarm & "</td>" & vbcrlf
elseif objRSAlarms(intCounter).Value = "Minor" then
Response.Write "<td nowrap style=""background-color:#FFFF00;
color:#000000;""><font size=1>MIN</td>" & vbcrlf
Response.Write "<td nowrap style=""background-color:#FFFF00;
color:#000000;""><font size=1>" & objRSAlarms(8).Value & "</td>" &
vbcrlf
Response.Write "<td nowrap style=""background-color:#FFFF00;
color:#000000;""><font size=1>" & MyFormattedAlarm & "</td>" & vbcrlf
elseif objRSAlarms(intCounter).Value = "Warning" then
if instr(1, objRSAlarms(9).Value, "ALL ALARMS RESOLVED") then
Response.Write "<td style=""color:#ffffff;
background-color:#008000""><font size=1>WAR</td>" & vbcrlf
Response.Write "<td 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, "ipoGenAppOperational2") then
Response.Write "<td style=""color:#ffffff;
background-color:#008000""><font size=1>WAR</td>" & vbcrlf
Response.Write "<td 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>" & MyFormattedAlarm & "</td>" &
vbcrlf
elseif instr(objRSAlarms(9).Value, "ipoGenAppOperational3") then
Response.Write "<td style=""color:#ffffff;
background-color:#008000""><font size=1>WAR</td>" & vbcrlf
Response.Write "<td 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>" & MyFormattedAlarm & "</td>" &
vbcrlf
else
Response.Write "<td bgcolor=" & strAltColor & "
style=""color:#808080""><font size=1>WAR</td>" & vbcrlf
Response.Write "<td bgcolor=" & strAltColor & "
style=""color:#808080""><font size=1>" & objRSAlarms(8).Value & "</td>"
& vbcrlf
Response.Write "<td bgcolor=" & strAltColor & "
style=""color:#808080""><font size=1>" & MyFormattedAlarm & "</td>" &
vbcrlf
end if
end if
else
if objRSAlarms(intCounter).Value = "Major" then
Response.Write "<td style=""background-color:#ff0000; color:#ffffff;
font-weight:bold;""><font size=1>" & objRSAlarms(intCounter).Value &
"</td>" & vbcrlf
Response.Write "<td style=""background-color:#ff0000; color:#ffffff;
font-weight:bold;""><font size=1>" & objRSAlarms(8).Value & "</td>" &
vbcrlf
Response.Write "<td style=""background-color:#ff0000; color:#ffffff;
font-weight:bold;""><font size=1>" & objRSAlarms(9).Value & "</td>" &
vbcrlf
elseif objRSAlarms(intCounter).Value = "Minor" then
Response.Write "<td nowrap style=""background-color:#FFFF00;
color:#000000; font-weight:bold;""><font size=1>" &
objRSAlarms(intCounter).Value & "</td>" & vbcrlf
Response.Write "<td nowrap style=""background-color:#FFFF00;
color:#000000; font-weight:bold;""><font size=1>" & objRSAlarms(8).Value
& "</td>" & vbcrlf
Response.Write "<td nowrap style=""background-color:#FFFF00;
color:#000000; font-weight:bold;""><font size=1>" & objRSAlarms(9).Value
& "</td>" & vbcrlf
elseif objRSAlarms(intCounter).Value = "Warning" then
if instr(1, objRSAlarms(9).Value, "ALL ALARMS RESOLVED") then
Response.Write "<td style=""font-weight:bold; color:#ffffff;
background-color:#008000""><font size=1>" &
objRSAlarms(intCounter).Value & "</td>" & vbcrlf
Response.Write "<td style=""font-weight:bold; color:#ffffff;
background-color:#008000""><font size=1>" & objRSAlarms(8).Value &
"</td>" & vbcrlf
Response.Write "<td style=""font-weight:bold; color:#ffffff;
background-color:#008000""><font size=1>" & objRSAlarms(9).Value &
"</td>" & vbcrlf
elseif instr(objRSAlarms(9).Value, "ipoGenAppOperational") then
Response.Write "<td style=""font-weight:bold; color:#ffffff;
background-color:#008000""><font size=1>" &
objRSAlarms(intCounter).Value & "</td>" & vbcrlf
Response.Write "<td style=""font-weight:bold; color:#ffffff;
background-color:#008000""><font size=1>" & objRSAlarms(8).Value &
"</td>" & vbcrlf
Response.Write "<td style=""font-weight:bold; color:#ffffff;
background-color:#008000""><font size=1>" & objRSAlarms(9).Value &
"</td>" & vbcrlf
else
Response.Write "<td bgcolor=" & strAltColor & " style=""font-weight:bold;
color:#808080""><font size=1>" & objRSAlarms(intCounter).Value & "</td>"
& vbcrlf
Response.Write "<td bgcolor=" & strAltColor & " style=""font-weight:bold;
color:#808080""><font size=1>" & objRSAlarms(8).Value & "</td>" & vbcrlf
Response.Write "<td bgcolor=" & strAltColor & " style=""font-weight:bold;
color:#808080""><font size=1>" & objRSAlarms(9).Value & "</td>" & vbcrlf
end if
end if
end if
end if
Next
Response.Write vbcrlf & " </tr>" & vbcrlf
objRSAlarms.Movenext
Loop
%>
</tbody>
</table>
<%
' Close file system
set fs=nothing
' Close Recordset
objRSAlarms.Close
Set objRSAlarms = Nothing
objConn.Close
Set objConn = Nothing
Response.Write "<hr />"
Response.Write "<div align=""left""><font size=""2"">To view INADS link
test results <a target=_blank href=""/alarms/Logs/TestINADSResults.htm"">click
here<br></a></font></div><br>"
Response.Write "<td style=""color:#0000ff""><font size=2>To view alarm
test results <a target=_blank href=""tests.asp"">click here</a></td>" &
vbcrlf
Response.Write "<br /><br /><div align=""center""><font
size=""2""></b><a href=""http://www.alarmtraq.com/"">www.alarmtraq.com</a></font></div>"
%>
</body>
</html>