S
Steven Scaife
Hello
I am creating a reporting system using SQL Server 2000 and ASP, I have
created 4 pages that display the results i want, however the reports take an
average of 20 mins to run and i have been asked to automate them, i decided
to create another ASP page that uses the filesystemobject to create a static
htm file from the main page.
I decided to put all the declarations and includes my main page creation
page, and stripped these from the asp file so i was left with just the body
of the page, i read the body of the page into a variable and tried to do a
replace on the <%= and the %>
htmFile = replace(htmFile, "<%=", " chr(34) &")
htmFile = replace(htmFile, "%>", " & chr(34)")
I also tried doubling the quotes instead of using chr(34) but with either of
them i get unterminated string constant. I want to be able to just read in
the body of the page replacing any <%=%> so that it scales better. I have 4
reports at the moment but this will grow to any number that the business
wants.
As you can see from my code below a solution i have found is to copy the
body text into a variable and escape the string for the insertion of
variables, but as more and more reports get added the messier its going to
get
hopefully i made sense so if anyone knows how to replace the asp tags or a
way of achieving what i want to do i would appreciate the help
almost forgot the reason i am wanting to replace the asp tags is because
when it creates the page it doesn't show any values
my code is as follows
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% option explicit %>
<%
response.expires = "-1000"
'this declaration belongs to the callcentre report
dim dyTotalAppsWrit, dyTotalValueOfApps, dyTotalSourced, dyTotalSumSourced,
dySrceVol, dySrceVal
dim wkTotalAppsWrit, wkTotalValueOfApps, wkTotalSourced, wkTotalSumSourced,
wkSrceVol, wkSrceVal
dim mnTotalAppsWrit, mnTotalValueOfApps, mnTotalSourced, mnTotalSumSourced,
mnSrceVol, mnSrceVal
dim qtTotalAppsWrit, qtTotalValueOfApps, qtTotalSourced, qtTotalSumSourced,
qtSrceVol, qtSrceVal
dim yrTotalAppsWrit, yrTotalValueOfApps, yrTotalSourced, yrTotalSumSourced,
yrSrceVol, yrSrceVal
'this declaration belongs to the LCT BAG Report
dim dyTotalBooked, dyBookingValue, dyBookingFees, dyVisitsVolume,
dyVisitsValue, dyVisitsFees, dySignVolume, dySignValue, dySignFees
dim wkTotalBooked, wkBookingValue, wkBookingFees, wkVisitsVolume,
wkVisitsValue, wkVisitsFees, wkSignVolume, wkSignValue, wkSignFees
dim mnTotalBooked, mnBookingValue, mnBookingFees, mnVisitsVolume,
mnVisitsValue, mnVisitsFees, mnSignVolume, mnSignValue, mnSignFees
dim qtTotalBooked, qtBookingValue, qtBookingFees, qtVisitsVolume,
qtVisitsValue, qtVisitsFees, qtSignVolume, qtSignValue, qtSignFees
dim yrTotalBooked, yrBookingValue, yrBookingFees, yrVisitsVolume,
yrVisitsValue, yrVisitsFees, yrSignVolume, yrSignValue, yrSignFees
'these are needed for the page to function
dim PageTop, CCBagPage, LCTBagPage
%>
<!--#include file="scripts\DBDataScript.asp"-->
<!--#include file="DBArea\loc\location.inc"-->
<!--#include file="include\connection.inc"-->
<%
SetUpPages "Call Centre - BAG Report"
GettheValuesCCBag
CCBagPage = "<table width='950' border='1' cellspacing='0' cellpadding='0'
align='center' style='border-collapse:collapse;'><tr> <td><span
class='style12'>Call Centre </span></td> <td><span
class='style12'>Applications Written Volumes </span></td> <td><span
class='style12'>Applications Written Value </span></td> <td><span
class='style12'>Applications Sourced Volume </span></td> <td><span
class='style13'>%</span></td> <td><span class='style12'>Applications
Sourced Value </span></td> <td><span class='style13'>%</span></td></tr><tr>
<td><span class='style12'>Daily</span></td> <td><span class='style13'>" &
dyTotalAppsWrit & "</span></td><td><span class='style13'>" &
formatcurrency(dyTotalValueOfApps) & "</span></td> <td><span
class='style13'>" & dyTotalSourced & "</span></td> <td width='30px'>" &
dySrceVol & "</td> <td><span class='style13'>" &
formatcurrency(dyTotalSumSourced) & "</span></td> <td width='30px'><span
class='style13'>" & dySrceVal & "</span></td></tr><tr> <td><span
class='style12'>Week To Date </span></td> <td><span class='style13'>" &
wkTotalAppsWrit & "</span></td> <td><span class='style13'>" &
formatcurrency(wkTotalValueOfApps) & "</span></td> <td><span
class='style13'>" & wkTotalSourced & "</span></td> <td width='30px'>" &
wkSrceVol & "</td> <td><span class='style13'>" &
formatcurrency(wkTotalSumSourced) & "</span></td> <td width='30px'><span
class='style13'>" & wkSrceVal & "</span></td></tr><tr> <td><span
class='style12'>Month To Date </span></td> <td><span class='style13'>" &
mnTotalAppsWrit & "</span></td> <td><span class='style13'>" &
formatcurrency(mnTotalValueOfApps) & "</span></td> <td><span
class='style13'>" & mnTotalSourced & "</span></td> <td width='30px'>" &
mnSrceVol & "</td> <td><span class='style13'>" &
formatcurrency(mnTotalSumSourced) & "</span></td> <td width='30px'><span
class='style13'>" & mnSrceVal & "</span></td></tr><tr> <td><span
class='style12'>Quarter To Date </span></td> <td><span class='style13'>" &
qtTotalAppsWrit & "</span></td> <td><span class='style13'>" &
formatcurrency(qtTotalValueOfApps) & "</span></td> <td><span
class='style13'>" & qtTotalSourced & "</span></td> <td width='30px'>" &
qtSrceVol & "</td> <td><span class='style13'>" &
formatcurrency(qtTotalSumSourced) & "</span></td> <td width='30px'><span
class='style13'>" & qtSrceVal & "</span></td></tr><tr> <td><span
class='style12'>Year To Date </span></td> <td><span class='style13'>" &
yrTotalAppsWrit & "</span></td> <td><span class='style13'>" &
formatcurrency(yrTotalValueOfApps) & "</span></td> <td><span
class='style13'>" & yrTotalSourced & "</span></td> <td width='30px'>" &
yrSrceVol & "</td> <td><span class='style13'>" &
formatcurrency(yrTotalSumSourced) & "</span></td> <td width='30px'><span
class='style13'>" & yrSrceVal & "</span></td></tr></table><br /><table
width='950' border='1' cellspacing='0' cellpadding='0' align='center'
style='border-collapse:collapse;'><tr> <td width='166'><span
class='style12'>Call Centre </span></td> <td width='166'><span
class='style12'>Dead - Agent Error Volume </span></td> <td
width='30'>%</td> <td width='166'><span class='style12'>Dead - Agent Error
Value </span></td> <td width='30'><span class='style13'>%</span></td> <td
width='166'><span class='style12'>Dead - Out of Criteria Volume</span></td>
<td width='30'>%</td> <td width='166'>Dead- Out of Criteria Value </td>
<td width='30'>%</td></tr><tr> <td><span class='style12'>Daily</span></td>
<td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td><span class='style13'></span></td> <td
width='40'> </td> <td><span class='style13'></span></td> <td
width='24'> </td> <td width='159'> </td> <td width='43'><span
class='style13'></span></td></tr><tr> <td><span class='style12'>Week To
Date </span></td> <td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td><span class='style13'></span></td>
<td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td> </td> <td> </td> <td><span
class='style13'></span></td></tr><tr> <td><span class='style12'>Month To
Date </span></td> <td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td><span class='style13'></span></td>
<td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td> </td> <td> </td> <td><span
class='style13'></span></td></tr><tr> <td><span class='style12'>Quarter To
Date </span></td> <td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td><span class='style13'></span></td>
<td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td> </td> <td> </td> <td><span
class='style13'></span></td></tr><tr> <td><span class='style12'>Year To
Date </span></td> <td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td><span class='style13'></span></td>
<td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td> </td> <td> </td> <td><span
class='style13'></span></td></tr></table></body></html>"
If makeHtmFile(CCBagPage) Then
response.write "File created Successfully"
Else
response.write "File creation failed : " & err.description
end if
%>
<%
Sub SetUpPages(pageTitle)
PageTop = "<!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><meta http-equiv='Content-Type'
content='text/html; charset=iso-8859-1' />" & _
"<title>" & pageTitle & "</title><link href='styles/style.css'
rel='stylesheet' type='text/css' /></head><body><table width='950'
border='1' cellspacing='0' cellpadding='0' align='center'
style='border-collapse:collapse;'><tr><td colspan='3'><img
src='images/logo.png' /></td></tr> <tr><td colspan='3'><div
align='center'><img src='images/menubar.png' alt='earth logo' width='830'
height='30' /></div></td> </tr> <tr><td colspan='3'> </td></tr>
<tr> <td><span class='style1'>Earth Mortgages - Business at a glance -
report</span></td> <td>Date</td> <td> " &
formatdatetime(now(), vblongdate) & "</td> </tr> <tr><td
colspan='3'> </td></tr></table><br />"
End Sub
%>
<%
Function makeHTMFile(pageBody)
dim htmFile, fso, ts, htmFileName
'set the filename of the htmfile in the format yyyy-mm-dd-ReportTitle
htmFileName = server.MapPath(".") & "\automation\" & year(date) & "-" &
month(date) & "-" & day(date) & "-CallCentreBAG.htm"
set fso = Server.CreateObject("Scripting.FileSystemObject") 'instantiate the
object
'Set ts = fspenTextFile(server.MapPath(".") & "\indextest.asp", 1)
htmFile = pageTop & pageBody 'ts.readall
response.write htmFile 'for debugging purposes
Set ts = fso.CreateTextFile(htmFileName, True) 'create a textfile using the
fso object
ts.write htmFile
ts.close
set fso = nothing
If err.number = 0 Then
makeHTMFile = True
Else
makeHTMFile = False
End If
End Function
%>
I am creating a reporting system using SQL Server 2000 and ASP, I have
created 4 pages that display the results i want, however the reports take an
average of 20 mins to run and i have been asked to automate them, i decided
to create another ASP page that uses the filesystemobject to create a static
htm file from the main page.
I decided to put all the declarations and includes my main page creation
page, and stripped these from the asp file so i was left with just the body
of the page, i read the body of the page into a variable and tried to do a
replace on the <%= and the %>
htmFile = replace(htmFile, "<%=", " chr(34) &")
htmFile = replace(htmFile, "%>", " & chr(34)")
I also tried doubling the quotes instead of using chr(34) but with either of
them i get unterminated string constant. I want to be able to just read in
the body of the page replacing any <%=%> so that it scales better. I have 4
reports at the moment but this will grow to any number that the business
wants.
As you can see from my code below a solution i have found is to copy the
body text into a variable and escape the string for the insertion of
variables, but as more and more reports get added the messier its going to
get
hopefully i made sense so if anyone knows how to replace the asp tags or a
way of achieving what i want to do i would appreciate the help
almost forgot the reason i am wanting to replace the asp tags is because
when it creates the page it doesn't show any values
my code is as follows
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% option explicit %>
<%
response.expires = "-1000"
'this declaration belongs to the callcentre report
dim dyTotalAppsWrit, dyTotalValueOfApps, dyTotalSourced, dyTotalSumSourced,
dySrceVol, dySrceVal
dim wkTotalAppsWrit, wkTotalValueOfApps, wkTotalSourced, wkTotalSumSourced,
wkSrceVol, wkSrceVal
dim mnTotalAppsWrit, mnTotalValueOfApps, mnTotalSourced, mnTotalSumSourced,
mnSrceVol, mnSrceVal
dim qtTotalAppsWrit, qtTotalValueOfApps, qtTotalSourced, qtTotalSumSourced,
qtSrceVol, qtSrceVal
dim yrTotalAppsWrit, yrTotalValueOfApps, yrTotalSourced, yrTotalSumSourced,
yrSrceVol, yrSrceVal
'this declaration belongs to the LCT BAG Report
dim dyTotalBooked, dyBookingValue, dyBookingFees, dyVisitsVolume,
dyVisitsValue, dyVisitsFees, dySignVolume, dySignValue, dySignFees
dim wkTotalBooked, wkBookingValue, wkBookingFees, wkVisitsVolume,
wkVisitsValue, wkVisitsFees, wkSignVolume, wkSignValue, wkSignFees
dim mnTotalBooked, mnBookingValue, mnBookingFees, mnVisitsVolume,
mnVisitsValue, mnVisitsFees, mnSignVolume, mnSignValue, mnSignFees
dim qtTotalBooked, qtBookingValue, qtBookingFees, qtVisitsVolume,
qtVisitsValue, qtVisitsFees, qtSignVolume, qtSignValue, qtSignFees
dim yrTotalBooked, yrBookingValue, yrBookingFees, yrVisitsVolume,
yrVisitsValue, yrVisitsFees, yrSignVolume, yrSignValue, yrSignFees
'these are needed for the page to function
dim PageTop, CCBagPage, LCTBagPage
%>
<!--#include file="scripts\DBDataScript.asp"-->
<!--#include file="DBArea\loc\location.inc"-->
<!--#include file="include\connection.inc"-->
<%
SetUpPages "Call Centre - BAG Report"
GettheValuesCCBag
CCBagPage = "<table width='950' border='1' cellspacing='0' cellpadding='0'
align='center' style='border-collapse:collapse;'><tr> <td><span
class='style12'>Call Centre </span></td> <td><span
class='style12'>Applications Written Volumes </span></td> <td><span
class='style12'>Applications Written Value </span></td> <td><span
class='style12'>Applications Sourced Volume </span></td> <td><span
class='style13'>%</span></td> <td><span class='style12'>Applications
Sourced Value </span></td> <td><span class='style13'>%</span></td></tr><tr>
<td><span class='style12'>Daily</span></td> <td><span class='style13'>" &
dyTotalAppsWrit & "</span></td><td><span class='style13'>" &
formatcurrency(dyTotalValueOfApps) & "</span></td> <td><span
class='style13'>" & dyTotalSourced & "</span></td> <td width='30px'>" &
dySrceVol & "</td> <td><span class='style13'>" &
formatcurrency(dyTotalSumSourced) & "</span></td> <td width='30px'><span
class='style13'>" & dySrceVal & "</span></td></tr><tr> <td><span
class='style12'>Week To Date </span></td> <td><span class='style13'>" &
wkTotalAppsWrit & "</span></td> <td><span class='style13'>" &
formatcurrency(wkTotalValueOfApps) & "</span></td> <td><span
class='style13'>" & wkTotalSourced & "</span></td> <td width='30px'>" &
wkSrceVol & "</td> <td><span class='style13'>" &
formatcurrency(wkTotalSumSourced) & "</span></td> <td width='30px'><span
class='style13'>" & wkSrceVal & "</span></td></tr><tr> <td><span
class='style12'>Month To Date </span></td> <td><span class='style13'>" &
mnTotalAppsWrit & "</span></td> <td><span class='style13'>" &
formatcurrency(mnTotalValueOfApps) & "</span></td> <td><span
class='style13'>" & mnTotalSourced & "</span></td> <td width='30px'>" &
mnSrceVol & "</td> <td><span class='style13'>" &
formatcurrency(mnTotalSumSourced) & "</span></td> <td width='30px'><span
class='style13'>" & mnSrceVal & "</span></td></tr><tr> <td><span
class='style12'>Quarter To Date </span></td> <td><span class='style13'>" &
qtTotalAppsWrit & "</span></td> <td><span class='style13'>" &
formatcurrency(qtTotalValueOfApps) & "</span></td> <td><span
class='style13'>" & qtTotalSourced & "</span></td> <td width='30px'>" &
qtSrceVol & "</td> <td><span class='style13'>" &
formatcurrency(qtTotalSumSourced) & "</span></td> <td width='30px'><span
class='style13'>" & qtSrceVal & "</span></td></tr><tr> <td><span
class='style12'>Year To Date </span></td> <td><span class='style13'>" &
yrTotalAppsWrit & "</span></td> <td><span class='style13'>" &
formatcurrency(yrTotalValueOfApps) & "</span></td> <td><span
class='style13'>" & yrTotalSourced & "</span></td> <td width='30px'>" &
yrSrceVol & "</td> <td><span class='style13'>" &
formatcurrency(yrTotalSumSourced) & "</span></td> <td width='30px'><span
class='style13'>" & yrSrceVal & "</span></td></tr></table><br /><table
width='950' border='1' cellspacing='0' cellpadding='0' align='center'
style='border-collapse:collapse;'><tr> <td width='166'><span
class='style12'>Call Centre </span></td> <td width='166'><span
class='style12'>Dead - Agent Error Volume </span></td> <td
width='30'>%</td> <td width='166'><span class='style12'>Dead - Agent Error
Value </span></td> <td width='30'><span class='style13'>%</span></td> <td
width='166'><span class='style12'>Dead - Out of Criteria Volume</span></td>
<td width='30'>%</td> <td width='166'>Dead- Out of Criteria Value </td>
<td width='30'>%</td></tr><tr> <td><span class='style12'>Daily</span></td>
<td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td><span class='style13'></span></td> <td
width='40'> </td> <td><span class='style13'></span></td> <td
width='24'> </td> <td width='159'> </td> <td width='43'><span
class='style13'></span></td></tr><tr> <td><span class='style12'>Week To
Date </span></td> <td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td><span class='style13'></span></td>
<td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td> </td> <td> </td> <td><span
class='style13'></span></td></tr><tr> <td><span class='style12'>Month To
Date </span></td> <td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td><span class='style13'></span></td>
<td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td> </td> <td> </td> <td><span
class='style13'></span></td></tr><tr> <td><span class='style12'>Quarter To
Date </span></td> <td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td><span class='style13'></span></td>
<td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td> </td> <td> </td> <td><span
class='style13'></span></td></tr><tr> <td><span class='style12'>Year To
Date </span></td> <td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td><span class='style13'></span></td>
<td><span class='style13'></span></td> <td><span
class='style13'></span></td> <td> </td> <td> </td> <td><span
class='style13'></span></td></tr></table></body></html>"
If makeHtmFile(CCBagPage) Then
response.write "File created Successfully"
Else
response.write "File creation failed : " & err.description
end if
%>
<%
Sub SetUpPages(pageTitle)
PageTop = "<!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><meta http-equiv='Content-Type'
content='text/html; charset=iso-8859-1' />" & _
"<title>" & pageTitle & "</title><link href='styles/style.css'
rel='stylesheet' type='text/css' /></head><body><table width='950'
border='1' cellspacing='0' cellpadding='0' align='center'
style='border-collapse:collapse;'><tr><td colspan='3'><img
src='images/logo.png' /></td></tr> <tr><td colspan='3'><div
align='center'><img src='images/menubar.png' alt='earth logo' width='830'
height='30' /></div></td> </tr> <tr><td colspan='3'> </td></tr>
<tr> <td><span class='style1'>Earth Mortgages - Business at a glance -
report</span></td> <td>Date</td> <td> " &
formatdatetime(now(), vblongdate) & "</td> </tr> <tr><td
colspan='3'> </td></tr></table><br />"
End Sub
%>
<%
Function makeHTMFile(pageBody)
dim htmFile, fso, ts, htmFileName
'set the filename of the htmfile in the format yyyy-mm-dd-ReportTitle
htmFileName = server.MapPath(".") & "\automation\" & year(date) & "-" &
month(date) & "-" & day(date) & "-CallCentreBAG.htm"
set fso = Server.CreateObject("Scripting.FileSystemObject") 'instantiate the
object
'Set ts = fspenTextFile(server.MapPath(".") & "\indextest.asp", 1)
htmFile = pageTop & pageBody 'ts.readall
response.write htmFile 'for debugging purposes
Set ts = fso.CreateTextFile(htmFileName, True) 'create a textfile using the
fso object
ts.write htmFile
ts.close
set fso = nothing
If err.number = 0 Then
makeHTMFile = True
Else
makeHTMFile = False
End If
End Function
%>