CMQueryDlg.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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 SamplesCommon;
  14. using cognosdotnet_10_2;
  15. namespace CMQuery
  16. {
  17. /// <summary>
  18. /// Summary description for CMQueryDlg.
  19. /// </summary>
  20. public class CMQueryDlg : System.Windows.Forms.Form
  21. {
  22. private System.Windows.Forms.MainMenu mainMenu1;
  23. private System.Windows.Forms.MenuItem menuItemFile;
  24. private System.Windows.Forms.MenuItem menuItemExit;
  25. private System.Windows.Forms.MenuItem menuItemHelp;
  26. private System.Windows.Forms.MenuItem menuItemAbout;
  27. private System.Windows.Forms.Label ServerUrlLBL;
  28. private System.Windows.Forms.Button buttonExecuteQuery;
  29. private System.Windows.Forms.RichTextBox resultsDisplayWindowRTB;
  30. private IContainer components;
  31. private System.Windows.Forms.TextBox searchPathTB;
  32. private static contentManagerService1 cBIServer = null;
  33. private string userName = "";
  34. private string userPassword = "";
  35. private System.Windows.Forms.Label searchPathLBL;
  36. private System.Windows.Forms.GroupBox groupBox1;
  37. private System.Windows.Forms.TextBox serverUrlTB;
  38. private string userNamespace = "";
  39. public CMQueryDlg()
  40. {
  41. //
  42. // Required for Windows Form Designer support
  43. //
  44. InitializeComponent();
  45. //
  46. // TODO: Add any constructor code after InitializeComponent call
  47. //
  48. }
  49. /// <summary>
  50. /// Clean up any resources being used.
  51. /// </summary>
  52. protected override void Dispose( bool disposing )
  53. {
  54. if( disposing )
  55. {
  56. if(components != null)
  57. {
  58. components.Dispose();
  59. }
  60. }
  61. base.Dispose( disposing );
  62. }
  63. #region Windows Form Designer generated code
  64. /// <summary>
  65. /// Required method for Designer support - do not modify
  66. /// the contents of this method with the code editor.
  67. /// </summary>
  68. private void InitializeComponent()
  69. {
  70. this.components = new System.ComponentModel.Container();
  71. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CMQueryDlg));
  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.ServerUrlLBL = new System.Windows.Forms.Label();
  78. this.serverUrlTB = new System.Windows.Forms.TextBox();
  79. this.buttonExecuteQuery = new System.Windows.Forms.Button();
  80. this.resultsDisplayWindowRTB = new System.Windows.Forms.RichTextBox();
  81. this.searchPathTB = new System.Windows.Forms.TextBox();
  82. this.searchPathLBL = new System.Windows.Forms.Label();
  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(112, 16);
  123. this.ServerUrlLBL.TabIndex = 0;
  124. this.ServerUrlLBL.Text = "Server URL";
  125. //
  126. // serverUrlTB
  127. //
  128. this.serverUrlTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  129. | System.Windows.Forms.AnchorStyles.Right)));
  130. this.serverUrlTB.BackColor = System.Drawing.SystemColors.Control;
  131. this.serverUrlTB.Location = new System.Drawing.Point(16, 32);
  132. this.serverUrlTB.Name = "serverUrlTB";
  133. this.serverUrlTB.Size = new System.Drawing.Size(440, 20);
  134. this.serverUrlTB.TabIndex = 1;
  135. //
  136. // buttonExecuteQuery
  137. //
  138. this.buttonExecuteQuery.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  139. this.buttonExecuteQuery.Location = new System.Drawing.Point(496, 24);
  140. this.buttonExecuteQuery.Name = "buttonExecuteQuery";
  141. this.buttonExecuteQuery.Size = new System.Drawing.Size(112, 40);
  142. this.buttonExecuteQuery.TabIndex = 2;
  143. this.buttonExecuteQuery.Text = "Execute";
  144. this.buttonExecuteQuery.Click += new System.EventHandler(this.buttonExecuteQuery_Click);
  145. //
  146. // resultsDisplayWindowRTB
  147. //
  148. this.resultsDisplayWindowRTB.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  149. | System.Windows.Forms.AnchorStyles.Left)
  150. | System.Windows.Forms.AnchorStyles.Right)));
  151. this.resultsDisplayWindowRTB.BackColor = System.Drawing.SystemColors.Control;
  152. this.resultsDisplayWindowRTB.Location = new System.Drawing.Point(24, 144);
  153. this.resultsDisplayWindowRTB.Name = "resultsDisplayWindowRTB";
  154. this.resultsDisplayWindowRTB.Size = new System.Drawing.Size(576, 232);
  155. this.resultsDisplayWindowRTB.TabIndex = 3;
  156. this.resultsDisplayWindowRTB.Text = "";
  157. //
  158. // searchPathTB
  159. //
  160. this.searchPathTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  161. | System.Windows.Forms.AnchorStyles.Right)));
  162. this.searchPathTB.Location = new System.Drawing.Point(16, 88);
  163. this.searchPathTB.Name = "searchPathTB";
  164. this.searchPathTB.Size = new System.Drawing.Size(592, 20);
  165. this.searchPathTB.TabIndex = 4;
  166. this.searchPathTB.Text = "/*";
  167. //
  168. // searchPathLBL
  169. //
  170. this.searchPathLBL.Location = new System.Drawing.Point(16, 72);
  171. this.searchPathLBL.Name = "searchPathLBL";
  172. this.searchPathLBL.Size = new System.Drawing.Size(72, 16);
  173. this.searchPathLBL.TabIndex = 5;
  174. this.searchPathLBL.Text = "Search Path";
  175. //
  176. // groupBox1
  177. //
  178. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  179. | System.Windows.Forms.AnchorStyles.Left)
  180. | System.Windows.Forms.AnchorStyles.Right)));
  181. this.groupBox1.Location = new System.Drawing.Point(16, 128);
  182. this.groupBox1.Name = "groupBox1";
  183. this.groupBox1.Size = new System.Drawing.Size(592, 256);
  184. this.groupBox1.TabIndex = 6;
  185. this.groupBox1.TabStop = false;
  186. this.groupBox1.Text = "Results Display Window";
  187. //
  188. // CMQueryDlg
  189. //
  190. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  191. this.ClientSize = new System.Drawing.Size(624, 398);
  192. this.Controls.Add(this.resultsDisplayWindowRTB);
  193. this.Controls.Add(this.groupBox1);
  194. this.Controls.Add(this.searchPathLBL);
  195. this.Controls.Add(this.searchPathTB);
  196. this.Controls.Add(this.serverUrlTB);
  197. this.Controls.Add(this.buttonExecuteQuery);
  198. this.Controls.Add(this.ServerUrlLBL);
  199. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  200. this.Menu = this.mainMenu1;
  201. this.Name = "CMQueryDlg";
  202. this.Text = "Content Manager Query Sample";
  203. this.ResumeLayout(false);
  204. this.PerformLayout();
  205. }
  206. #endregion
  207. private void menuItemExit_Click(object sender, System.EventArgs e)
  208. {
  209. this.Close();
  210. }
  211. private void menuItemAbout_Click(object sender, System.EventArgs e)
  212. {
  213. SamplesAbout about = new SamplesAbout();
  214. about.applicationName = "Capabilities";
  215. about.applicationVersion = "1.1";
  216. about.Show();
  217. }
  218. private void buttonExecuteQuery_Click(object sender, System.EventArgs e)
  219. {
  220. string output = "";
  221. string searchPath = searchPathTB.Text;
  222. if ( (searchPath == null) || (0 == searchPath.CompareTo("")) )
  223. {
  224. MessageBox.Show("Please enter a valid search path");
  225. return;
  226. }
  227. displayMessage("Executing Query...");
  228. CMQuery queryObj = new CMQuery();
  229. output = queryObj.doQuery(cBIServer, searchPath, userName, userPassword, userNamespace, true);
  230. displayMessage(output);
  231. }
  232. public void setConnection(contentManagerService1 cBICMS,
  233. string cBIUrl,
  234. string uname,
  235. string password,
  236. string unamespace)
  237. {
  238. cBIServer = cBICMS;
  239. serverUrlTB.Text = cBIUrl;
  240. userName = uname;
  241. userPassword = password;
  242. userNamespace = unamespace;
  243. }
  244. public void displayMessage(string message)
  245. {
  246. resultsDisplayWindowRTB.AppendText("\n" + message);
  247. }
  248. public void clearDisplayWindow()
  249. {
  250. resultsDisplayWindowRTB.Clear();
  251. }
  252. }
  253. }