欢迎光临
我们一直在努力

ASP Call Crystal Report with Store Procedure(6)

建站超值云服务器,限时71元/月

rptserver.asp

case "srch"

call retrieveobjects

call checkforerror

create page variable

gvpagenumber = cint(page)

select case vfmt

case "encp"

if gopagegenerator.findtext(text, 0, gvpagenumber) then

response.contenttype = emfmimetype

session("oemf").sendpagenumberrecord(gvpagenumber)

else

gserrortext = "the specified text, " & text & " was not found in the report"

response.contenttype = emfmimetype

session("oemf").senderrormsg 33, gserrortext

end if

case "html_frame"

we are being called by html viewer

need to get the text from the form post

dim searchfound

text = request.form("text")

now find out what page the text is on

tempnumber = gvpagenumber + 1

if(cbool(gopagegenerator.findtext(text, 0, tempnumber))) then

session("currentpagenumber") = tempnumber

searchfound = 1

else

session("currentpagenumber") = gvpagenumber

searchfound = 0

end if

if brch <> "" then

gvurl = "framepage.asp?brch=" & brch & "&searchfound=" & searchfound

else

gvurl = "framepage.asp?searchfound=" & searchfound

end if

response.redirect gvurl

case "html_page"

we are being called by html viewer

need to get the text from the form post

text = request.form("text")

now find out what page the text is on

tempnumber = gvpagenumber

if(cbool(gopagegenerator.findtext(text, 0, tempnumber))) then

gvpagenumber = tempnumber

set gopage = gopagecollection(gvpagenumber)

session("opageengine").imageoptions = 1

response.binarywrite gopage.renderhtml(1,3,3,request.servervariables("script_name"),8209)

else

send back an html page indicating the text was not found.

response.write "<html><title>seagate asp reports server</title><body bgcolor=white><center><h1>the text cannot be found in this report.</h1></center></body></html>"

end if

end select

case "toolbar_page"

redirect to the framepage, need to know if we are

on the last page.

if session("lastpagenumber") <> "" then

if cint(page) > cint(session("lastpagenumber")) then

session("currentpagenumber") = session("lastpagenumber")

else

session("currentpagenumber") = page

end if

else

call retrieveobjects

call checkforerror

create the actual page

set gopage = gopagecollection(page)

check for an exception on the page number

call validatepagenumber

if gopage.islastpage then

session("lastpagenumber") = gopage.pagenumber

session("currentpagenumber") = session("lastpagenumber")

else

session("currentpagenumber") = page

end if

end if

if brch <> "" then

gvurl = "framepage.asp?brch=" & brch

else

gvurl = "framepage.asp"

end if

response.redirect gvurl

case "export"

set exportoptions = session("orpt").exportoptions

if(fillexportoptionsobject( export_fmt)) then

call retrieveobjects

response.binarywrite gopagegenerator.export(8209)

call checkforerror

else

response.contenttype = emfmimetype

session("oemf").senderrormsg 1, "invalid export type specified"

end if

case "map_dd"

only supported in java and active x smart viewers

select case vfmt

case "encp"

get page collection

call retrieveobjects

call checkforerror

pass the coordinates to the report engine to determine what

branch the drill down goes to.

set gopagegeneratordrillonmap = gopagegenerator.drillonmap(page, glx, gly)

check for an exception because of coordinates

if err.number <> 0 then

gserrortext = "no values exist for selected region of map"

response.contenttype = emfmimetype

session("oemf").senderrormsg 40, gserrortext

err.clear

response.end

end if

pass the group level and group path to helper function to create

the emf message, this tells the viewer where to get the page.

gvgrouppathdd = gopagegeneratordrillonmap.grouppath

gvgroupnamedd = gopagegeneratordrillonmap.groupname

session("oemf").groupname = gvgroupnamedd

response.contenttype = emfmimetype

session("oemf").sendbranchesemf(gvgrouppathdd)

end select

end select

sub retrieveobjects()

this procedure simply retrieves the session objects into global variables.

in the case of out of place subreports, the subrpt parameter must be parsed and the

subreport page generator object must be created.

dim orptoptions report options

dim charindexval,tmpcharindexval

dim tmpstr

dim tmppagegenerator

dim subpagegenerator

dim oopsseqno holds the pages oops sequence number

dim oopssubname holds the oopss name

dim subcoords holds the coordinates of the oops in the main report

dim subgvgrouppath holds the group path for the main report in subrpt parameter

dim mainrptpagenumber holds the page number for the main report in the subrpt parameter

subgvgrouppath = array()

if isobject(session("opageengine")) then

make sure dialogs have been disabled

if subrpt <> "" then

obtain the subreport sequence number

charindexval = findchar(subrpt, ":")

if charindexval > 1 then

oopsseqno = mid(subrpt,1,charindexval – 1)

end if

obtain the subreports name

tmpstr = mid(subrpt,charindexval + 1)

charindexval = findchar(tmpstr, ":")

if charindexval > 1 then

oopssubname = mid(tmpstr,1,charindexval – 1)

end if

tmpstr = mid(tmpstr,charindexval + 1)

charindexval = findchar(tmpstr, ":")

obtain the group path for the out of place subreport

if charindexval > 1 then

subgvgrouppath = createarray(mid(tmpstr, 1, charindexval – 1))

end if

obtain the main report page number after the fourth : character

tmpstr = mid(tmpstr,charindexval + 1)

get the location of the fourth : seperator

charindexval = findchar(tmpstr, ":")

mainrptpagenumber = mid(tmpstr, 1, charindexval – 1)

get the coordinates portion of the subrpt parameter

subcoords = mid(tmpstr, charindexval + 1)

call getdrilldowncoordinates(subcoords, slx, sly)

get the main reports page generator for the view

set tmppagegenerator = session("opageengine").createpagegenerator(subgvgrouppath)

set subpagegenerator = tmppagegenerator.drillonsubreport(mainrptpagenumber, slx, sly)

set gopagegenerator = subpagegenerator.createsubreportpagegenerator(gvgrouppath)

else

set gopagegenerator = session("opageengine").createpagegenerator(gvgrouppath)

end if

set gopagecollection = gopagegenerator.pages

else

must have timed out return an error, you may wan to append to the

iis log here.

if vfmt = "encp" then

response.contenttype = emfmimetype

session("oemf").senderrormsg 1, "user session has expired"

else

response.write "user session has expired"

end if

response.end

end if

end sub

sub parseqs()

parse the query string

cmd = ucase(request.querystring("cmd")) this determines the main function to perform

page = ucase(request.querystring("page")) the page to return

brch = ucase(request.querystring("brch")) the branch is a mechanism to determine the drill down level.

a drill down level is like a view of the report, a new tab

is created to indicate that it is a new view

viewer = ucase(request.querystring("viewer")) this is the viewer that is calling the server

vfmt = ucase(request.querystring("vfmt")) the format that the viewer understands

node = ucase(request.querystring("node"))

grp = ucase(request.querystring("grp")) this is a way of specifing the actual group

coord = ucase(request.querystring("coord")) these are the coordinates on the graph to process

dir = ucase(request.querystring("dir")) this is the search direction

cse = ucase(request.querystring("case")) indicates if the search is case sensitive

text = request.querystring("text") this is the text to search for.

init = ucase(request.querystring("init")) used to build the frames for the html viewer

tab = ucase(request.querystring("tab")) used to keep track of tabs on drill down.

export_fmt = ucase(request.querystring("export_fmt")) used to specify export format and type.

subrpt = ucase(request.querystring("subrpt")) the out of place subreport coordinates.

incomplete_page = cint(request.querystring("incomplete_page")) used to specify whether the page is to contain placeholders.

incomplete_page_count = cint(request.querystring("incomplete_page_count")) used to specify whether the page has to contain a total page count.

pversion = cint(request.querystring("pversion")) used to indicate the protocol version the viewer is utilizing.

ttl_info = ucase(request.querystring("ttl_info"))used to indicate the group path of the totaller request.

initialize variables to a default if they are not provided on the query string.

check for parameter values that are passed by the http post command.

if cmd = "" then

cmd = ucase(request.form("cmd"))

if cmd = "" then

cmd = "get_pg"

end if

end if

if init = "" then

init = ucase(request.form("init"))

end if

if brch = "" then

brch = ucase(request.form("brch"))

end if

if brch = "" and init = "html_frame" then

call initializeframearray

end if

if brch <> "" and init = "html_frame" then

if session("lastbrch") <> brch then

newbrch = "1"

end if

end if

if viewer = "" then

viewer = ucase(request.form("viewer"))

if viewer = "" then

viewer = "html"

end if

end if

if vfmt = "" then

vfmt = ucase(request.form("vfmt"))

if vfmt = "" then

vfmt = "html_page"

end if

end if

if grp = "" then

grp = ucase(request.form("grp"))

end if

if ttl_info = "" then

ttl_info = ucase(request.form("ttl_info"))

end if

if coord = "" then

coord = ucase(request.form("coord"))

end if

if node = "" then

node = ucase(request.form("node"))

end if

if dir = "" then

dir = ucase(request.form("dir"))

if dir = "" then

dir = "for" forward

end if

end if

if cse = "" then

cse = ucase(request.form("case"))

if cse = "" then

cse = "0" case insensitive

end if

end if

if text = "" then

text = request.form("text")

end if

if export_fmt = "" then

export_fmt = ucase(request.form("export_fmt"))

end if

if subrpt = "" then

subrpt = ucase(request.form("subrpt"))

end if

if request.form("incomplete_page") <> "" then

incomplete_page = cint(request.form("incomplete_page"))

end if

if request.form("incomplete_page_count") <> "" then

incomplete_page_count = cint(request.form("incomplete_page_count"))

end if

if pversion = 0 then

pversion = cint(request.form("pversion"))

end if

check to make sure there is a page requested, if not use 1 as a default

if page = "" then

page = ucase(request.form("page"))

if page = "" then

page = "1"

end if

end if

if page <> "" and not isnumeric(page) then

page = "1"

end if

end sub

function createarray(byval vsstringarray)

this function takes an string like 0-1-1-0 and converts

it into an array of integers

dim lvarray

dim lvnewarray

dim licount

dim licurrentpos

dim lsbuf

lvarray = array()

lvnewarray = array()

redim lvarray(256)

listringlength = len(vsstringarray)

licount = 0

licurrentpos = 1

lsbuf = ""

while licurrentpos <= listringlength

ignore this character

if mid(vsstringarray, licurrentpos, 1) <> "-" then

lsbuf = lsbuf & mid(vsstringarray, licurrentpos, 1)

if licurrentpos = listringlength then

lvarray(licount) = cint(lsbuf)

lsbuf = ""

licount = licount + 1

end if

else

lvarray(licount) = cint(lsbuf)

lsbuf = ""

licount = licount + 1

end if

licurrentpos = licurrentpos + 1

wend

redim lvnewarray(licount – 1)

for x = 0 to (licount – 1)

lvnewarray(x) = lvarray(x)

next

createarray = lvnewarray

end function

helper function to parse coordinates passed by viewers and place into independent variables.

sub getdrilldowncoordinates(byval strparam, byref xcoord, byref ycoord)

dim listringlength

dim lbdone

dim lsbuf

listringlength = len(strparam)

lbdone = false

lsbuf = ""

xcoord = ""

ycoord = ""

for x = 1 to listringlength

lsbuf = mid(strparam, x, 1)

ignore this character

if lsbuf = "-" then

lsbuf = ""

lbdone = true

end if

if lbdone then

ycoord = ycoord + lsbuf

else

xcoord = xcoord + lsbuf

end if

next

end sub

this helper procedure will check if the requested page number exists.

if it does not, it will set it to the last available page.

sub validatepagenumber()

if err.number <> 0 then

if err.number = 9 then

just return the last page

page = gopagecollection.count

set gopage = gopagecollection(page)

these session variables are used for the html frame viewer

session("lastpagenumber") = page

session("currentpagenumber") = page

err.clear

else

a more serious error has occurred. error message sent to browser.

call checkforerror

end if

end if

end sub

this helper procedure will send an error msg to the browser based on what viewer is being used.

sub checkforerror()

if err.number <> 0 then

if vfmt = "encp" then

response.contenttype = emfmimetype

session("oemf").senderrormsg 1, "craxdrt error occured on server. " & err.number & " : " & err.description

else

response.write "craxdrt error occured on server. error number: " & err.number & " error description: " & err.description

end if

response.end

end if

end sub

sub initializeframearray()

initialize the html_frame array

set session("tabarray") = nothing

session("lastbrch") = ""

dim tmparray

tmparray = array(4)

redim tmparray(4)

initialize the sequence number

tmparray(0) = "empty"

session("tabarray") = tmparray

end sub

helper function to parse the export_fmt parameter and fill in the properties of the

export object.

function fillexportoptionsobject(export_fmt_options)

dim charindex

dim exporttype

dim exportdllname

charindex = findchar(export_fmt_options,":")

set session("exportoptions") = session("orpt").exportoptions

if(charindex > 0) then

get the export format type value

exporttype = mid(export_fmt_options, charindex + 1)

exportdllname = ucase(mid(export_fmt_options, 1, charindex – 1))

select case exportdllname

case "u2fwordw"

exportoptions.formattype = creftwordforwindows + cint(exporttype)

response.contenttype = "application/msword"

case "u2frtf"

exportoptions.formattype = creftrichtext + cint(exporttype)

response.contenttype = "application/rtf"

case "u2fxls"

exportoptions.formattype = creftexcel21 + cint(exporttype)

response.contenttype = "application/x-msexcel"

case "u2fcr"

exportoptions.formattype = creftcrystalreport + cint(exporttype)

response.contenttype = "application/x-rpt"

case else

fillexportoptionsobject = false

exit function

end select

exportoptions.destinationtype = credtdiskfile

fillexportoptionsobject = true

else

fillexportoptionsobject = false

end if

end function

helper function that returns the index of the character in the given string.

function findchar(findstr, chartofind)

dim lenstr

dim result

lenstr = len(findstr)

result = -1

if(lenstr > 0) then

charcounter = 1

do while(charcounter <= lenstr)

tmpchar = mid(findstr,charcounter,1)

if(tmpchar = chartofind) then

result = charcounter

exit do

end if

charcounter = charcounter + 1

loop

end if

findchar = result

end function

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP Call Crystal Report with Store Procedure(6)
分享到: 更多 (0)

相关推荐

  • 暂无文章