Guest User

Untitled

a guest
Dec 8th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. import com.crystaldecisions.sdk.framework.*
  2. import="com.crystaldecisions.sdk.exception.SDKException
  3. import="com.crystaldecisions.sdk.occa.infostore.*
  4. import com.businessobjects.rebean.wi.*
  5.  
  6. boolean loginSuccessful = false;
  7. IEnterpriseSession oEnterpriseSession = null;
  8.  
  9. String username = "Administrator";
  10. String password = "MyPassword";
  11. String cmsname = "localhost";
  12. String authenticationType = "secEnterprise";
  13.  
  14. try {
  15. //Log in.
  16. oEnterpriseSession = CrystalEnterprise.getSessionMgr().logon( username, password, cmsname,authenticationType);
  17. if (oEnterpriseSession == null) {
  18.  
  19. } else {
  20. loginSuccessful = true;
  21. }
  22. } catch (SDKException sdkEx) {
  23.  
  24. }
  25.  
  26. if (loginSuccessful) {
  27. IInfoObject oInfoObject = null;
  28.  
  29. String docname = "TestWebi";
  30.  
  31. //Grab the InfoStore from the httpsession
  32. IInfoStore oInfoStore = (IInfoStore) oEnterpriseSession.getService("", "InfoStore");
  33.  
  34. //Query for the report object in the CMS. See the Developer Reference guide for more information the query language.
  35. String query = "SELECT TOP 1 * " +"FROM CI_INFOOBJECTS " + "WHERE SI_INSTANCE = 0 And SI_Kind = 'Webi' " +"AND SI_NAME='" + docname + "'";
  36.  
  37. IInfoObjects oInfoObjects = (IInfoObjects) oInfoStore.query(query);
  38.  
  39. if (oInfoObjects.size() > 0) {
  40. //Retrieve the latest instance of the report
  41. oInfoObject = (IInfoObject) oInfoObjects.get(0);
  42.  
  43. // Initialize the Report Engine
  44. ReportEngines oReportEngines = (ReportEngines) oEnterpriseSession.getService("ReportEngines");
  45. ReportEngine oReportEngine = (ReportEngine) oReportEngines.getService(ReportEngines.ReportEngineType.WI_REPORT_ENGINE);
  46.  
  47. // Openning the document
  48. DocumentInstance oDocumentInstance = oReportEngine.openDocument(oInfoObject.getID());
  49.  
  50. DataProvider oDataProvider = null;
  51.  
  52. //Loop through dataproviders and purge data
  53. for (int i=0; i<oDocumentInstance.getDataProviders().getCount(); i++) {
  54. oDataProvider = oDocumentInstance.getDataProviders().getItem(i);
  55.  
  56. oDataProvider.purge();
  57.  
  58. // This option purges data as well as reset prompt values used during last refresh
  59. //oDataProvider.purge(true);
  60.  
  61. }
  62.  
  63. oDocumentInstance.save();
  64.  
  65. oDocumentInstance.closeDocument();
  66. }
  67.  
  68. oEnterpriseSession.logoff();
  69. }
Add Comment
Please, Sign In to add comment