<%
end sub
'===========绘制图表=========================================================================================================
sub showchart()
%>
<%
end sub
'===========显示结果2=========================================================================================================
'显示报警记录
sub showpage2
dim isMulti, bl, d1, d2
isMulti = session("isMulti")
bl = session("bl")
d1 = session("d1")
d2 = session("d2")
dim rsa, sql, totalPages, totalRecords, strFileName, bl_arr, bl_str
strFileName = "report.asp?action=showpage2"
if isMulti = false then
if bl = "" then
response.write "没有记录!"
response.end
end if
else
bl_arr = split(bl,",")
for i = 0 to ubound(bl_arr)
sql = "select * from t_waring_record where type_desc = '" & xml_getVarDesc(trim(bl_arr(i))) & "'"
set kk = server.CreateObject("adodb.recordset")
kk.open sql, conn, 1, 1
if not kk.eof then
if bl_str = "" then
bl_str = "'" & xml_getVarDesc(trim(bl_arr(i))) & "'"
else
bl_str = bl_str & "," & "'" & xml_getVarDesc(trim(bl_arr(i))) & "'"
end if
end if
next
if bl_str = "" then
response.write "没有记录!"
response.end
end if
end if
sql = "select type_desc,happen_time,curr_value,warncontent from t_waring_record where type_desc "
if isMulti = true then
sql = sql & "in (" & bl_str & ")"
else
sql = sql & "= '" & xml_getVarDesc(trim(bl)) & "'"
end if
'时间范围
sql = sql & " and happen_time between '" & d1 & "' and '" & d2 & "'"
'排序
sql = sql & " order by equip_desc, type_desc, happen_time desc"
set rsa = server.CreateObject("adodb.recordset")
rsa.open sql, conn, 1, 1
rsa.pagesize = maxperpage
totalPages = rsa.pagecount
totalRecords = rsa.recordcount
if rsa.bof and rsa.eof then
else
dim pageAction
pageAction = request("pageAction")
select case pageAction
case "goPage" session("page") = CLng(request("pageNum"))
case "first" session("page") = 1
case "prev" session("page") = session("page") - 1
case "next" session("page") = session("page") + 1
case "last" session("page") = totalPages
case else session("page") = 1
end select
if session("page") < 1 then session("page") = 1
if session("page") > totalPages then session("page") = totalPages
rsa.absolutepage = session("page")
end if
%>
<%
if totalPages > 1 then
if session("page")=1 then
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页 -下一页-最后一页"
elseif session("page")=TotalPages Then
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页-下一页-最后一页"
else
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页-下一页-最后一页"
end if
else
response.write "共有报警" & totalRecords & "条 " & session("page") & "/" & totalPages & "页"
end if
%>
变量名
发生时间
报警信息
值
<%if rsa.bof and rsa.eof then%>
没有记录!
<%
else
i = 0
do while not rsa.eof and i < maxperpage
i = i + 1
%>
<%=rsa("type_desc")%>
<%=rsa("happen_time")%>
<%=rsa("warncontent")%>
<%=dotwithonebit(rsa("curr_value"),2)%>
<%
rsa.movenext
loop
rsa.close
set rsa = nothing
end if
%>
<%
end sub
'===========显示短信查询结果=========================================================================================================
sub showpageSms
dim d1, d2
d1 = session("d1")
d2 = session("d2")
dim rsa, sql, totalPages, totalRecords, strFileName
strFileName = "report.asp?action=showpageSms"
sql = "select telnum, contactname, sendtime, contents from t_sms_rec where "
'时间范围
sql = sql & "sendtime between '" & d1 & "' and '" & d2 & "'"
'排序
sql = sql & " order by id desc"
set rsa = server.CreateObject("adodb.recordset")
rsa.open sql, conn, 1, 1
rsa.pagesize = maxperpage
totalPages = rsa.pagecount
totalRecords = rsa.recordcount
if rsa.bof and rsa.eof then
else
dim pageAction
pageAction = request("pageAction")
select case pageAction
case "goPage" session("page") = CLng(request("pageNum"))
case "first" session("page") = 1
case "prev" session("page") = session("page") - 1
case "next" session("page") = session("page") + 1
case "last" session("page") = totalPages
case else session("page") = 1
end select
if session("page") < 1 then session("page") = 1
if session("page") > totalPages then session("page") = totalPages
rsa.absolutepage = session("page")
end if
%>
<%
if totalPages > 1 then
if session("page")=1 then
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页 -下一页-最后一页"
elseif session("page")=TotalPages Then
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页-下一页-最后一页"
else
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页-下一页-最后一页"
end if
else
response.write "共有报警" & totalRecords & "条 " & session("page") & "/" & totalPages & "页"
end if
%>
手机号码
报警信息
发送时间
<%if rsa.bof and rsa.eof then%>
没有记录!
<%
else
i = 0
do while not rsa.eof and i < maxperpage
i = i + 1
%>
<%=rsa("telnum")%>
<%=rsa("contents")%>
<%=rsa("sendtime")%>
<%
rsa.movenext
loop
rsa.close
set rsa = nothing
end if
%>
<%
end sub
'===========显示电话查询结果=========================================================================================================
sub showpageTel
dim d1, d2
d1 = session("d1")
d2 = session("d2")
dim rsa, sql, totalPages, totalRecords, strFileName
strFileName = "report.asp?action=showpageTel"
sql = "select telnum, contactname, sendtime, contents from t_notice_rec where "
'时间范围
sql = sql & "sendtime between '" & d1 & "' and '" & d2 & "'"
'排序
sql = sql & " order by id desc"
set rsa = server.CreateObject("adodb.recordset")
rsa.open sql, conn, 1, 1
rsa.pagesize = maxperpage
totalPages = rsa.pagecount
totalRecords = rsa.recordcount
if rsa.bof and rsa.eof then
else
dim pageAction
pageAction = request("pageAction")
select case pageAction
case "goPage" session("page") = CLng(request("pageNum"))
case "first" session("page") = 1
case "prev" session("page") = session("page") - 1
case "next" session("page") = session("page") + 1
case "last" session("page") = totalPages
case else session("page") = 1
end select
if session("page") < 1 then session("page") = 1
if session("page") > totalPages then session("page") = totalPages
rsa.absolutepage = session("page")
end if
%>
<%
if totalPages > 1 then
if session("page")=1 then
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页 -下一页-最后一页"
elseif session("page")=TotalPages Then
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页-下一页-最后一页"
else
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页-下一页-最后一页"
end if
else
response.write "共有报警" & totalRecords & "条 " & session("page") & "/" & totalPages & "页"
end if
%>
手机号码
报警信息
发送时间
<%if rsa.bof and rsa.eof then%>
没有记录!
<%
else
i = 0
do while not rsa.eof and i < maxperpage
i = i + 1
%>
<%=rsa("telnum")%>
<%=rsa("contents")%>
<%=rsa("sendtime")%>
<%
rsa.movenext
loop
rsa.close
set rsa = nothing
end if
%>
<%
end sub
'===========显示Email查询结果=========================================================================================================
sub showpageEmail
dim d1, d2
d1 = session("d1")
d2 = session("d2")
dim rsa, sql, totalPages, totalRecords, strFileName
strFileName = "report.asp?action=showpageEmail"
sql = "select emailaddr, contactname, sendtime, contents from t_email_rec where "
'时间范围
sql = sql & "sendtime between '" & d1 & "' and '" & d2 & "'"
'排序
sql = sql & " order by id desc"
set rsa = server.CreateObject("adodb.recordset")
rsa.open sql, conn, 1, 1
rsa.pagesize = maxperpage
totalPages = rsa.pagecount
totalRecords = rsa.recordcount
if rsa.bof and rsa.eof then
else
dim pageAction
pageAction = request("pageAction")
select case pageAction
case "goPage" session("page") = CLng(request("pageNum"))
case "first" session("page") = 1
case "prev" session("page") = session("page") - 1
case "next" session("page") = session("page") + 1
case "last" session("page") = totalPages
case else session("page") = 1
end select
if session("page") < 1 then session("page") = 1
if session("page") > totalPages then session("page") = totalPages
rsa.absolutepage = session("page")
end if
%>
<%
if totalPages > 1 then
if session("page")=1 then
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页 -下一页-最后一页"
elseif session("page")=TotalPages Then
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页-下一页-最后一页"
else
response.write "共有报警"&TotalRecords&"条 "&session("page")&"/"&TotalPages&"页 第一页-上一页-下一页-最后一页"
end if
else
response.write "共有报警" & totalRecords & "条 " & session("page") & "/" & totalPages & "页"
end if
%>
Email地址
报警信息
发送时间
<%if rsa.bof and rsa.eof then%>
没有记录!
<%
else
i = 0
do while not rsa.eof and i < maxperpage
i = i + 1
%>
<%=rsa("emailaddr")%>
<%=rsa("contents")%>
<%=rsa("sendtime")%>
<%
rsa.movenext
loop
rsa.close
set rsa = nothing
end if
%>
<%
end sub
'===========绘制图表=========================================================================================================
sub showchart2()
%>
<%
end sub
'===========导出Excel=========================================================================================================
sub createExcel()
dim prename, xmlFile, xml, iRow
prename = session("prename")
if not fso.fileexists(server.mappath("temp/"&prename&".xls")) then
xmlFile = server.MapPath("temp/" & prename & "_alldata.xml")
set xml = server.CreateObject("MicroSoft.XMLDom")
xml.Load(xmlFile)
Response.ContentType = "application/msexcel"
Dim xlWorkSheet
Dim xlApplication
Set xlApplication = Server.CreateObject("Excel.Application")
xlApplication.Visible = False
xlApplication.Workbooks.Add
Set xlWorksheet = xlApplication.Worksheets(1)
xlWorksheet.Cells(1,1).Value = "变量名"
xlWorksheet.Cells(1,2).Value = "值"
xlWorksheet.Cells(1,3).Value = "发生时间"
iRow = 2
if xml.getElementsByTagName("subdata").length = 0 then
xlWorksheet.Cells(iRow,1).Value = ""
xlWorksheet.Cells(iRow,2).Value = ""
xlWorksheet.Cells(iRow,3).Value = ""
else
for i = 0 to xml.getElementsByTagName("subdata").length - 1
xlWorksheet.Cells(iRow,1).Value = xml.getElementsByTagName("subdata")(i).childNodes.item(0).text
xlWorksheet.Cells(iRow,2).Value = xml.getElementsByTagName("subdata")(i).childNodes.item(1).text
xlWorksheet.Cells(iRow,3).Value = xml.getElementsByTagName("subdata")(i).childNodes.item(2).text
iRow = iRow + 1
next
end if
xlWorksheet.SaveAs Server.MapPath("temp/" & prename & ".xls")
xlApplication.Quit
'Close the Workbook
Set xlWorksheet = Nothing
Set xlApplication = Nothing
set xml = nothing
response.Redirect "report.asp?action=createExcel"
else
%>
<%
end if
end sub
%>
<%
'获取设备列表
function getsb()
dim sql, rssb, str
sql = "select t_classid, classname from t_area where child = 0 and parentid <> 0 order by orderid, t_classid"
set rssb = conn.execute(sql)
if rssb.bof and rssb.eof then
str = ""
else
do while not rssb.eof
str = str & ""
rssb.movenext
loop
end if
rssb.close
set rssb = nothing
getsb = str
end function
'获取变量列表
function getbl()
dim sql, rsbl, str, areaid
sql = "select description, varname from t_dev_variant where issave = '1' order by description"
set rsbl = conn.execute(sql)
if rsbl.bof and rsbl.eof then
str = str & ""
else
do while not rsbl.eof
str = str & "" & vbCrLf
rsbl.movenext
loop
end if
rsbl.close
set rsbl = nothing
getbl = str
end function
'打开文件文本并读取内容
function FSOFileRead(filename)
Dim objFSO,objCountFile,FiletempData
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
if not objFSO.fileExists(server.mappath(filename)) then exit function
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)
FSOFileRead = objCountFile.ReadAll
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing
End Function
'删除不符合条件的数组元素
function arrayremove(m, n, byval arrpar, byval key, byval key2, byval key3)
dim i,j,k
k=0
for i = 1 to ubound(arrpar,2)
if left(arrpar(m,i),len(key)) = key and arrpar(n,i) > key2 and arrpar(n,i) < key3 then
k = k+1
for j = 0 to ubound(arrpar,1)
arrpar(j,k-1) = arrpar(j,i)
next
end if
next
ReDim Preserve arrpar(ubound(arrpar,1), k-1)
arrayremove = arrpar
end function
function arrayremove_multi(m, n, byval arrpar, byval key, byval key2, byval key3)
dim i,j,k,key_arr,kk
k=0
key_arr = split(key,",")
for i = 1 to ubound(arrpar,2)
for kk = 0 to ubound(key_arr)
if left(arrpar(m,i),len(key_arr(kk))) = key_arr(kk) and arrpar(n,i) > key2 and arrpar(n,i) < key3 then
k = k+1
for j = 0 to ubound(arrpar,1)
arrpar(j,k-1) = arrpar(j,i)
next
end if
next
next
ReDim Preserve arrpar(ubound(arrpar,1), k-1)
arrayremove = arrpar
end function
function arrayremove2(m, n, byval arrpar, byval key, byval key2)
dim i,j,k
k=0
for i = 0 to ubound(arrpar,2)
if arrpar(m,i) = key and mid(cstr(formattime(arrpar(n,i))),1,10) = mid(cstr(key2),1,10) then
k = k+1
for j = 0 to ubound(arrpar,1)
arrpar(j,k-1) = arrpar(j,i)
next
end if
next
ReDim Preserve arrpar(ubound(arrpar,1), k-1)
arrayremove2 = arrpar
end function
'合并数组
function array_merge(byVal firstArray, byVal secondArray)
dim totalSize
dim i,j
dim combinedArray
'Ensure that we're dealing with arrays.
if not isArray(firstArray) then
firstArray = Array(firstArray)
end if
if not isArray(secondArray) then
secondArray = Array(secondArray)
end if
'Set up the new array.
totalSize = uBound(firstArray,2) + uBound(secondArray,2) + 1
combinedArray = firstArray
redim preserve combinedArray(uBound(firstArray,1),totalSize)
for i = 0 to uBound(secondArray,2)
for j = 0 to uBound(firstArray,1)
combinedArray(j,uBound(firstArray,2) + 1 + i) = secondArray(j,i)
next
next
array_merge = combinedArray
end function
function formattime(t)
dim omm,odd,ohh,ostr
omm = month(t)
odd = day(t)
ohh = hour(t)
ostr = cstr(t)
if len(omm) = 1 then ostr = replace(ostr,"-"&omm,"-0"&omm,1,1)
if len(odd) = 1 then ostr = replace(ostr,"-"&odd,"-0"&odd,1,1)
if len(ohh) = 1 then ostr = replace(ostr," "&ohh," 0"&ohh,1,1)
formattime = ostr
end function
function getMax(arr)
dim i, max
if not isArray(arr) then
arr = Array(arr)
end if
max = cint(arr(0))
for i = 0 to ubound(arr)
if cint(arr(i)) > cint(max) then max = cint(arr(i))
next
getMax = max
end function
'日志文件筛选后存入xml
function logToxml(oLog, isMulti, bl, d1, d2, prename)
dim ao, arr, bl_arr, i, j, arr1, arr2
set ao = new arrayoperate
arr = ao.stringtoarray(oLog) '日志存入数组
if isMulti = false then
arr1 = arrayremove(0,2,arr,""""&trim(bl)&"""",""""&d1&"""",""""&d2&"""")
call arrToxml(0, arr1, d1, intervaltime, itime, trim(bl), prename)
call arrToxml_all(arr1, d1, trim(bl), prename)
else
bl_arr = split(trim(bl),",")
for i = 0 to ubound(bl_arr)
arr2 = arrayremove(0,2,arr,""""&trim(bl_arr(i))&"""",""""&d1&"""",""""&d2&"""")
call arrToxml(i, arr2, d1, intervaltime, itime, trim(bl_arr(i)), prename)
call arrToxml_all(arr2, d1, trim(bl_arr(i)), prename)
next
end if
set ao = nothing
end function
'数组到xml.data.xml
function arrToxml(num, arr, d1, intervaltime, itime, bl, prename)
dim xml, xmlFile, tags, nodeValue, preValue
xmlFile = server.MapPath("temp/" & prename & "_data.xml")
set xml = server.CreateObject("MicroSoft.XMLDom")
xml.Load(xmlFile)
if xml.parseError.errorCode <> 0 then
Response.Write "xml.parseError.errorCode = " & xml.parseError.errorCode
Response.Write "xml.parseError.reason = " & xml.parseError.reason
Response.Write "xml.parseError.line = " & xml.parseError.line
Response.End
end if
for i = 1 to itime - 1
chart_temp = arrayremove(0, 2, arr, """" & trim(bl) & """", """" & formattime(dateadd("s",intervaltime*(i-1),d1)) & """", """" & formattime(dateadd("s",intervaltime*i,d1)) & """")
if ubound(chart_temp,2) <> -1 then
xml.getElementsByTagName("graph")(num).childNodes.item(i-1).text = dotwithonebit(chart_temp(1,ubound(chart_temp,2)),2)
end if
chart_temp = ""
next
xml.save xmlFile
set xml = nothing
end function
'数组到xml.alldata.xml
function arrToxml_all(arr, d1, bl, prename)
dim xml_all, xmlFile_all, i, node_subdata, node_varname, node_value, node_happentime, varname
xmlFile_all = server.MapPath("temp/" & prename & "_alldata.xml")
set xml_all = server.CreateObject("MicroSoft.XMLDom")
xml_all.Load(xmlFile_all)
varname = xml_getVarDesc(replace(bl,"""",""))
if xml_all.parseError.errorCode <> 0 then
Response.Write "xml.parseError.errorCode = " & xml_all.parseError.errorCode
Response.Write "xml.parseError.reason = " & xml_all.parseError.reason
Response.Write "xml.parseError.line = " & xml_all.parseError.line
Response.End
end if
for i = 0 to ubound(arr,2)
set node_subdata = xml_all.createElement("subdata")
set node_varname = xml_all.createElement("varname")
node_varname.text = varname
set node_value = xml_all.createElement("value")
node_value.text = dotwithonebit(arr(1,i),2)
set node_happentime = xml_all.createElement("happentime")
node_happentime.text = replace(arr(2,i),"""","")
node_subdata.appendChild(node_varname)
node_subdata.appendChild(node_value)
node_subdata.appendChild(node_happentime)
xml_all.getElementsByTagName("data")(0).appendChild(node_subdata)
next
xml_all.save xmlFile_all
set xml_all = nothing
end function
function xml_getVarDesc(varName)
dim rsxml, desc, sql
sql = "select description from t_dev_variant where varname = '" & varName & "'"
set rsxml = server.CreateObject("adodb.recordset")
rsxml.open sql, conn, 1, 1
if rsxml.bof and rsxml.eof then
desc = ""
else
desc = rsxml("description")
end if
xml_getVarDesc = desc
rsxml.close
set rsxml = nothing
end function
function xml_getUnit(varName)
dim rsxml, str, sql
sql = "select unit from t_dev_variant where varname = '" & varName & "'"
set rsxml = server.CreateObject("adodb.recordset")
rsxml.open sql, conn, 1, 1
if rsxml.bof and rsxml.eof then
str = ""
else
str = rsxml(0)
end if
xml_getUnit = rsxml(0)
set rsxml = nothing
end function
function dotwithonebit(d,n)
dim od, odstr
if isNumeric(d) and instr(d,".") > 0 then
odstr = split(d,".")
od = odstr(0) & "." & left(odstr(1),n)
else
od = d
end if
dotwithonebit = od
end function
%>