急!!高分寻找crystal report 中rptserver.asp 的jsp版。(200分)

  • 主题发起人 主题发起人 xuyingfeng
  • 开始时间 开始时间
X

xuyingfeng

Unregistered / Unconfirmed
GUEST, unregistred user!
这是aps的源代码,可是我需要的是jsp版,谁能帮忙啊!!
<%@ Language=VBScript %>
<%
' Copyright ?1997-2002 Crystal Decisions, Inc.
Option Explicit
'Create an instance of the object factory. It is used to create
'report objects more efficiently.
Dim objectFactory
Set objectFactory = Server.CreateObject("CrystalReports.ObjectFactory")
'Check to see if the report has been opened
If Not IsObject(Session("oClientDoc")) then
Dim clientDocument
Set clientDocument = objectFactory.CreateObject("CrystalClientDoc.ReportClientDocument")
Call CheckForError

'Store the clientdo
cument in the session for subsequent requests
Set Session("oClientDoc") = clientDocument

'Support passing the report name in the session or in the URL
Dim reportName
reportName = Session("ReportName")

If reportName = "" then
reportName = Request.QueryString("rpt")
End If

If reportName = "" then
SetEMFError 1, "A report name was not specified"
Session.Abandon
Response.End
End If

'Open the report
clientDocument.Open(reportname)
Call CheckForError
End if
' Handle the command from the viewer
Dim command
command = UCase(GetArgument("cmd"))
Select Case command
Case "GET_PG"
Call GetPage
Case "GET_TTL"
Call GetTotaller
Case "NAV"
Call Navigate
Case "CHRT_DD"
DrillGraph
Case "GET_LPG"
Call GetLastPage
Case "SRCH"
Call SearchText
Case "MAP_DD"
Call DrillMap
Case "RFSH"
Call Refresh
Case "EXPORT"
Call Export
Case "BSRCH"
Call BooleanSearch
End Select
'Get Page
Sub GetPage()
Dim requestContext
Set requestContext = objectFactory.CreateObject("CrystalReports.PageRequestContext")
requestContext.PageNumber = GetPageNumber()
requestContext.RequestContext = CreateBaseContext()
On Error Resume Next

Dim EPF
EPF = Session("oClientDoc").ReportSource.GetPage(requestContext)
If LenB(EPF) > 0 then
Response.ContentType = "application/x-epf" 'EPF MIME Type
Response.AddHeader "CONTENT-LENGTH", LenB(EPF)
Response.BinaryWrite EPF
else
SetEMFError 1, "Unable to generate page."
End If
End Sub
'Get Totaller
Sub GetTotaller()
Dim requestContext
Set requestContext = objectFactory.CreateObject("CrystalReports.TotallerRequestContext")
requestContext.RequestContext = CreateBaseContext()
Dim groupPath
Set groupPath = objectFactory.CreateObject("CrystalReports.GroupPath")
Dim path
path = UCase(GetArgument("TTL_INFO")) 'Used to indicate the group path of the totaller request.

If path <> "" then
groupPath.FromString path
End If
requestContext.RootGroupPath = groupPath
On Error Resume Next
Dim ETF
ETF = Session("oClientDoc").ReportSource.GetTotaller(requestContext)
If LenB(ETF) > 0 then
Response.ContentType = "application/x-etf" 'ETF MIME Type
Response.AddHeader "CONTENT-LENGTH", LenB(ETF)
Response.BinaryWrite ETF
else
SetEMFError 1, "Unable to generate totaller."
End If
End Sub
'Navigate
Sub Navigate()
Dim requestContext
Set requestContext = objectFactory.CreateObject("CrystalReports.FindGroupRequestContext")
requestContext.RequestContext = CreateBaseContext()
Dim groupPath
Set groupPath = objectFactory.CreateObject("CrystalReports.GroupPath")
Dim path
path = UCase(GetArgument("GRP"))
If path <> "" then
groupPath.FromString path
End If
requestContext.GroupPath = groupPath
Dim pageNumber
pageNumber = Session("oClientDoc").ReportSource.FindGroup(requestContext)

SetEMFPageNumber pageNumber
End Sub
'Drill Graph
Sub DrillGraph()
Dim requestContext
Set requestContext = objectFactory.CreateObject("CrystalReports.DrillDownRequestContext")
Dim pageRequestContext
Set pageRequestContext = objectFactory.CreateObject("CrystalReports.PageRequestContext")
pageRequestContext.PageNumber = GetPageNumber()
requestContext.PageRequestContext = pageRequestContext
pageRequestContext.RequestContext = CreateBaseContext()
Dim COORD
COORD = UCase(GetArgument("COORD")) ' these are the coordinates on the graph to process
Dim XPosition, YPosition
Call GetDrillDownCoordinates(COORD, XPosition, YPosition)
requestContext.XPosition = XPosition
requestContext.YPosition = YPosition
On Error Resume Next
Dim totallerNodeID
Set totallerNodeID = Session("oClientDoc").ReportSource.DrillGraph(requestContext)
If IsObject(totallerNodeID) then
Dim groupName, groupPath
groupName = totallerNodeID.GroupName
groupPath = totallerNodeID.GroupPath.ToString
SetEMFGroupInfo groupName, groupPath
else
Err.Clear
SetEMFError 40, "Drilldo
wn not possible."
End If
End Sub
'Drill Map
Sub DrillMap()
Dim requestContext
Set requestContext = objectFactory.CreateObject("CrystalReports.DrillDownRequestContext")
Dim pageRequestContext
Set pageRequestContext = objectFactory.CreateObject("CrystalReports.PageRequestContext")
pageRequestContext.PageNumber = GetPageNumber()
requestContext.PageRequestContext = pageRequestContext
pageRequestContext.RequestContext = CreateBaseContext()
Dim COORD
COORD = UCase(GetArgument("COORD")) ' these are the coordinates on the graph to process
Dim XPosition, YPosition
Call GetDrillDownCoordinates(COORD, XPosition, YPosition)
requestContext.XPosition = XPosition
requestContext.YPosition = YPosition
On Error Resume Next
Dim totallerNodeID
Set totallerNodeID = Session("oClientDoc").ReportSource.DrillMap(requestContext)
If IsObject(totallerNodeID) then
Dim groupName, groupPath
groupName = totallerNodeID.GroupName
groupPath = totallerNodeID.GroupPath.ToString
SetEMFGroupInfo groupName, groupPath
else
Err.Clear
SetEMFError 40, "Drilldo
wn not possible."
End If
End Sub
'Get Last Page
Sub GetLastPage()
Dim requestContext
Set requestContext = objectFactory.CreateObject("CrystalReports.RequestContext")
Set requestContext = CreateBaseContext()

Dim pageNumber
pageNumber = Session("oClientDoc").ReportSource.GetLastPageNumber(requestContext)
SetEMFPageNumber pageNumber
End Sub
'Search Text
Sub SearchText()
Dim requestContext
Set requestContext = objectFactory.CreateObject("CrystalReports.FindTextRequestContext")
Dim pageRequestContext
Set pageRequestContext = objectFactory.CreateObject("CrystalReports.PageRequestContext")
pageRequestContext.PageNumber = GetPageNumber()
requestContext.PageRequestContext = pageRequestContext
pageRequestContext.RequestContext = CreateBaseContext()
requestContext.Text = DecodeUTF8(GetArgument("TEXT"))

Dim searchDirection
searchDirection = GetArgument("DIR")
If UCase(searchDirection) = "FOR" then
requestContext.SearchDirection = 0
else
requestContext.SearchDirection = 1
End If
Dim pageNumber
pageNumber = Session("oClientDoc").ReportSource.FindText(requestContext)

if pageNumber > 0 then
SetEMFPageNumber pageNumber
else
SetEMFError 33, "The specified text, '" &amp;
requestContext.Text &amp;
"' was not found in the report."
End If
End Sub
'Refresh
Sub Refresh()
Session("oClientDoc").ReportSource.Refresh

'The Java Viewer expects an EPF back containing page 1.
'The ActiveX Viewer expects an EMF back.
Dim viewer
viewer = UCase(GetArgument("VIEWER")) ' This is the viewer that is calling the server

If viewer = "JAVA" then
Call GetPage
else
SetEMFError 0, ""
End If
End Sub
'Export
Sub Export()
Dim exportOptions
Set exportOptions = objectFactory.CreateObject("CrystalReports.ExportOptions")
'Determine the export format
Dim fmt
fmt = UCase(GetArgument("EXPORT_FMT")) ' Used to specify export format and type.

Dim charIndex
charIndex = findChar(fmt, ":")

If charIndex > 0 then
Dim exportType
Dim exportDLLName
exportType = Mid(fmt, charIndex + 1)
exportDLLName = UCase(Mid(fmt, 1, charIndex - 1))
Dim startPage, endPage
Select Case exportDLLName
Case "U2FCR"
exportOptions.ExportFormatType = 0 ' Crystal Reports
Response.ContentType = "application/x-rpt"
Case "CRXF_XLS"
Response.ContentType = "application/vnd.ms-excel"
If exportType = "10" then
exportOptions.ExportFormatType = 6 ' Microsoft Excel Data Dump
else
exportOptions.ExportFormatType = 2 ' Microsoft Excel
End If

GetExportPageRange startPage, endPage
If startPage > 0 then
Dim ExcelExportOptions
Set ExcelExportOptions = objectFactory.CreateObject("CrystalReports.ExcelExportFormatOptions")
ExcelExportOptions.StartPageNumber = startPage
ExcelExportOptions.EndPageNumber = endPage

exportOptions.FormatOptions = ExcelExportOptions
End If
Case "CRXF_WORDW"
exportOptions.ExportFormatType = 1 'Microsoft Word
Response.ContentType = "application/msword"

GetExportPageRange startPage, endPage
If startPage > 0 then
Dim WordExportOptions
Set WordExportOptions = objectFactory.CreateObject("CrystalReports.RTFWordExportFormatOptions")
WordExportOptions.StartPageNumber = startPage
WordExportOptions.EndPageNumber = endPage

exportOptions.FormatOptions = WordExportOptions
End If
Case "CRXF_RTF"
exportOptions.ExportFormatType = 3 'RTF
Response.ContentType = "application/rtf"

GetExportPageRange startPage, endPage
If startPage > 0 then
Dim RTFExportOptions
Set RTFExportOptions = objectFactory.CreateObject("CrystalReports.RTFWordExportFormatOptions")
RTFExportOptions.StartPageNumber = startPage
RTFExportOptions.EndPageNumber = endPage

exportOptions.FormatOptions = RTFExportOptions
End If
Case "CRXF_PDF"
exportOptions.ExportFormatType = 5 ' Adobe Acrobat (PDF)
Response.ContentType = "application/pdf"

GetExportPageRange startPage, endPage
If startPage > 0 then
Dim PDFExportOptions
Set PDFExportOptions = objectFactory.CreateObject("CrystalReports.PDFExportFormatOptions")
PDFExportOptions.StartPageNumber = startPage
PDFExportOptions.EndPageNumber = endPage

exportOptions.FormatOptions = PDFExportOptions
End If

'Older Export DLL Names:
Case "U2FWORDW"
exportOptions.ExportFormatType = 1 'Microsoft Word
Response.ContentType = "application/msword"
Case "U2FRTF"
exportOptions.ExportFormatType = 3 'RTF
Response.ContentType = "application/rtf"
Case "U2FXLS"
exportOptions.ExportFormatType = 2 ' Microsoft Excel
Response.ContentType = "application/vnd.ms-excel"
Case "U2FPDF"
exportOptions.ExportFormatType = 5 ' Adobe Acrobat (PDF)
Response.ContentType = "application/pdf"
Case else
SetEMFError 1, "Unknown Export Format"
Exit Sub
End Select
else
SetEMFError 1, "Unknown Export Format"
Exit Sub
End If
Dim requestContext
Set requestContext = CreateBaseContext()
On Error Resume Next
Dim exportContent
exportContent = Session("oClientDoc").ReportSource.Export(exportOptions, requestContext)

If LenB(exportContent) > 0 then
Response.AddHeader "CONTENT-LENGTH", LenB(exportContent)
Response.BinaryWrite exportContent
else
SetEMFError 1, "Export failed."
End If
End Sub
'Boolean Search
Sub BooleanSearch()
SetEMFError 1, "This feature is not supported."
End Sub

Sub GetExportPageRange(ByRef startPage, ByRef endPage)
Dim exportOptions
exportOptions = GetArgument("export_opt")
startPage = 0
endPage = 0

If exportOptions = "" then
Exit Sub
End If
'The export_opt value is formatted as follows:
'[n-m] page n to m
'(-n] first page to n
'[n-) page n to the end
'(-) all pages

Dim i, dashIndex
dashIndex = findChar(exportOptions, "-")
If dashIndex = -1 then
Exit Sub
End If

'Check for a starting page
i = findChar(exportOptions, "[")
If i <> -1 then
startPage = Mid(exportOptions, i + 1, dashIndex - i - 1)
else
startPage = 1
End If

'Check for an ending page
i = findChar(exportOptions, "]")
If i <> -1 then
endPage = Mid(exportOptions, dashIndex + 1, i - dashIndex - 1)
else
endPage = -1
End If
End Sub
Function CreateBaseContext()
Dim baseContext
Set baseContext = objectFactory.CreateObject("CrystalReports.RequestContext")
'Handle the branch information
Dim branches
branches = UCase(GetArgument("BRCH")) ' the branch is a mechanism to determine the drilldo
wn level.
If branches <> "" then
Dim groupPath
Set groupPath = objectFactory.CreateObject("CrystalReports.GroupPath")
groupPath.FromString branches

Dim totallerNodeID
Set totallerNodeID = objectFactory.CreateObject("CrystalReports.TotallerNodeID")
totallerNodeID.GroupPath = groupPath

baseContext.TotallerNodeID = totallerNodeID
End If

'Handle the subreport context
Dim subrpt
subrpt = DecodeUTF8(GetArgument("SUBRPT")) ' The Out of Place Subreport coordinates.

If subrpt <> "" then
Dim charIndexVal, tmpCharIndexVal
Dim tmpStr
Dim OOPSSeqNo 'holds the page's OOPS sequence number
Dim SubName 'holds the subreport name
Dim subCoords 'holds the coordinates of the OOPS in the main report
Dim mainRptPageNumber 'holds the page number for the main report in the subrpt parameter
Dim XPosition, YPosition
Dim subreportGroupPath 'holds the group path for the main report in subrpt parameter

' Obtain the subreport sequence number
charIndexVal = findChar(subrpt, ":")
If charIndexVal > 1 then
OOPSSeqNo = Mid(subrpt, 1, charIndexVal - 1)
End If
' Obtain the subreport's name
tmpStr = Mid(subrpt, charIndexVal + 1)
charIndexVal = findChar(tmpStr, ":")
If charIndexVal > 1 then
SubName = 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
subreportGroupPath = 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, XPosition, YPosition)
'Create the subreport context object and set the values into it
Dim subreportContext
Set subreportContext = objectFactory.CreateObject("CrystalReports.SubreportRequestContext")

subreportContext.SubreportName = SubName
subreportContext.PageNumber = mainRptPageNumber
subreportContext.XPosition = XPosition
subreportContext.YPosition = YPosition
If subreportGroupPath <> "" then

Dim subrptGroupPath
Set subrptGroupPath = objectFactory.CreateObject("CrystalReports.GroupPath")
subrptGroupPath.FromString subreportGroupPath

Dim subrptTotallerNodeID
Set subrptTotallerNodeID = objectFactory.CreateObject("CrystalReports.TotallerNodeID")
subrptTotallerNodeID.GroupPath = subrptGroupPath
subreportContext.TotallerNodeID = subrptTotallerNodeID
End If

baseContext.SubreportRequestContext = subreportContext
End If

'Handle any Selection Formula
Dim sf
sf = GetArgument("sf")
If sf <> "" then
Dim reportStateInfo
Set reportStateInfo = objectFactory.CreateObject("CrystalReports.ReportStateInfo")
reportStateInfo.SelectionFormula = sf

baseContext.ReportStateInfo = reportStateInfo
End If

Set CreateBaseContext = baseContext
End Function
Function GetPageNumber()
Dim pageNumber
pageNumber = UCase(GetArgument("page"))

' Check to make sure there is a page requested, if not use 1 as a default
If pageNumber <> "" And NOT IsNumeric(pageNumber) then
pageNumber = "1"
End If
GetPageNumber = pageNumber
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
Dim x
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
' Helper function that returns the index of the character in the given string.
Function findChar(findStr, charToFind)
Dim lenStr
Dim result
Dim charCounter
Dim tmpChar

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
Exitdo
End If
charCounter = charCounter + 1
Loop
End If

findChar = result
End Function
Sub CheckForEMFHandler()
' The oEMF object is a helper object to create EMFs (Ecapsulated Messages) for the viewers.
' The viewers use EMFs to display errors and navigate to specific pages of the report.
' EMFGEN version 2 is required because it implements the SendBranchesStringEMF method.
If Not IsObject(Session("oEMF")) then
Set Session("oEMF") = Server.CreateObject("CREmfgen.CREmfgen.2")
Call CheckForError
End if
End Sub
Sub SetEMFError(errorCode, errorMessage)
CheckForEMFHandler

Response.ContentType = "application/x-emf" 'EMF MIME Type
Session("oEMF").SendErrorMsg errorCode, errorMessage
End Sub
Sub SetEMFPageNumber(n)
CheckForEMFHandler

Response.ContentType = "application/x-emf" 'EMF MIME Type
Session("oEMF").SendPageNumberRecord n
End Sub
Sub SetEMFGroupInfo(groupName, groupPath)
CheckForEMFHandler
Response.ContentType = "application/x-emf" 'EMF MIME Type
Session("oEMF").GroupName = groupName
Session("oEMF").SendBranchesStringEMF groupPath
End Sub
Sub CheckForError()
If Err.Number <> 0 then
SetEMFError 1, "Error Occured on Server. " &amp;
Err.Number &amp;
" : " &amp;
Err.Description
Response.End
End if
End Sub
Function DecodeUTF8(ByRef s)
If s <> "" then
CheckForEMFHandler

DecodeUTF8 = UCase(session("oEMF").DecodeUTF8String(s))
else
DecodeUTF8 = s
End If
End Function
Function GetArgument(argumentName)
'Preference goes to the Form first, since POST data is the preferred method
'of transmitting variable-length data

Dim t
t = Request.Form(argumentName)

If t = "" then
t = Request.QueryString(argumentName)
End If

GetArgument = t
End Function
%>
 
这是我写的jsp的版的一部分,谁能看出我写的错在那里也可以呀。
<%@ page contentType="application/x-epf;charset=utf-8" %>
<%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportInteractiveViewer" %>
<%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer" %>
<%@ page import="com.crystaldecisions.report.web.viewer.BooleanSearchControl" %>
<%@ page import ="com.crystaldecisions.sdk.occa.report.reportsource.* "%>
<%@ page import ="com.crystaldecisions.sdk.occa.report.application.* "%>
<%@ page import ="com.crystaldecisions.thirdparty.com.ooc.OB.ObjectFactory"%>
<%@ page import ="com.crystaldecisions.sdk.occa.report.data.GroupPath"%>
<%@ page import = "com.crystaldecisions.thirdparty.org.omg.IOP.*"%>
<%@ page import = "java.io.InputStream" %>
<%@ page import = "javax.servlet.jsp.*" %>
<%@include file="jspMethods.jsp" %>
<%!
class APoint{
int X;
int Y;
}
public void GetPage(HttpServletRequest irequest,HttpServletResponse iresponse,HttpSession isession,JspWriter iout) throws Exception{
int d=0;
int EPFlen;
PageRequestContext requestContext = new PageRequestContext(CreateBaseContext(irequest,isession));
requestContext.setPageNumber(Integer.parseInt(GetPageNumber(irequest)));
// On Error Resume Next
InputStream EPF = ((ReportClientDocument)isession.getAttribute("oClientDoc")).getReportSource().getPage(requestContext);
EPFlen = EPF.available();
if (EPFlen>0) {
iresponse.setContentType("application/x-epf");//EPF MIME Type
iresponse.addIntHeader("CONTENT-LENGTH",EPF.available());
byte[] rb = new byte[EPFlen];
EPF.read(rb);
iresponse.setContentLength(EPFlen);
iout.write(new String(rb));
}
else
{
// SetEMFError 1, "Unable to generate page."
}
}
public void GetTotaller(HttpServletRequest irequest,HttpServletResponse iresponse,HttpSession isession,JspWriter iout) throws Exception{
TotallerRequestContext requestContext = new TotallerRequestContext(CreateBaseContext(irequest,isession));
GroupPath groupPath = new GroupPath();
String path = new String();
path = GetArgument("TTL_INFO",irequest).toUpperCase();
//Used to indicate the group path of the totaller request.
if(path.equals("")==false){
groupPath.fromString(path);
}
requestContext.setRootGroupPath(groupPath);
//On Error Resume Next
InputStream ETF;
ETF = ((ReportClientDocument)isession.getAttribute("oClientDoc")).getReportSource().getTotaller(requestContext);
int ETFlen=ETF.available();
if(ETFlen > 0){
iresponse.setContentType("application/x-etf");//ETF MIME Type
iresponse.addIntHeader("CONTENT-LENGTH", ETF.available());
byte[] rb = new byte[ETFlen];
ETF.read(rb);
iresponse.setBufferSize(ETFlen);
iout.write(new String(rb));
}
else
{
//SetEMFError 1, "Unable to generate totaller."
}
}
//Navigate
public void Navigate(HttpServletRequest irequest,HttpSession isession) throws Exception{
FindGroupRequestContext requestContext = new FindGroupRequestContext(CreateBaseContext(irequest,isession));
GroupPath groupPath = new GroupPath();
String path = new String();
path = GetArgument("GRP",irequest).toUpperCase();
if(path.equals("")==false){
groupPath.fromString(path);
}
requestContext.setGroupPath(groupPath);
int pageNumber = ((ReportClientDocument)isession.getAttribute("oClientDoc")).getReportSource().findGroup(requestContext);
//SetEMFPageNumber pageNumber
}
//Drill Graph
public void DrillGraph(HttpServletRequest irequest,HttpSession isession) throws Exception{
PageRequestContext pageRequestContext = new PageRequestContext(CreateBaseContext(irequest,isession));
DrillDownRequestContext requestContext = new DrillDownRequestContext(pageRequestContext);
pageRequestContext.setPageNumber(Integer.parseInt(GetPageNumber(irequest)));
String COORD= new String();
COORD = GetArgument("COORD",irequest).toUpperCase(); // these are the coordinates on the graph to process
int XPosition=0, YPosition=0;
APoint aPoint = new APoint();
aPoint = GetDrillDownCoordinates(COORD);
XPosition = aPoint.X;
YPosition = aPoint.Y;
requestContext.setXPosition(XPosition);
requestContext.setYPosition(YPosition);
// On Error Resume Next
ITotallerNodeID totallerNodeID;
totallerNodeID = ((ReportClientDocument)isession.getAttribute("oClientDoc")).getReportSource().drillGraph(requestContext);
if(totallerNodeID.equals(null)){
String groupName, groupPath;
groupName = totallerNodeID.getGroupName();
groupPath = totallerNodeID.getGroupPath().toString();
//SetEMFGroupInfo groupName, groupPath
}
else
{
//Err.Clear
//SetEMFError 40, "Drilldo
wn not possible."
}
}
//Drill Map
public void DrillMap(HttpServletRequest irequest,HttpSession isession) throws Exception{
PageRequestContext pageRequestContext = new PageRequestContext(CreateBaseContext(irequest,isession));
DrillDownRequestContext requestContext = new DrillDownRequestContext(pageRequestContext);
pageRequestContext.setPageNumber(Integer.parseInt(GetPageNumber(irequest)));
String COORD = new String();
COORD = GetArgument("COORD",irequest).toUpperCase(); // these are the coordinates on the graph to process
int XPosition=0, YPosition=0;
APoint aPoint = new APoint();
aPoint = GetDrillDownCoordinates(COORD);
XPosition = aPoint.X;
YPosition=aPoint.Y;
requestContext.setXPosition(XPosition);
requestContext.setYPosition(YPosition);
//On Error Resume Next
ITotallerNodeID totallerNodeID;
totallerNodeID = ((ReportClientDocument)isession.getAttribute("oClientDoc")).getReportSource().drillGraph(requestContext);
if(totallerNodeID.equals(null)){
String groupName, groupPath;
groupName = totallerNodeID.getGroupName();
groupPath = totallerNodeID.getGroupPath().toString();
//SetEMFGroupInfo groupName, groupPath
}
else
{
//Err.Clear
//SetEMFError 40, "Drilldo
wn not possible."
}
}
//GetLastPage()
public void GetLastPage(HttpServletRequest irequest,HttpSession isession) throws Exception{
RequestContext requestContext = new RequestContext(CreateBaseContext(irequest,isession));
int pageNumber;
pageNumber = ((ReportClientDocument)isession.getAttribute("oClientDoc")).getReportSource().getLastPageNumber(requestContext);
//SetEMFPageNumber pageNumber
}
//Search Text
public void SearchText() throws Exception{
/*
FindTextRequestContext requestContext = new FindTextRequestContext();
PageRequestContext pageRequestContext = new PageRequestContext();
pageRequestContext.setPageNumber(Integer.parseInt(GetPageNumber()));
requestContext.setSubreportRequestContext((ISubreportRequestContext)pageRequestContext);
pageRequestContext = (PageRequestContext)CreateBaseContext();
requestContext.setText(DecodeUTF8(GetArgument("TEXT"));
Dim searchDirection
searchDirection = GetArgument("DIR")
If UCase(searchDirection) = "FOR" then
requestContext.SearchDirection = 0
else
requestContext.SearchDirection = 1
End If
Dim pageNumber
pageNumber = Session("oClientDoc").ReportSource.FindText(requestContext)
if pageNumber > 0 then
SetEMFPageNumber pageNumber
else
SetEMFError 33, "The specified text, '" &amp;
requestContext.Text &amp;
"' was not found in the report."
End If
*/
}
//Refresh
public void Refresh() throws Exception{}
//Export
public void Export() throws Exception{}
//Boolean Search
public void BooleanSearch() throws Exception{}
public void GetExportPageRange(int startPage, int endPage) throws Exception{}
public RequestContext CreateBaseContext(HttpServletRequest irequest,HttpSession isession) throws Exception{
RequestContext baseContext= new RequestContext();
//Handle the branch information
String branches = new String("");
branches = GetArgument("BRCH",irequest).toUpperCase(); // the branch is a mechanism to determine the drilldo
wn level.
if (branches.equals("")==false){
GroupPath groupPath = new GroupPath();
groupPath.fromString(branches);
TotallerNodeID totallerNodeID = new TotallerNodeID();
totallerNodeID.setGroupPath(groupPath);
baseContext.setTotallerNodeID(totallerNodeID);
}
//Handle the subreport context
String subrpt = DecodeUTF8(GetArgument("SUBRPT",irequest));
// ?no decodeUTF8?The Out of Place Subreport coordinates.
if (subrpt.equals("")==false ){
int charIndexVal, tmpCharIndexVal;
String tmpStr;
String OOPSSeqNo; //holds the page's OOPS sequence number
String SubName; //holds the subreport name
String subCoords;
//holds the coordinates of the OOPS in the main report
String mainRptPageNumber;
//holds the page number for the main report in the subrpt parameter
int XPosition=0, YPosition=0;
String subreportGroupPath;
//holds the group path for the main report in subrpt parameter
SubName = new String("");
subreportGroupPath = new String("");
// Obtain the subreport sequence number
charIndexVal = subrpt.indexOf(":");
int d=0;
if(charIndexVal > 1){
System.out.println(d++);
System.out.println(subrpt);
OOPSSeqNo = subrpt.substring(0, charIndexVal - 1);
}
// Obtain the subreport's name
System.out.println(d++);
tmpStr = subrpt.substring(charIndexVal);
charIndexVal = tmpStr.indexOf(":");
if(charIndexVal > 1){
System.out.println(d++);
SubName = tmpStr.substring(0, charIndexVal - 1);
}
System.out.println(d++);
tmpStr = tmpStr.substring(charIndexVal);
charIndexVal = tmpStr.indexOf(":");
// Obtain the group path for the Out of Place Subreport
if(charIndexVal > 1) {
System.out.println(d++);
subreportGroupPath = tmpStr.substring(0, charIndexVal - 1);
}
//Obtain the main report page number after the fourth : character
System.out.println(d++);
tmpStr = tmpStr.substring(charIndexVal);
//Get the location of the fourth : seperator
charIndexVal = tmpStr.indexOf(":");
if(charIndexVal > 1) {
System.out.println(d++);
mainRptPageNumber = tmpStr.substring(0, charIndexVal - 1);
}
System.out.println(d++);
mainRptPageNumber = tmpStr.substring(charIndexVal);
//Get the coordinates portion of the SUBRPT parameter
System.out.println(d++);
subCoords = tmpStr.substring(charIndexVal);
APoint aPoint = new APoint();
aPoint = GetDrillDownCoordinates(subCoords);
XPosition = aPoint.X;
YPosition = aPoint.Y;
//Create the subreport context object and set the values into it
SubreportRequestContext subreportContext = new SubreportRequestContext();
subreportContext.setSubreportName(SubName);
subreportContext.setPageNumber(Integer.parseInt(mainRptPageNumber));
subreportContext.setXOffset(XPosition);
subreportContext.setYOffset(YPosition);
if( subreportGroupPath.equals("")==false){
GroupPath subrptGroupPath = new GroupPath();
subrptGroupPath.fromString(subreportGroupPath);
TotallerNodeID subrptTotallerNodeID = new TotallerNodeID();
subrptTotallerNodeID.setGroupPath(subrptGroupPath);
subreportContext.setTotallerNodeID(subrptTotallerNodeID);
}
baseContext.setSubreportRequestContext(subreportContext);
}
//Handle any Selection Formula
String sf = GetArgument("sf",irequest);
if(sf.equals("")==false){
ReportStateInfo reportStateInfo= new ReportStateInfo();
reportStateInfo.setSelectionFormula(sf);
baseContext.setReportStateInfo(reportStateInfo);
}
return baseContext;
}
public String GetPageNumber(HttpServletRequest irequest) throws Exception{
String pageNumber = new String(GetArgument("page",irequest).toUpperCase());
// Check to make sure there is a page requested, if not use 1 as a default
// if((pageNumber.equals("")==false)){//IsNumeric(pageNumber)
// pageNumber = "1";
// }
return pageNumber;
}
// Helper function to parse coordinates passed by viewers and place into independent variables.
public APoint GetDrillDownCoordinates(String strParam) throws Exception{
System.out.println(strParam);
int liStringLength;
boolean lbDone;
String lsBuf;
int x;
liStringLength = strParam.length();
lbDone = false;
APoint aPoint = new APoint();
lsBuf = "";
String xCoord = "";
String yCoord = "";
for(x = 0;x<liStringLength;x++){
lsBuf = strParam.substring(x, x+1);
//ignore this character
if(lsBuf.equals("-")){
lsBuf = "";
lbDone = true;
}
if (lbDone==true){
yCoord+=lsBuf;
}
else
{
xCoord+=lsBuf;
}
}
aPoint.X = Integer.parseInt(xCoord);
aPoint.Y = Integer.parseInt(yCoord);
return aPoint;
}
public void CheckForEMFHandler(){
// The oEMF object is a helper object to create EMFs (Ecapsulated Messages) for the viewers.
// The viewers use EMFs to display errors and navigate to specific pages of the report.
// EMFGEN version 2 is required because it implements the SendBranchesStringEMF method.
}
public void SetEMFError(int errorCode,String errorMessage){
}
public void SetEMFPageNumber(int n){
}
public void SetEMFGroupInfo(String groupName,String groupPath){
}
public void CheckForError(){
}
public String DecodeUTF8(String s){
return s;
}
public String GetArgument(String argumentName,HttpServletRequest irequest) throws Exception{
String T;
T = irequest.getParameter(argumentName);
if(T==null){
T="s";
}
return T;
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html;
charset=gb2312"></HEAD>
<BODY>
<%
ReportClientDocument clientDocument = new ReportClientDocument();
ReportAppSession reportAppSession = new ReportAppSession();
reportAppSession.setReportAppServer("win2000");
reportAppSession.createService("com.crystaldecisions.sdk.occa.report.application.ReportClientDocument");
reportAppSession.initialize();
clientDocument.initialize(reportAppSession);
session.setAttribute("oClientDoc",clientDocument);
//clientDocument.setReportAppServer("win2000");
String reportName = new String("c:/Program Files/Crystal Decisions/Report Application Server 9/Reports/xtreme/CompanyFinancialInfo.rpt");//
// clientDocument.initServerAgent(true);
clientDocument.open(reportName, 0);//"C://Program Files//Crystal Decisions//Report Application Server 9//Reports//xtreme//Current Inventory Status.rpt"
//Store the clientdo
cument in the session for subsequent requests
// Handle the command from the viewer
String command = new String("");
command = GetArgument("cmd",request).toUpperCase();
if(command.equals("GET_PG")==true){GetPage(request,response,session,out);}
else
if(command.equals("GET_TTL")==true){GetTotaller(request,response,session,out);}
else
if(command.equals("NAV")==true){Navigate(request,session);}
else
if(command.equals("CHRT_DD")==true){DrillGraph(request,session);}
else
if(command.equals("GET_LPG")==true){GetLastPage(request,session);}
else
if(command.equals("SRCH")==true){SearchText();}
else
if(command.equals("MAP_DD")==true){DrillMap(request,session);}
else
if(command.equals("RFSH")==true){Refresh();}
else
if(command.equals("EXPORT")==true){Export();}
else
if(command.equals("BSRCH")==true){BooleanSearch();}
%>
</BODY></HTML>
 
参考
http://www.java-cn.com
 
后退
顶部