壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1075|回复: 0

[其他] 《原创》给大家共享一下mstr读取folder和report并树形显示的代码

[复制链接]
发表于 2010/8/2 13:15:53 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
如下是我的代码,给大家分享一下,哈哈!
链接可以到报表的提示页面,然后显示报表,或者压缩报表内容邮件发送出去。

  1. <%@ page contentType="text/html; charset=GBK"%>
  2. <%@page import="com.microstrategy.web.objects.*"%>
  3. <%@page import="com.microstrategy.webapi.*"%>
  4. <%
  5. WebFolder rootFolder = null;
  6. String sharedReportsFolderID = "";
  7. //Create a session using
  8. //create factory object
  9. WebObjectsFactory factory=WebObjectsFactory.getInstance();
  10. WebIServerSession serverSession=factory.getIServerSession();
  11. WebObjectSource objectSource=factory.getObjectSource();
  12. serverSession.setServerName ( "" );
  13. serverSession.setServerPort ( 0 );
  14. serverSession.setProjectName ( "" );
  15. serverSession.setLogin ( "" );
  16. serverSession.setPassword ( "" );
  17. try
  18. {
  19. serverSession.getSessionID();
  20. }
  21. catch ( WebObjectsException ex )
  22. {
  23. out.println("Session created with ID ERROR: "+ex.getMessage());
  24. return;
  25. }
  26. WebObjectSource objSource = factory.getObjectSource();
  27. try {
  28. sharedReportsFolderID = objSource.getFolderID(EnumDSSXMLFolderNames.DssXmlFolderNamePublicReports);
  29. rootFolder = (WebFolder) objSource.getObject(sharedReportsFolderID, EnumDSSXMLObjectTypes.DssXmlTypeFolder);
  30. rootFolder.setBlockBegin(1);
  31. rootFolder.setBlockCount(50);
  32. rootFolder.populate();
  33. if (rootFolder.size() == 0)
  34. {
  35. out.println("此项目下没有报表!");
  36. serverSession.closeSession();
  37. return;
  38. }
  39. for (int i = 0; i < rootFolder.size(); i++) {
  40. String objectType = null;
  41. switch (rootFolder.get(i).getType()) {
  42. case EnumDSSXMLObjectTypes.DssXmlTypeFolder:
  43. objectType = "Folder";
  44. break;
  45. case EnumDSSXMLObjectTypes.DssXmlTypeReportDefinition:
  46. objectType = "Report";
  47. break;
  48. case EnumDSSXMLObjectTypes.DssXmlTypeDocumentDefinition:
  49. objectType = "Document";
  50. break;
  51. case EnumDSSXMLObjectTypes.DssXmlTypeFilter:
  52. objectType = "Filter";
  53. break;
  54. case EnumDSSXMLObjectTypes.DssXmlTypeTemplate:
  55. objectType = "Template";
  56. break;
  57. }
  58. out.println(objectType + ": " + rootFolder.get(i).getName()+"<br>");
  59. WebFolder childFolder = (WebFolder)rootFolder.get(i);
  60. childFolder.setBlockBegin(1);
  61. childFolder.setBlockCount(50);
  62. childFolder.populate();
  63. for (int j = 0; j < childFolder.size(); j++)
  64. {
  65. WebObjectInfo reportObject = childFolder.get(j);
  66. String reportIDUrl = "<a href='aaa_download.jsp?rid="+reportObject.getID()+"&rname="+reportObject.getName()+"'>";
  67. reportIDUrl = reportIDUrl + reportObject.getName()+"</a><br>";
  68. out.println(reportIDUrl);
  69. }
  70. }
  71. }
  72. catch (WebObjectsException ex) {
  73. out.println(ex.getMessage());
  74. }
  75. finally
  76. {
  77. serverSession.closeSession();
  78. }
  79. %>
复制代码

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/29 12:21 , Processed in 0.011510 second(s), 14 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表