%@ CODEPAGE=65001 %>
<%
'Localized Language Code Page
'------------------------------------------------------------
'
' Microsoft Internet Printing Project
'
' Copyright (c) Microsoft Corporation. All rights reserved.
'
' Default SNMP page. This page is used if there is nothing
' supplied by the printer vendor.
'
'------------------------------------------------------------
option explicit
%>
<%
On Error Resume Next
Err.Clear
CheckSession
Response.expires = 0
Response.Buffer = TRUE
Dim bRefresh
bRefresh = Request ("refresh") = 1
%>
<%
const L_NotEmpty_Text = "Not Empty" 'The input tray is not empty
const L_Empty_Text = "Empty" 'The input tray is empty
const L_Name_Text = "Name" 'The name of the input tray
const L_PaperSize_Text = "Paper Size"
const L_Media_Text = "Media"
const L_Current_Text = "Current" 'The Current number of the paper in the input tray
const L_Maximum_Text = "Maximum" 'The Maximum number of the paper in the input tray
const L_Tray_Text = "Tray "
const L_Seperator_Text = " - "
const L_Printer_Text = "Printer"
const L_Output_Text = "Output"
Function ErrorHandler (strErr)
Dim strHref
strHref = "ipp_0013.asp?notes=" & strErr
Response.Redirect (strHref)
Response.End
End Function
Function ErrorHandler2 (strErr)
Dim strScript
strScript = ""
Response.Write (strScript)
Response.End
End Function
Function GenConsoleTable(iRow, iColumn, strArray, strLang)
Dim strHTML
Dim strBgnCol, strEndCol
Dim strBgnRow, strEndRow
Dim i, j, srcIndex, c
Dim tmpArray
ReDim tmpArray (iColumn)
strHTML = ""
strBgnCol = "
"
strEndCol = "
"
If strLang = "JP" then
strBgnRow = ""
Else
strBgnRow = "" & DEF_FONT_TAG
End If
strEndRow = END_FONT & " | "
For i = 1 To iRow
srcIndex = 1
j = 1
While j <= iColumn
c = Mid (strArray(i - 1), srcIndex, 1)
If c = "" Then
tmpArray(j) = " "
Else
if Asc(c) <= 32 Then
tmpArray(j) = " "
Else
If strLang = "JP" Then
tmpArray(j) = OleCvt.ToUnicode (c, 932)
Else
tmpArray(j) = c
End If
End If
End If
j = j + 1
srcIndex = srcIndex + 1
Wend
strHTML = strHTML & strBgnCol
For j = 1 To iColumn
strHTML = strHTML & strBgnRow & tmpArray(j) & strEndRow
Next
strHTML = strHTML & strEndCol
Next
GenConsoleTable = strHTML
End Function
Function GenOneLight (rgLights, i, strId)
Dim strHTML
strHTML = " "
If rgLights(SNMP_LIGHT_ON, i) <> "0" And strId <> "IBM Network Printer 24 2.34F" Then
If rgLights(SNMP_LIGHT_OFF, i) <> "0" Then
strHTML = strHTML & ""
Else
strHTML = strHTML & ""
End If
Else
strHTML = strHTML & ""
End If
strHTML = strHTML & " | " & DEF_FONT_TAG
strHTML = strHTML & strCleanString(rgLights(SNMP_LIGHT_DESCRIPTION, i)) & " " & END_FONT & " | "
GenOneLight = strHTML
End Function
Function GenLightTable(iLights, rgLights, strId)
Dim i
Dim strHTML
Dim strBgnHdrCol, strEndHdrCol, strOneHeader
Const L_State_Text = "State /"
Const L_Light_Text = "Light"
strBgnHdrCol = "" & MENU_FONT_TAG & ""
strEndHdrCol = "" & END_FONT & " | "
strOneHeader = "" & MENU_FONT_TAG & "" & L_State_Text & strEndHdrCol & " | " & strBgnHdrCol & L_Light_Text & strEndHdrCol
strHTML = "" & strOneHeader & strOneHeader & strOneHeader & " "
If iLights <= 25 then
For i = 0 To iLights
If i Mod 3 = 0 Then
If i <> 0 Then strHTML = strHTML & ""
strHTML = strHTML & "" & GenOneLight (rgLights, i, strId)
Else
strHTML = strHTML & GenOneLight (rgLights, i, strId)
End If
Next
strHTML = strHTML & " "
Else
For i = 0 To iLights Step 2
strHTML = strHTML & "" & GenOneLight (rgLights, i, strId)
If i + 1 < iLights Then
strHTML = strHTML & GenOneLight (rgLights, i + 1, strId)
Else
strHTML = strHTML & " | | "
End If
strHTML = strHTML & " "
Next
End If
GenLightTable = strHTML
End Function
Function GetCurrentNumberOfPaper (iCurrent)
Dim strCount
Select Case iCurrent
Case -1, -2
strCount = " "
Case 0
strCount = L_Empty_Text
Case -3
strCount = L_NotEmpty_Text
Case Else
strCount = cstr(iCurrent)
End Select
GetCurrentNumberOfPaper = strCount
End Function
Function GenTrayTable (bPaperSize, bPaperMedia, iTrays, rgTrays)
Dim strHTML
Dim strBgnHdrCol, strEndHdrCol
Dim strBgnCol, strEndCol
Dim strBgnRow, strEndRow
Dim i, j, srcIndex, c
Dim tmpArray
strBgnHdrCol = "" & MENU_FONT_TAG & ""
strEndHdrCol = "" & END_FONT & " | "
strHTML = ""
strHTML = strHTML & strBgnHdrCol & L_Name_Text & strEndHdrCol
If bPaperSize Then
strHTML = strHTML & strBgnHdrCol & L_PaperSize_Text & strEndHdrCol
End If
If bPaperMedia Then
strHTML = strHTML & strBgnHdrCol & L_Media_Text & strEndHdrCol
End If
strHTML = strHTML & strBgnHdrCol & L_Current_Text & strEndHdrCol
strHTML = strHTML & strBgnHdrCol & L_Maximum_Text & strEndHdrCol
'strHTML = strHTML & strBgnHdrCol & L_State_Text & strEndHdrCol
strHTML = strHTML & " "
Dim strTrayName
For i = 0 to iTrays
strBgnCol = "" & DEF_FONT_TAG
strEndCol = END_FONT & " | "
strHTML = strHTML & "" & strBgnCol
if rgTrays(SNMP_INTRAY_UNIT, i) = "" or rgTrays(SNMP_INTRAY_UNIT, i) = " " then
If rgTrays(SNMP_INTRAY_NAME, i) = "" Then
strTrayName = L_Tray_Text & Cstr (i + 1)
Else
strTrayName = rgTrays(SNMP_INTRAY_NAME, i)
End If
Else
strTrayName = rgTrays(SNMP_INTRAY_UNIT, i)
End If
strHTML = strHTML & strCleanString(strTrayName) & strEndCol
rgTrays(SNMP_INTRAY_UNIT, i) = strTrayName
If bPaperSize Then
strHTML = strHTML & strBgnCol
dim strLongName
strLongName = objHelper.LongPaperName (rgTrays(SNMP_INTRAY_MEDIA, i))
If strLongName = "Unknown" Then
strLongName = rgTrays(SNMP_INTRAY_MEDIA, i)
End If
strHTML = strHTML & strLongName & strEndCol
End If
If bPaperMedia Then
strHTML = strHTML & strBgnCol & getMedia (rgTrays(SNMP_INTRAY_MEDIA, i)) & strEndCol
End If
strHTML = strHTML & strBgnCol & GetCurrentNumberOfPaper( rgTrays(SNMP_INTRAY_CURRENT, i)) & strEndCol
strHTML = strHTML & strBgnCol & rgTrays(SNMP_INTRAY_MAX, i) & strEndCol
strHTML = strHTML & " "
Next
GenTrayTable = strHTML
End Function
Function GenAlertTable (iAlerts, rgAlerts, rgTrays)
Dim strHTML
Dim i, j, bDup, code, strDscp
strHTML = ""
For i = 0 to iAlerts
code = rgAlerts(SNMP_ALERT_CODE, i)
j = 0
bDup = FALSE
While j <= i - 1 And Not bDup
If code = rgAlerts(SNMP_ALERT_CODE, j) Then
If rgAlerts(SNMP_ALERT_SUBUNIT, i) = rgAlerts(SNMP_ALERT_SUBUNIT, j) And rgAlerts(SNMP_ALERT_INDEX, i) = rgAlerts(SNMP_ALERT_INDEX, j) Then
bDup = TRUE
End If
End If
j = j + 1
Wend
If Not bDup Then
strHTML = strHTML & ""
Select Case rgAlerts(SNMP_ALERT_SEVERITY, i)
Case 3,5
strHTML = strHTML & ""
Case 4
strHTML = strHTML & ""
Case Else
strHTML = strHTML & " "
End Select
strHTML = strHTML & " | " & DEF_FONT_TAG
Select Case rgAlerts(SNMP_ALERT_SUBUNIT, i)
Case 8
If rgAlerts(SNMP_ALERT_INDEX, i) > 0 Then
strHTML = strHTML & strCleanString(rgTrays(SNMP_INTRAY_UNIT, rgAlerts(SNMP_ALERT_INDEX, i) - 1)) & L_Seperator_Text
Else
strHTML = strHTML & L_Tray_Text & L_Seperator_Text
End If
Case 5
strHTML = strHTML & L_Printer_Text & L_Seperator_Text
Case 9
strHTML = strHTML & L_Output_Text & L_Seperator_Text
Case Else
'
End Select
strHTML = strHTML & strCleanString(rgAlerts(SNMP_ALERT_DESCRIPTION, i)) & END_FONT & " | "
End If
Next
GenAlertTable = strHTML
End Function
Function getMedia(mediaName)
Dim media, i, mediaList
Dim L_MediaList_Text(3)
mediaList = Array("-white", "-envelope", "-colored", "-transparent")
L_MediaList_Text(0) = "White Paper"
L_MediaList_Text(1) = "Envelope"
L_MediaList_Text(2) = "Colored Paper"
L_MediaList_Text(3) = "Transparecy"
i = 0
For Each media In mediaList
If InStr(mediaName, media) > 0 Then
getMedia = L_MediaList_Text(i)
Exit Function
End If
i = i + 1
Next
getMedia = ""
End Function
Const L_WrongIP_Message = "The IP Address is not correct."
Const L_PageTitle_Text = "Microsoft Default SNMP status"
Const strFileID = "page1.asp"
Dim rgState, rgAlerts, rgLights, rgTrays, rgConsole, strLight
Dim bRet, objHelper
Dim iRow, iColumn, iAlerts, iTrays, iLights
Dim bPaperSize, bPaperMedia, i
Dim strLang
Dim strId
Dim objSNMP
Dim strIP, strCommunity, iDevice, strDevice
Dim strPrinter, strEncodedPrinter, strComputer, strNewURL
Dim strHTML
Err.Clear
strIP = Request(IPADDRESS)
If strIP = "" Then
Err.Number = 1
Err.Description = L_WrongIP_Message
ErrorHandler (strFileID)
End If
strCommunity = Request (COMMUNITY)
iDevice = Request(DEVICE)
strDevice = CStr(iDevice)
strEncodedPrinter = Request(PRINTER)
strPrinter = OleCvt.DecodeUnicodeName ( strEncodedPrinter )
Set objSNMP = Server.CreateObject(PROGID_SNMP)
If Err Then ErrorHandler (strFileID)
objSNMP.open strIP, strCommunity, 3, 2000
If Err Then ErrorHandler (strFileID)
strComputer = session(COMPUTER)
strNewURL = "page1.asp?refresh=1" & ATIPADDRESS & strIP & ATCOMMUNITY & strCommunity &_
ATPRINTER & strEncodedPrinter & ATDEVICE & strDevice
Set objHelper = Server.CreateObject (PROGID_HELPER)
objHelper.open "\\" & strComputer & "\" & strPrinter
If Err Then ErrorHandler (strFileID)
'Get Printer Id
strId = objSNMP.Get ("25.3.2.1.3." & CStr (iDevice))
If Err.Number <> 0 Then
ErrorHandler (strFileID)
End If
'Get basic state
rgState = rgSNMPGetState(objSNMP, iDevice)
If Err.Number <> 0 Or Not IsArray (rgState) Then ErrorHandler (strFileID)
If bRefresh Then
bRet = rgSNMPConsole(objSNMP, iDevice, iRow, iColumn, rgConsole, strLang)
If Not bRet Then ErrorHandler (strFileID)
rgLights = rgSNMPLights(objSNMP, iDevice, iLights)
If Err.Number <> 0 Then ErrorHandler (strFileID)
rgTrays = rgSNMPGetInputTrays(objSNMP, iDevice, iTrays)
If Err.Number <> 0 Then ErrorHandler (strFileID)
If iTrays >= 0 then
bPaperSize = not (rgTrays(SNMP_INTRAY_MEDIA, 0) = "" or rgTrays(SNMP_INTRAY_MEDIA, 0) = " " )
bPaperMedia = (getMedia (rgTrays(SNMP_INTRAY_MEDIA, 0)) <> "")
End if
'Get alerts
rgAlerts = rgSNMPGetAlerts(objSNMP, objHelper, iDevice, iAlerts)
End If
%>
<%=SetCodePage%>
<%=Write(L_PageTitle_Text) %>
<%=Write(DEF_BASEFONT_TAG)%>
<%
If Not bRefresh Then
Response.Flush
bRet = rgSNMPConsole(objSNMP, iDevice, iRow, iColumn, rgConsole, strLang)
If Not bRet Then ErrorHandler2 (strFileID)
End If
Const L_FrontPanelColon_Text = "Front Panel:"
Const L_DeviceStatus_Text = "Device Status:"
Const L_FrontPanel_Text = "FrontPanel"
Const L_RealTimeTitle_Text = "Real time display of the printer front panel"
%>
<%=Write(DEF_FONT_TAG & L_DeviceStatus_Text & END_FONT)%>
|
<% If IsArray (rgConsole) Then
Response.Write(Write("" & DEF_FONT_TAG & L_FrontPanelColon_Text & END_FONT & " | ") )
End If
%>
<% =Write(strSnmpStatus(rgState)) %>
|
<% If IsArray (rgConsole) Then
strHTML = "" &_
"" &_
GenConsoleTable(iRow, iColumn, rgConsole, strLang) &_
" | " &_
"
| "
Response.Write( Write(strHTML) )
End If
%>
<% Const L_PaperTrays_Text = "Paper Trays:" %>
<%=Write(DEF_FONT_TAG & L_PaperTrays_Text & END_FONT)%>
<%
If Not bRefresh Then
Response.Flush
rgTrays = rgSNMPGetInputTrays(objSNMP, iDevice, iTrays)
If Err.Number <> 0 Then ErrorHandler2 (strFileID)
If iTrays >= 0 Then
bPaperSize = not (rgTrays(SNMP_INTRAY_MEDIA, 0) = "" or rgTrays(SNMP_INTRAY_MEDIA, 0) = " " )
bPaperMedia = (getMedia (rgTrays(SNMP_INTRAY_MEDIA, 0)) <> "")
End If
End If
%>
<%=Write(GenTrayTable (bPaperSize, bPaperMedia, iTrays, rgTrays))%>
<%
If Not bRefresh Then
Response.Flush
rgLights = rgSNMPLights(objSNMP, iDevice, iLights)
If Err.Number <> 0 Then ErrorHandler2 (strFileID)
End If
%>
<%If iLights >= 0 Then %>
<% const L_ConsoleLights_Text = "Console Lights:" %>
<%=Write(DEF_FONT_TAG & L_ConsoleLights_Text & END_FONT)%>
<%=Write(GenLightTable (iLights, rgLights, strId))%>
<% End If%>
<% Const L_DetailedErr_Text = "Detailed Errors and Warnings:" %>
<%=Write(DEF_FONT_TAG & L_DetailedErr_Text & END_FONT)%>
<%
If Not bRefresh Then
Response.Flush
'Get alerts
rgAlerts = rgSNMPGetAlerts(objSNMP, objHelper, iDevice, iAlerts)
'If Err.Number <> 0 Then Exit Function
End If
%>
<%=Write(GenAlertTable (iAlerts, rgAlerts, rgTrays))%>
<%
objHelper.close
%>
<%
Response.End
%> |