大家好!
本人在用Eclipse中写一个小程序打开在Crystal Report XI Server 是遇到了一个问题!Java代码如下:
package cr;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.occa.managedreports.IReportAppFactory;
import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument;
import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
public class AlwaysRequiredSteps {
public ReportClientDocument Required() throws SDKException{
String cms = "fams-full";
String username = "famsdev";
String password = "fams123";
String auth = "secEnterprise";
String reportName = "bookTest";
IEnterpriseSession enterpriseSession = null;
ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
boolean loggedIn = true;
ReportClientDocument clientDoc = null;
if (enterpriseSession == null){
try{
sessionMgr = CrystalEnterprise.getSessionMgr();
enterpriseSession = sessionMgr.logon(username, password, cms, auth);
} catch (Exception error){
loggedIn = false;
}
if (!loggedIn){
System.out.println("------------Sorry!you could not be logged on to this server!-----------");
return null;
}else{
IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore");
IInfoObjects infoObjects = iStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME='" + reportName + "' And SI_INSTANCE=0");
IInfoObject infoObject = (IInfoObject)infoObjects.get(0);
IReportAppFactory reportAppFactory = (IReportAppFactory) enterpriseSession.getService("RASReportFactory");
System.out.println("-----Opening...");
System.out.println("-----infoObject.Title:"+infoObject.getTitle());
System.out.println("-----java.util.Locale.getDefault:"+java.util.Locale.getDefault());
clientDoc = reportAppFactory.openDocument(infoObject,0,java.util.Locale.getDefault());
System.out.println("-------------clientDoc:"+clientDoc);
}
}
return clientDoc;
}
}
然后在JSP页面调用这个方法!
控制台打印如下:
-----Opening...
-----infoObject.Title:bookTest
-----java.util.Locale.getDefault:zh_CN
Eclipse运行进度条一直卡着不动!调试时显示一直在等待openDocument()这个方法返回值!
这个bookTest.rpt报表可以通过浏览器地址访问InfoView,浏览内容!
小弟不仅是Java程序员的新手,更是Crystal Report的新手,请问这个Crystal Report XI Server要哪些配置的?需要哪些步骤?具体是怎样的?
恳请高手解答,万分感激!!!
------解决方案--------------------
不用这么麻烦
ISessionMgr sm = CrystalEnterprise.getSessionMgr();
IEnterpriseSession enterpriseSession = sm.logon(username, password, cms, authentication);