CapabilitiesDlg.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 Capabilities
  17. {
  18. /// <summary>
  19. /// Summary description for CapabilitiesDlg.
  20. /// </summary>
  21. public class CapabilitiesDlg : System.Windows.Forms.Form
  22. {
  23. private System.Windows.Forms.Label label1;
  24. private System.Windows.Forms.Button buttonSetCapabilities;
  25. private System.Windows.Forms.RichTextBox resultsDisplayWindowRTB;
  26. private System.Windows.Forms.MainMenu mainMenu1;
  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 IContainer components;
  32. private System.Windows.Forms.TextBox cmServiceUrlTB;
  33. private System.Windows.Forms.GroupBox groupBox1;
  34. public static contentManagerService1 cmService = null;
  35. public CapabilitiesDlg()
  36. {
  37. //
  38. // Required for Windows Form Designer support
  39. //
  40. InitializeComponent();
  41. //
  42. // TODO: Add any constructor code after InitializeComponent call
  43. //
  44. }
  45. /// <summary>
  46. /// Clean up any resources being used.
  47. /// </summary>
  48. protected override void Dispose( bool disposing )
  49. {
  50. if( disposing )
  51. {
  52. if(components != null)
  53. {
  54. components.Dispose();
  55. }
  56. }
  57. base.Dispose( disposing );
  58. }
  59. #region Windows Form Designer generated code
  60. /// <summary>
  61. /// Required method for Designer support - do not modify
  62. /// the contents of this method with the code editor.
  63. /// </summary>
  64. private void InitializeComponent()
  65. {
  66. this.components = new System.ComponentModel.Container();
  67. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CapabilitiesDlg));
  68. this.label1 = new System.Windows.Forms.Label();
  69. this.cmServiceUrlTB = new System.Windows.Forms.TextBox();
  70. this.buttonSetCapabilities = new System.Windows.Forms.Button();
  71. this.resultsDisplayWindowRTB = new System.Windows.Forms.RichTextBox();
  72. this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
  73. this.menuItemFile = new System.Windows.Forms.MenuItem();
  74. this.menuItemExit = new System.Windows.Forms.MenuItem();
  75. this.menuItemHelp = new System.Windows.Forms.MenuItem();
  76. this.menuItemAbout = new System.Windows.Forms.MenuItem();
  77. this.groupBox1 = new System.Windows.Forms.GroupBox();
  78. this.SuspendLayout();
  79. //
  80. // label1
  81. //
  82. this.label1.Location = new System.Drawing.Point(16, 24);
  83. this.label1.Name = "label1";
  84. this.label1.Size = new System.Drawing.Size(150, 16);
  85. this.label1.TabIndex = 0;
  86. this.label1.Text = "Server URL";
  87. //
  88. // cmServiceUrlTB
  89. //
  90. this.cmServiceUrlTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  91. | System.Windows.Forms.AnchorStyles.Right)));
  92. this.cmServiceUrlTB.BackColor = System.Drawing.SystemColors.Control;
  93. this.cmServiceUrlTB.Location = new System.Drawing.Point(16, 40);
  94. this.cmServiceUrlTB.Name = "cmServiceUrlTB";
  95. this.cmServiceUrlTB.Size = new System.Drawing.Size(432, 20);
  96. this.cmServiceUrlTB.TabIndex = 1;
  97. //
  98. // buttonSetCapabilities
  99. //
  100. this.buttonSetCapabilities.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  101. this.buttonSetCapabilities.Location = new System.Drawing.Point(496, 32);
  102. this.buttonSetCapabilities.Name = "buttonSetCapabilities";
  103. this.buttonSetCapabilities.Size = new System.Drawing.Size(112, 40);
  104. this.buttonSetCapabilities.TabIndex = 2;
  105. this.buttonSetCapabilities.Text = "Set Capabilities";
  106. this.buttonSetCapabilities.Click += new System.EventHandler(this.buttonSetCapabilities_Click);
  107. //
  108. // resultsDisplayWindowRTB
  109. //
  110. this.resultsDisplayWindowRTB.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  111. | System.Windows.Forms.AnchorStyles.Left)
  112. | System.Windows.Forms.AnchorStyles.Right)));
  113. this.resultsDisplayWindowRTB.BackColor = System.Drawing.SystemColors.Control;
  114. this.resultsDisplayWindowRTB.Location = new System.Drawing.Point(24, 120);
  115. this.resultsDisplayWindowRTB.Name = "resultsDisplayWindowRTB";
  116. this.resultsDisplayWindowRTB.Size = new System.Drawing.Size(576, 136);
  117. this.resultsDisplayWindowRTB.TabIndex = 3;
  118. this.resultsDisplayWindowRTB.Text = "";
  119. //
  120. // mainMenu1
  121. //
  122. this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  123. this.menuItemFile,
  124. this.menuItemHelp});
  125. //
  126. // menuItemFile
  127. //
  128. this.menuItemFile.Index = 0;
  129. this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  130. this.menuItemExit});
  131. this.menuItemFile.Text = "File";
  132. //
  133. // menuItemExit
  134. //
  135. this.menuItemExit.Index = 0;
  136. this.menuItemExit.Text = "Exit";
  137. this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
  138. //
  139. // menuItemHelp
  140. //
  141. this.menuItemHelp.Index = 1;
  142. this.menuItemHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  143. this.menuItemAbout});
  144. this.menuItemHelp.Text = "Help";
  145. //
  146. // menuItemAbout
  147. //
  148. this.menuItemAbout.Index = 0;
  149. this.menuItemAbout.Text = "About";
  150. this.menuItemAbout.Click += new System.EventHandler(this.menuItemAbout_Click);
  151. //
  152. // groupBox1
  153. //
  154. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  155. | System.Windows.Forms.AnchorStyles.Left)
  156. | System.Windows.Forms.AnchorStyles.Right)));
  157. this.groupBox1.Location = new System.Drawing.Point(16, 104);
  158. this.groupBox1.Name = "groupBox1";
  159. this.groupBox1.Size = new System.Drawing.Size(592, 168);
  160. this.groupBox1.TabIndex = 5;
  161. this.groupBox1.TabStop = false;
  162. this.groupBox1.Text = "Results Display Window";
  163. //
  164. // CapabilitiesDlg
  165. //
  166. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  167. this.ClientSize = new System.Drawing.Size(624, 289);
  168. this.Controls.Add(this.resultsDisplayWindowRTB);
  169. this.Controls.Add(this.buttonSetCapabilities);
  170. this.Controls.Add(this.cmServiceUrlTB);
  171. this.Controls.Add(this.label1);
  172. this.Controls.Add(this.groupBox1);
  173. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  174. this.Menu = this.mainMenu1;
  175. this.Name = "CapabilitiesDlg";
  176. this.Text = "Capabilities Sample";
  177. this.ResumeLayout(false);
  178. this.PerformLayout();
  179. }
  180. #endregion
  181. private void menuItemExit_Click(object sender, System.EventArgs e)
  182. {
  183. this.Close();
  184. }
  185. private void menuItemAbout_Click(object sender, System.EventArgs e)
  186. {
  187. SamplesAbout about = new SamplesAbout();
  188. about.applicationName = "Capabilities";
  189. about.applicationVersion = "1.0";
  190. about.Show();
  191. }
  192. // This function is the main driver for this sample.
  193. private void buttonSetCapabilities_Click(object sender, System.EventArgs e)
  194. {
  195. string resultMessage = "";
  196. resultsDisplayWindowRTB.Clear();
  197. try
  198. {
  199. Capabilities capObj = new Capabilities();
  200. capObj.setCapabilities(cmService, ref resultMessage);
  201. displayMessage(resultMessage);
  202. }
  203. catch(SoapException ex)
  204. {
  205. displayMessage("\n...the operation failed.\nThe following information was returned by cmService:");
  206. displayMessage(SamplesException.getExceptionMessage( ex));
  207. return;
  208. }
  209. catch(System.Exception ex)
  210. {
  211. if (0 != ex.Message.CompareTo("INPUT_CANCELLED_BY_USER"))
  212. {
  213. SamplesException.ShowExceptionMessage( ex.Message, true, "SetCapabilities Sample" );
  214. }
  215. return;
  216. }
  217. }
  218. public void setConnection(contentManagerService1 cBICMS, string crnUrl)
  219. {
  220. cmService = cBICMS;
  221. cmServiceUrlTB.Text = crnUrl;
  222. }
  223. public void displayMessage(string message)
  224. {
  225. resultsDisplayWindowRTB.AppendText("\n" + message);
  226. }
  227. public void clearDisplayWindow()
  228. {
  229. resultsDisplayWindowRTB.Clear();
  230. }
  231. }
  232. }