ReportAndQueryObject.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2005
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. using System;
  9. using cognosdotnet_10_2;
  10. namespace SamplesCommon
  11. {
  12. public class ReportAndQueryObject : baseClass
  13. {
  14. public ReportAndQueryObject()
  15. {
  16. this.defaultName = new tokenProp();
  17. this.searchPath = new stringProp();
  18. this.objectClass = new classEnumProp();
  19. }
  20. public ReportAndQueryObject[] reportAndQueryList = new ReportAndQueryObject[0];
  21. public override string ToString()
  22. {
  23. return this.defaultName.value;
  24. }
  25. public ReportAndQueryObject(contentManagerService1 cBICMS)
  26. {
  27. reportAndQueryList = buildReportQueryList(cBICMS);
  28. }
  29. public ReportAndQueryObject[] getReportAndQueryList(contentManagerService1 cBICMS)
  30. {
  31. return reportAndQueryList;
  32. }
  33. public ReportAndQueryObject[] buildReportQueryList(contentManagerService1 cBICMS)
  34. {
  35. baseClass[] reports = new baseClass[0];
  36. baseClass[] queries = new baseClass[0];
  37. propEnum[] props =
  38. new propEnum[] { propEnum.searchPath, propEnum.defaultName, propEnum.objectClass};
  39. sort[] sortOptions = { new sort() };
  40. sortOptions[0].order = orderEnum.ascending;
  41. sortOptions[0].propName = propEnum.defaultName;
  42. searchPathMultipleObject reportsPath = new searchPathMultipleObject();
  43. reportsPath.Value = "/content//report";
  44. searchPathMultipleObject queriesPath = new searchPathMultipleObject();
  45. queriesPath.Value = "/content//query";
  46. reports =
  47. cBICMS.query(
  48. reportsPath,
  49. props,
  50. sortOptions,
  51. new queryOptions());
  52. queries =
  53. cBICMS.query(
  54. queriesPath,
  55. props,
  56. sortOptions,
  57. new queryOptions());
  58. ReportAndQueryObject[] reportQueryList = new ReportAndQueryObject[reports.GetLength(0) + queries.GetLength(0)];
  59. int nbReports = 0;
  60. int nbQueries = 0;
  61. if ((reports != null) && (reports.GetLength(0) > 0))
  62. {
  63. nbReports = reports.GetLength(0);
  64. for (int i=0; i<nbReports; i++)
  65. {
  66. reportQueryList[i] = new ReportAndQueryObject();
  67. reportQueryList[i].defaultName.value = reports[i].defaultName.value;
  68. reportQueryList[i].searchPath.value = reports[i].searchPath.value;
  69. reportQueryList[i].objectClass.value = reports[i].objectClass.value;
  70. }
  71. }
  72. if ((queries != null) && (queries.GetLength(0) > 0))
  73. {
  74. nbQueries = queries.GetLength(0);
  75. for (int j=0; j<nbQueries; j++)
  76. {
  77. reportQueryList[nbReports+j] = new ReportAndQueryObject();
  78. reportQueryList[nbReports+j].defaultName.value = queries[j].defaultName.value;
  79. reportQueryList[nbReports+j].searchPath.value = queries[j].searchPath.value;
  80. reportQueryList[nbReports+j].objectClass.value = queries[j].objectClass.value;
  81. }
  82. }
  83. return reportQueryList;
  84. }
  85. public string[] getPackageNameList(contentManagerService1 cBICMS)
  86. {
  87. sort[] sortOptions = { new sort() };
  88. sortOptions[0].order = orderEnum.ascending;
  89. sortOptions[0].propName = propEnum.defaultName;
  90. propEnum[] props = new propEnum[] { propEnum.searchPath, propEnum.defaultName };
  91. searchPathMultipleObject packagesPath = new searchPathMultipleObject();
  92. packagesPath.Value = "/content//package";
  93. baseClass[] bc = cBICMS.query(packagesPath, props, sortOptions, new queryOptions());
  94. string[] packageNames = new string[bc.GetLength(0)];
  95. for (int i = 0; i < bc.GetLength(0); i++)
  96. {
  97. packageNames[i] = bc[i].defaultName.value;
  98. }
  99. return packageNames;
  100. }
  101. }
  102. }