CancelReportDlg.cs 12 KB

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