【BO-SDK】Update Database information for .rpt (BOE SDK Java Applications @_1)
转载自:http://blog.itpub.net/post/42444/504970 惊翎轩
简单修改BOE上数据库连接参数,替代CMC的手动修改,此处不涉及LOV动态列表,非RAS-SDK操作。
【for Java】
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
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.plugin.desktop.common.IReportLogon;
import com.crystaldecisions.sdk.plugin.desktop.report.IReport;
public class Update_Database_Info {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String username = "Administrator";
String password = "****7";
String cmsName = "pvg*******:6400";
String authType = "secEnterprise";
String reportName = "Sales Dashboard";
IInfoObjects oInfoObjects = null;
IInfoObject oInfoObject = null;
IEnterpriseSession boEnterpriseSession;
try {
boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon(
username, password, cmsName, authType);
IInfoStore boInfoStore = (IInfoStore) boEnterpriseSession
.getService("", "InfoStore");
oInfoObjects = (IInfoObjects) boInfoStore
.query("Select * from CI_INFOOBJECTS Where SI_INSTANCE=0 And SI_NAME='"
+ reportName + "'");// 确切为ID
// oInfoObjects = (IInfoObjects)
// boInfoStore.query("Select * from CI_INFOOBJECTS Where SI_INSTANCE=0 And SI_ID='13399'");
oInfoObject = (IInfoObject) oInfoObjects.get(0);
// cast the InfoObject as a Report Object
IReport oReport = (IReport) oInfoObject;
IReportLogon rptLogon = (IReportLogon) oReport.getReportLogons()
.get(0);
rptLogon.setOriginalDataSource(true);
// rptLogon.setOriginalDataSource(false);
rptLogon.setPromptOnDemandViewing(false);
rptLogon.setUserName("User***");
rptLogon.setPassword("Pass***");
// rptLogon.setCustomUserName("CusUser***");
// rptLogon.setCustomPassword("CusPass***");
boInfoStore.commit(oInfoObjects);
System.out.println(reportName
+ "'s logon information has been reset successfully.");
} catch (SDKException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}