Move.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2005, 2007
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. // *
  9. // * Move.sln
  10. // *
  11. // * Copyright (C) 2007 Cognos ULC, an IBM Company. All rights reserved.
  12. // * Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  13. // *
  14. // * Description: Moves a report to another location.
  15. using System;
  16. using System.Web.Services.Protocols;
  17. using SamplesCommon;
  18. using cognosdotnet_10_2;
  19. namespace Move
  20. {
  21. /// <summary>
  22. /// Summary description for Move.
  23. /// </summary>
  24. class Move
  25. {
  26. /// <summary>
  27. /// The main entry point for the application.
  28. /// </summary>
  29. ///
  30. public Move(){}
  31. static void Main(string[] args)
  32. {
  33. string cBIUrl = "";
  34. MoveDlg moveDlgObject = new MoveDlg();
  35. contentManagerService1 cmService = null;
  36. SamplesConnect connectDlg = new SamplesConnect();
  37. if (args.GetLength(0) == 0 )
  38. {
  39. // GUI mode
  40. connectDlg.ShowDialog();
  41. if (connectDlg.IsConnectedToCBI() == true)
  42. {
  43. cmService = connectDlg.CBICMS;
  44. cBIUrl = connectDlg.CBIURL;
  45. moveDlgObject.setConnection(cmService, cBIUrl);
  46. moveDlgObject.setReportList(BaseClassWrapper.buildReportQueryList(cmService));
  47. moveDlgObject.setSelectedReportIndex(0);
  48. moveDlgObject.ShowDialog();
  49. }
  50. }
  51. }
  52. public bool doMove(contentManagerService1 cBICMS, string reportPath, string targetPath, ref string resultMessage)
  53. {
  54. if (cBICMS == null)
  55. {
  56. resultMessage = "...the connection is invalid.\n";
  57. }
  58. report rReport = new report();
  59. stringProp reportToMove = new stringProp();
  60. reportToMove.value = reportPath;
  61. rReport.searchPath = reportToMove;
  62. baseClass[] bcaMove = {rReport};
  63. moveOptions cpOptions = new moveOptions();
  64. searchPathSingleObject cmTargetPath = new searchPathSingleObject();
  65. cmTargetPath.Value = targetPath;
  66. // sn_dg_sdk_method_contentManagerService_move_start_0
  67. baseClass[] bcaMoveResults = cBICMS.move(bcaMove, cmTargetPath, cpOptions);
  68. if (bcaMoveResults.GetLength(0) > 0)
  69. {
  70. //the number of successfully copied objects
  71. resultMessage = "...the report has been successfully moved to the target location \"" + targetPath + "\".";
  72. return true;
  73. }
  74. // sn_dg_sdk_method_contentManagerService_move_end_0
  75. else
  76. {
  77. resultMessage = "...moving the report to the target location : \"" + targetPath + "\" failed.";
  78. return false;
  79. }
  80. }
  81. }
  82. }