ViewPackages.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2005, 2008
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  9. // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  10. //
  11. // Description: This code sample demonstrates how to get information about
  12. // packages using the query method.
  13. //
  14. // Use this method to request objects from Content Manager.
  15. using System;
  16. using System.Text;
  17. using System.Web.Services.Protocols;
  18. using System.Threading;
  19. using System.Windows.Forms;
  20. using SamplesCommon;
  21. using cognosdotnet_10_2;
  22. namespace ViewPackages
  23. {
  24. /// <summary>
  25. /// Demonstrate the query() method.
  26. /// </summary>
  27. class ViewPackages
  28. {
  29. public ViewPackages(){}
  30. static void Main(string[] args)
  31. {
  32. string cBIUrl = "";
  33. contentManagerService1 cBIServer = null;
  34. SamplesConnect connectDlg = new SamplesConnect();
  35. ViewPackagesDlg ViewPackagesDlgObject = new ViewPackagesDlg();
  36. if (args.GetLength(0) == 0 )
  37. {
  38. // GUI mode
  39. connectDlg.ShowDialog();
  40. if (connectDlg.IsConnectedToCBI() == true)
  41. {
  42. cBIServer = connectDlg.CBICMS;
  43. cBIUrl = connectDlg.CBIURL;
  44. ViewPackagesDlgObject.setConnection(cBIServer, cBIUrl);
  45. ViewPackagesDlgObject.ShowDialog();
  46. }
  47. }
  48. }
  49. public bool doViewPackages( contentManagerService1 cBICMS, ref string resultMessage )
  50. {
  51. if (cBICMS == null)
  52. {
  53. resultMessage = "The Server connection provided is not valid.";
  54. return false;
  55. }
  56. StringBuilder output = new StringBuilder();
  57. // Look for all of the packages.
  58. propEnum[] props = new propEnum[] { propEnum.searchPath, propEnum.defaultName };
  59. sort[] s = new sort[]{ new sort() };
  60. s[0].order = orderEnum.ascending;
  61. s[0].propName = propEnum.defaultName;
  62. queryOptions qo = new queryOptions();
  63. searchPathMultipleObject packagePath = new searchPathMultipleObject();
  64. packagePath.Value = "/content//package";
  65. baseClass[] packageList = cBICMS.query( packagePath, props, s, qo );
  66. if( packageList.Length > 0 )
  67. {
  68. foreach( baseClass pack_item in packageList )
  69. {
  70. output.AppendFormat( "\n {0}\n", pack_item.defaultName.value );
  71. output.AppendFormat( " {0}\n", pack_item.searchPath.value );
  72. }
  73. }
  74. else
  75. {
  76. output.Append( "There are currently no published packages.\n" );
  77. }
  78. resultMessage = output.ToString();
  79. return true;
  80. }
  81. }
  82. }