【BO-SDK】Update Database information for .rpt &nbsp&nbsp&nbsp&nbsp(BOE SDK Java Applications @_1)

xiangjinling發表於2010-09-06

簡單修改BOE上資料庫連線引數,替代CMC的手動修改,此處不涉及LOV動態列表,非RAS-SDK操作。

【for Java】

[@more@]

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();
}



}

}

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24167472/viewspace-1037952/,如需轉載,請註明出處,否則將追究法律責任。

相關文章