Copy.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. // *
  9. // * Copy.sln
  10. // *
  11. // * Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  12. // * Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  13. // *
  14. // * Description: Copies a report to another location.
  15. using System;
  16. using SamplesCommon;
  17. using cognosdotnet_10_2;
  18. namespace Copy
  19. {
  20. /// <summary>
  21. /// Summary description for Copy.
  22. /// </summary>
  23. class Copy
  24. {
  25. /// <summary>
  26. /// The main entry point for the application.
  27. /// </summary>
  28. ///
  29. public Copy(){}
  30. static void Main(string[] args)
  31. {
  32. string cBIUrl = "";
  33. contentManagerService1 cBICMS = null;
  34. CopyDlg copyDlgObject = new CopyDlg();
  35. SamplesConnect connectDlg = new SamplesConnect();
  36. if (args.GetLength(0) == 0 )
  37. {
  38. // GUI mode
  39. connectDlg.ShowDialog();
  40. if (connectDlg.IsConnectedToCBI() == true)
  41. {
  42. cBICMS = connectDlg.CBICMS;
  43. cBIUrl = connectDlg.CBIURL;
  44. copyDlgObject.setConnection(cBICMS, cBIUrl);
  45. copyDlgObject.setReportList(BaseClassWrapper.buildReportQueryList(cBICMS));
  46. copyDlgObject.setSelectedReportIndex(0);
  47. copyDlgObject.ShowDialog();
  48. }
  49. }
  50. }
  51. public bool doCopy(contentManagerService1 cBICMS, string reportPath, string targetPath, ref string resultMessage)
  52. {
  53. if (cBICMS == null)
  54. {
  55. resultMessage = "...the Server connection is invalid.\n";
  56. return false;
  57. }
  58. report rReport = new report();
  59. stringProp reportToCopy = new stringProp();
  60. reportToCopy.value = reportPath;
  61. rReport.searchPath = reportToCopy;
  62. baseClass[] bcaCopy = {rReport};
  63. copyOptions cpOptions = new copyOptions();
  64. searchPathSingleObject targetPathSO = new searchPathSingleObject();
  65. targetPathSO.Value = targetPath;
  66. // sn_dg_sdk_method_contentManagerService_copy_start_0
  67. baseClass[] bcaCopyResults = cBICMS.copy(bcaCopy, targetPathSO, cpOptions);
  68. if (bcaCopyResults.GetLength(0) > 0)
  69. {
  70. //returns the number of successfully copied baseClass objects
  71. resultMessage = "...the report has been successfully copied to : " + targetPath + ".\n";
  72. return true;
  73. }
  74. // sn_dg_sdk_method_contentManagerService_copy_end_0
  75. else
  76. {
  77. resultMessage = "...copying the report to : \"" + targetPath + "\" failed.\n";
  78. return false;
  79. }
  80. }
  81. }
  82. }