CopyDlg.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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 System.Drawing;
  10. using System.Collections;
  11. using System.ComponentModel;
  12. using System.Windows.Forms;
  13. using System.Web.Services.Protocols;
  14. using SamplesCommon;
  15. using cognosdotnet_10_2;
  16. namespace Copy
  17. {
  18. /// <summary>
  19. /// Summary description for CopyDlg.
  20. /// </summary>
  21. public class CopyDlg : System.Windows.Forms.Form
  22. {
  23. private System.Windows.Forms.MainMenu mainMenu1;
  24. private System.Windows.Forms.Label CognosURL;
  25. private System.Windows.Forms.Label label1;
  26. private System.Windows.Forms.Button copy;
  27. private System.Windows.Forms.MenuItem menuItemFile;
  28. private System.Windows.Forms.MenuItem menuItemExit;
  29. private System.Windows.Forms.MenuItem menuItemHelp;
  30. private System.Windows.Forms.MenuItem menuItemAbout;
  31. private System.Windows.Forms.ComboBox reportListCB;
  32. private System.Windows.Forms.Label label2;
  33. private System.Windows.Forms.TextBox targetPathTB;
  34. private IContainer components;
  35. private System.Windows.Forms.RichTextBox resultsDisplayWindowRTB;
  36. private System.Windows.Forms.TextBox reportSearchPathTB;
  37. private System.Windows.Forms.GroupBox groupBox1;
  38. private System.Windows.Forms.TextBox serverUrlTB;
  39. private contentManagerService1 cBIServer = null;
  40. public CopyDlg()
  41. {
  42. //
  43. // Required for Windows Form Designer support
  44. //
  45. InitializeComponent();
  46. //
  47. // TODO: Add any constructor code after InitializeComponent call
  48. //
  49. }
  50. /// <summary>
  51. /// Clean up any resources being used.
  52. /// </summary>
  53. protected override void Dispose( bool disposing )
  54. {
  55. if( disposing )
  56. {
  57. if(components != null)
  58. {
  59. components.Dispose();
  60. }
  61. }
  62. base.Dispose( disposing );
  63. }
  64. #region Windows Form Designer generated code
  65. /// <summary>
  66. /// Required method for Designer support - do not modify
  67. /// the contents of this method with the code editor.
  68. /// </summary>
  69. private void InitializeComponent()
  70. {
  71. this.components = new System.ComponentModel.Container();
  72. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CopyDlg));
  73. this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
  74. this.menuItemFile = new System.Windows.Forms.MenuItem();
  75. this.menuItemExit = new System.Windows.Forms.MenuItem();
  76. this.menuItemHelp = new System.Windows.Forms.MenuItem();
  77. this.menuItemAbout = new System.Windows.Forms.MenuItem();
  78. this.CognosURL = new System.Windows.Forms.Label();
  79. this.serverUrlTB = new System.Windows.Forms.TextBox();
  80. this.label1 = new System.Windows.Forms.Label();
  81. this.copy = new System.Windows.Forms.Button();
  82. this.resultsDisplayWindowRTB = new System.Windows.Forms.RichTextBox();
  83. this.reportListCB = new System.Windows.Forms.ComboBox();
  84. this.label2 = new System.Windows.Forms.Label();
  85. this.targetPathTB = new System.Windows.Forms.TextBox();
  86. this.reportSearchPathTB = new System.Windows.Forms.TextBox();
  87. this.groupBox1 = new System.Windows.Forms.GroupBox();
  88. this.SuspendLayout();
  89. //
  90. // mainMenu1
  91. //
  92. this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  93. this.menuItemFile,
  94. this.menuItemHelp});
  95. //
  96. // menuItemFile
  97. //
  98. this.menuItemFile.Index = 0;
  99. this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  100. this.menuItemExit});
  101. this.menuItemFile.Text = "File";
  102. //
  103. // menuItemExit
  104. //
  105. this.menuItemExit.Index = 0;
  106. this.menuItemExit.Text = "Exit";
  107. this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
  108. //
  109. // menuItemHelp
  110. //
  111. this.menuItemHelp.Index = 1;
  112. this.menuItemHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  113. this.menuItemAbout});
  114. this.menuItemHelp.Text = "Help";
  115. //
  116. // menuItemAbout
  117. //
  118. this.menuItemAbout.Index = 0;
  119. this.menuItemAbout.Text = "About";
  120. this.menuItemAbout.Click += new System.EventHandler(this.menuItemAbout_Click);
  121. //
  122. // CognosURL
  123. //
  124. this.CognosURL.Location = new System.Drawing.Point(16, 16);
  125. this.CognosURL.Name = "CognosURL";
  126. this.CognosURL.Size = new System.Drawing.Size(162, 16);
  127. this.CognosURL.TabIndex = 0;
  128. this.CognosURL.Text = "Server URL";
  129. //
  130. // serverUrlTB
  131. //
  132. this.serverUrlTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  133. | System.Windows.Forms.AnchorStyles.Right)));
  134. this.serverUrlTB.BackColor = System.Drawing.SystemColors.Control;
  135. this.serverUrlTB.Location = new System.Drawing.Point(16, 32);
  136. this.serverUrlTB.Name = "serverUrlTB";
  137. this.serverUrlTB.Size = new System.Drawing.Size(600, 20);
  138. this.serverUrlTB.TabIndex = 1;
  139. //
  140. // label1
  141. //
  142. this.label1.Location = new System.Drawing.Point(16, 72);
  143. this.label1.Name = "label1";
  144. this.label1.Size = new System.Drawing.Size(72, 16);
  145. this.label1.TabIndex = 2;
  146. this.label1.Text = "Report Name";
  147. //
  148. // copy
  149. //
  150. this.copy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  151. this.copy.Location = new System.Drawing.Point(520, 160);
  152. this.copy.Name = "copy";
  153. this.copy.Size = new System.Drawing.Size(96, 40);
  154. this.copy.TabIndex = 4;
  155. this.copy.Text = "Copy";
  156. this.copy.Click += new System.EventHandler(this.copy_Click);
  157. //
  158. // resultsDisplayWindowRTB
  159. //
  160. this.resultsDisplayWindowRTB.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  161. | System.Windows.Forms.AnchorStyles.Left)
  162. | System.Windows.Forms.AnchorStyles.Right)));
  163. this.resultsDisplayWindowRTB.BackColor = System.Drawing.SystemColors.Control;
  164. this.resultsDisplayWindowRTB.Location = new System.Drawing.Point(24, 224);
  165. this.resultsDisplayWindowRTB.Name = "resultsDisplayWindowRTB";
  166. this.resultsDisplayWindowRTB.Size = new System.Drawing.Size(592, 136);
  167. this.resultsDisplayWindowRTB.TabIndex = 6;
  168. this.resultsDisplayWindowRTB.Text = "";
  169. //
  170. // reportListCB
  171. //
  172. this.reportListCB.Location = new System.Drawing.Point(16, 88);
  173. this.reportListCB.Name = "reportListCB";
  174. this.reportListCB.Size = new System.Drawing.Size(264, 21);
  175. this.reportListCB.TabIndex = 7;
  176. this.reportListCB.SelectedIndexChanged += new System.EventHandler(this.reportListCB_SelectedIndexChanged);
  177. //
  178. // label2
  179. //
  180. this.label2.Location = new System.Drawing.Point(304, 72);
  181. this.label2.Name = "label2";
  182. this.label2.Size = new System.Drawing.Size(88, 16);
  183. this.label2.TabIndex = 8;
  184. this.label2.Text = "Target Location";
  185. //
  186. // targetPathTB
  187. //
  188. this.targetPathTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  189. | System.Windows.Forms.AnchorStyles.Right)));
  190. this.targetPathTB.Location = new System.Drawing.Point(304, 88);
  191. this.targetPathTB.Name = "targetPathTB";
  192. this.targetPathTB.Size = new System.Drawing.Size(312, 20);
  193. this.targetPathTB.TabIndex = 9;
  194. this.targetPathTB.Text = "CAMID(\"::Anonymous\")/folder[@name=\'My Folders\']";
  195. //
  196. // reportSearchPathTB
  197. //
  198. this.reportSearchPathTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  199. | System.Windows.Forms.AnchorStyles.Right)));
  200. this.reportSearchPathTB.BackColor = System.Drawing.SystemColors.Control;
  201. this.reportSearchPathTB.Location = new System.Drawing.Point(16, 128);
  202. this.reportSearchPathTB.Name = "reportSearchPathTB";
  203. this.reportSearchPathTB.Size = new System.Drawing.Size(600, 20);
  204. this.reportSearchPathTB.TabIndex = 10;
  205. //
  206. // groupBox1
  207. //
  208. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  209. | System.Windows.Forms.AnchorStyles.Left)
  210. | System.Windows.Forms.AnchorStyles.Right)));
  211. this.groupBox1.Location = new System.Drawing.Point(16, 208);
  212. this.groupBox1.Name = "groupBox1";
  213. this.groupBox1.Size = new System.Drawing.Size(608, 160);
  214. this.groupBox1.TabIndex = 11;
  215. this.groupBox1.TabStop = false;
  216. this.groupBox1.Text = "Results Display Window";
  217. //
  218. // CopyDlg
  219. //
  220. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  221. this.ClientSize = new System.Drawing.Size(632, 385);
  222. this.Controls.Add(this.reportSearchPathTB);
  223. this.Controls.Add(this.targetPathTB);
  224. this.Controls.Add(this.serverUrlTB);
  225. this.Controls.Add(this.label2);
  226. this.Controls.Add(this.reportListCB);
  227. this.Controls.Add(this.copy);
  228. this.Controls.Add(this.label1);
  229. this.Controls.Add(this.CognosURL);
  230. this.Controls.Add(this.resultsDisplayWindowRTB);
  231. this.Controls.Add(this.groupBox1);
  232. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  233. this.Menu = this.mainMenu1;
  234. this.Name = "CopyDlg";
  235. this.Text = "Copy Sample";
  236. this.ResumeLayout(false);
  237. this.PerformLayout();
  238. }
  239. #endregion
  240. // This function is the main driver for this sample.
  241. private void copy_Click(object sender, System.EventArgs e)
  242. {
  243. string resultMessage = "";
  244. clearResultsWindow();
  245. BaseClassWrapper selectedObject = (BaseClassWrapper)reportListCB.SelectedItem;
  246. try
  247. {
  248. if (selectedObject == null)
  249. {
  250. MessageBox.Show("Please select a valid entry.");
  251. return;
  252. }
  253. string targetPath = targetPathTB.Text;
  254. if ( (targetPath == null) || (0 == targetPath.CompareTo("")) )
  255. {
  256. MessageBox.Show("Please enter target location.");
  257. return;
  258. }
  259. Copy copyObject = new Copy();
  260. displayMessage("Copying the report : \"" + selectedObject.ToString() + "\" to :" + targetPath);
  261. copyObject.doCopy(cBIServer, selectedObject.searchPath.value, targetPath, ref resultMessage);
  262. displayMessage(resultMessage);
  263. }
  264. catch(SoapException ex)
  265. {
  266. displayMessage("\n...the operation failed.\nThe following information was returned:");
  267. displayMessage(SamplesException.getExceptionMessage( ex));
  268. return;
  269. }
  270. catch(System.Exception ex)
  271. {
  272. if (0 != ex.Message.CompareTo("INPUT_CANCELLED_BY_USER"))
  273. {
  274. SamplesException.ShowExceptionMessage( ex.Message, true, "Copy Sample" );
  275. }
  276. return;
  277. }
  278. }
  279. private void menuItemExit_Click(object sender, System.EventArgs e)
  280. {
  281. this.Close();
  282. }
  283. private void menuItemAbout_Click(object sender, System.EventArgs e)
  284. {
  285. SamplesAbout about = new SamplesAbout();
  286. about.applicationName = "Copy Sample";
  287. about.applicationVersion = "1.1";
  288. about.Show();
  289. }
  290. public void setReportList(BaseClassWrapper[] reportAndQueryList)
  291. {
  292. reportListCB.Items.AddRange(reportAndQueryList);
  293. }
  294. public void setSelectedReportIndex(int value)
  295. {
  296. reportListCB.SelectedIndex = value;
  297. }
  298. public void displayMessage(string message)
  299. {
  300. resultsDisplayWindowRTB.AppendText(message + "\n");
  301. }
  302. public void clearResultsWindow()
  303. {
  304. resultsDisplayWindowRTB.Clear();
  305. }
  306. public void setConnection(contentManagerService1 cBICMS, string cBIUrl)
  307. {
  308. cBIServer = cBICMS;
  309. serverUrlTB.Text = cBIUrl;
  310. }
  311. private void reportListCB_SelectedIndexChanged(object sender, System.EventArgs e)
  312. {
  313. BaseClassWrapper selectedObject = (BaseClassWrapper)reportListCB.SelectedItem;
  314. if (selectedObject == null)
  315. {
  316. return;
  317. }
  318. reportSearchPathTB.Text = selectedObject.searchPath.value;
  319. }
  320. }
  321. }