CreateDrillThroughTargetDlg.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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.IO;
  10. using System.Drawing;
  11. using System.Collections;
  12. using System.ComponentModel;
  13. using System.Windows.Forms;
  14. using System.Web.Services.Protocols;
  15. using SamplesCommon;
  16. using cognosdotnet_10_2;
  17. namespace CreateDrillThroughTarget
  18. {
  19. /// <summary>
  20. /// Summary description for CreateDrillThroughTargetDlg.
  21. /// </summary>
  22. public class CreateDrillThroughTargetDlg : System.Windows.Forms.Form
  23. {
  24. private System.Windows.Forms.MainMenu mainMenu1;
  25. private System.Windows.Forms.MenuItem menuItemFile;
  26. private System.Windows.Forms.MenuItem menuItemExit;
  27. private System.Windows.Forms.MenuItem menuItemHelp;
  28. private System.Windows.Forms.MenuItem menuItemAbout;
  29. private IContainer components;
  30. private System.Windows.Forms.Button buttonCreateDrillThroughTarget;
  31. private System.Windows.Forms.Label label1;
  32. private System.Windows.Forms.Label reportNameLBL;
  33. private System.Windows.Forms.ComboBox reportListCB;
  34. private AxSHDocVw.AxWebBrowser outputBrowser;
  35. private System.Windows.Forms.TextBox reportSearchPathTB;
  36. private System.Windows.Forms.TextBox serverUrlTB;
  37. private static contentManagerService1 cBIServer = null;
  38. private static reportService1 cBIRS = null;
  39. private ComboBox packageListCB;
  40. private Label packageLabel;
  41. private static SamplesConnect cBIConnection = null;
  42. private CreateDrillThroughTarget dtTarget = new CreateDrillThroughTarget();
  43. public CreateDrillThroughTargetDlg()
  44. {
  45. //
  46. // Required for Windows Form Designer support
  47. //
  48. InitializeComponent();
  49. //
  50. // TODO: Add any constructor code after InitializeComponent call
  51. //
  52. }
  53. /// <summary>
  54. /// Clean up any resources being used.
  55. /// </summary>
  56. protected override void Dispose( bool disposing )
  57. {
  58. if( disposing )
  59. {
  60. if(components != null)
  61. {
  62. components.Dispose();
  63. }
  64. }
  65. base.Dispose( disposing );
  66. }
  67. #region Windows Form Designer generated code
  68. /// <summary>
  69. /// Required method for Designer support - do not modify
  70. /// the contents of this method with the code editor.
  71. /// </summary>
  72. private void InitializeComponent()
  73. {
  74. this.components = new System.ComponentModel.Container();
  75. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CreateDrillThroughTargetDlg));
  76. this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
  77. this.menuItemFile = new System.Windows.Forms.MenuItem();
  78. this.menuItemExit = new System.Windows.Forms.MenuItem();
  79. this.menuItemHelp = new System.Windows.Forms.MenuItem();
  80. this.menuItemAbout = new System.Windows.Forms.MenuItem();
  81. this.buttonCreateDrillThroughTarget = new System.Windows.Forms.Button();
  82. this.label1 = new System.Windows.Forms.Label();
  83. this.serverUrlTB = new System.Windows.Forms.TextBox();
  84. this.reportNameLBL = new System.Windows.Forms.Label();
  85. this.reportListCB = new System.Windows.Forms.ComboBox();
  86. this.outputBrowser = new AxSHDocVw.AxWebBrowser();
  87. this.reportSearchPathTB = new System.Windows.Forms.TextBox();
  88. this.packageListCB = new System.Windows.Forms.ComboBox();
  89. this.packageLabel = new System.Windows.Forms.Label();
  90. ((System.ComponentModel.ISupportInitialize)(this.outputBrowser)).BeginInit();
  91. this.SuspendLayout();
  92. //
  93. // mainMenu1
  94. //
  95. this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  96. this.menuItemFile,
  97. this.menuItemHelp});
  98. //
  99. // menuItemFile
  100. //
  101. this.menuItemFile.Index = 0;
  102. this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  103. this.menuItemExit});
  104. this.menuItemFile.Text = "File";
  105. //
  106. // menuItemExit
  107. //
  108. this.menuItemExit.Index = 0;
  109. this.menuItemExit.Text = "Exit";
  110. this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
  111. //
  112. // menuItemHelp
  113. //
  114. this.menuItemHelp.Index = 1;
  115. this.menuItemHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  116. this.menuItemAbout});
  117. this.menuItemHelp.Text = "Help";
  118. //
  119. // menuItemAbout
  120. //
  121. this.menuItemAbout.Index = 0;
  122. this.menuItemAbout.Text = "About";
  123. this.menuItemAbout.Click += new System.EventHandler(this.menuItemAbout_Click);
  124. //
  125. // buttonCreateDrillThroughTarget
  126. //
  127. this.buttonCreateDrillThroughTarget.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  128. this.buttonCreateDrillThroughTarget.Location = new System.Drawing.Point(560, 136);
  129. this.buttonCreateDrillThroughTarget.Name = "buttonCreateDrillThroughTarget";
  130. this.buttonCreateDrillThroughTarget.Size = new System.Drawing.Size(125, 46);
  131. this.buttonCreateDrillThroughTarget.TabIndex = 0;
  132. this.buttonCreateDrillThroughTarget.Text = "Create Target";
  133. this.buttonCreateDrillThroughTarget.Click += new System.EventHandler(this.buttonCreateDrillThroughTarget_Click);
  134. //
  135. // label1
  136. //
  137. this.label1.Location = new System.Drawing.Point(19, 18);
  138. this.label1.Name = "label1";
  139. this.label1.Size = new System.Drawing.Size(199, 19);
  140. this.label1.TabIndex = 1;
  141. this.label1.Text = "Server URL";
  142. //
  143. // serverUrlTB
  144. //
  145. this.serverUrlTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  146. | System.Windows.Forms.AnchorStyles.Right)));
  147. this.serverUrlTB.BackColor = System.Drawing.SystemColors.Control;
  148. this.serverUrlTB.Location = new System.Drawing.Point(19, 37);
  149. this.serverUrlTB.Name = "serverUrlTB";
  150. this.serverUrlTB.Size = new System.Drawing.Size(666, 22);
  151. this.serverUrlTB.TabIndex = 2;
  152. //
  153. // reportNameLBL
  154. //
  155. this.reportNameLBL.Location = new System.Drawing.Point(19, 125);
  156. this.reportNameLBL.Name = "reportNameLBL";
  157. this.reportNameLBL.Size = new System.Drawing.Size(96, 18);
  158. this.reportNameLBL.TabIndex = 3;
  159. this.reportNameLBL.Text = "Report Name";
  160. //
  161. // reportListCB
  162. //
  163. this.reportListCB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  164. | System.Windows.Forms.AnchorStyles.Right)));
  165. this.reportListCB.Enabled = false;
  166. this.reportListCB.Location = new System.Drawing.Point(19, 155);
  167. this.reportListCB.Name = "reportListCB";
  168. this.reportListCB.Size = new System.Drawing.Size(522, 24);
  169. this.reportListCB.TabIndex = 4;
  170. this.reportListCB.SelectedIndexChanged += new System.EventHandler(this.reportListCB_SelectedIndexChanged);
  171. //
  172. // outputBrowser
  173. //
  174. this.outputBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  175. | System.Windows.Forms.AnchorStyles.Left)
  176. | System.Windows.Forms.AnchorStyles.Right)));
  177. this.outputBrowser.Enabled = true;
  178. this.outputBrowser.Location = new System.Drawing.Point(19, 255);
  179. this.outputBrowser.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("outputBrowser.OcxState")));
  180. this.outputBrowser.Size = new System.Drawing.Size(666, 358);
  181. this.outputBrowser.TabIndex = 5;
  182. //
  183. // reportSearchPathTB
  184. //
  185. this.reportSearchPathTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  186. | System.Windows.Forms.AnchorStyles.Right)));
  187. this.reportSearchPathTB.BackColor = System.Drawing.SystemColors.Control;
  188. this.reportSearchPathTB.Location = new System.Drawing.Point(19, 209);
  189. this.reportSearchPathTB.Name = "reportSearchPathTB";
  190. this.reportSearchPathTB.Size = new System.Drawing.Size(666, 22);
  191. this.reportSearchPathTB.TabIndex = 6;
  192. //
  193. // packageListCB
  194. //
  195. this.packageListCB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  196. | System.Windows.Forms.AnchorStyles.Right)));
  197. this.packageListCB.Location = new System.Drawing.Point(19, 91);
  198. this.packageListCB.MaxDropDownItems = 32;
  199. this.packageListCB.Name = "packageListCB";
  200. this.packageListCB.Size = new System.Drawing.Size(522, 24);
  201. this.packageListCB.Sorted = true;
  202. this.packageListCB.TabIndex = 7;
  203. this.packageListCB.SelectedIndexChanged += new System.EventHandler(this.packageListCB_SelectedIndexChanged);
  204. //
  205. // packageLabel
  206. //
  207. this.packageLabel.Location = new System.Drawing.Point(19, 67);
  208. this.packageLabel.Name = "packageLabel";
  209. this.packageLabel.Size = new System.Drawing.Size(65, 21);
  210. this.packageLabel.TabIndex = 8;
  211. this.packageLabel.Text = "Package";
  212. //
  213. // CreateDrillThroughTargetDlg
  214. //
  215. this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
  216. this.ClientSize = new System.Drawing.Size(704, 629);
  217. this.Controls.Add(this.packageLabel);
  218. this.Controls.Add(this.packageListCB);
  219. this.Controls.Add(this.reportSearchPathTB);
  220. this.Controls.Add(this.serverUrlTB);
  221. this.Controls.Add(this.outputBrowser);
  222. this.Controls.Add(this.reportListCB);
  223. this.Controls.Add(this.reportNameLBL);
  224. this.Controls.Add(this.label1);
  225. this.Controls.Add(this.buttonCreateDrillThroughTarget);
  226. this.Menu = this.mainMenu1;
  227. this.Name = "CreateDrillThroughTargetDlg";
  228. this.Text = "Create DrillThrough Target Sample";
  229. ((System.ComponentModel.ISupportInitialize)(this.outputBrowser)).EndInit();
  230. this.ResumeLayout(false);
  231. this.PerformLayout();
  232. }
  233. #endregion
  234. private void menuItemExit_Click(object sender, System.EventArgs e)
  235. {
  236. this.Close();
  237. }
  238. private void menuItemAbout_Click(object sender, System.EventArgs e)
  239. {
  240. SamplesAbout about = new SamplesAbout();
  241. about.applicationName = "CreateDrillThroughTarget Sample";
  242. about.applicationVersion = "1.1";
  243. about.Show();
  244. }
  245. private void buttonCreateDrillThroughTarget_Click(object sender, System.EventArgs e)
  246. {
  247. string output = "";
  248. BaseClassWrapper selectedObject = (BaseClassWrapper)reportListCB.SelectedItem;
  249. try
  250. {
  251. if (selectedObject == null)
  252. {
  253. MessageBox.Show("Please select a valid entry.");
  254. return;
  255. }
  256. output = dtTarget.createDrillThrough(cBIConnection, (BaseClassWrapper)selectedObject, packageListCB.SelectedItem.ToString());
  257. displayPage(output);
  258. }
  259. catch(SoapException ex)
  260. {
  261. displayPage("<br>...the operation failed.<br>The following information was returned:<br><br>" +
  262. SamplesException.getExceptionMessage( ex));
  263. return;
  264. }
  265. catch(System.Exception ex)
  266. {
  267. if (0 != ex.Message.CompareTo("INPUT_CANCELLED_BY_USER"))
  268. {
  269. SamplesException.ShowExceptionMessage( ex.Message, true, "CreateDrillThroughTarget Sample" );
  270. displayPage("\n...the operation failed.\nThe page could not be displayed.");
  271. }
  272. return;
  273. }
  274. }
  275. public void setReportList(BaseClassWrapper[] reportAndQueryList)
  276. {
  277. reportListCB.Items.AddRange(reportAndQueryList);
  278. }
  279. public void setPackageList(string[] packageNameList)
  280. {
  281. packageListCB.Items.AddRange(packageNameList);
  282. }
  283. public void setSelectedPackageIndex(int value)
  284. {
  285. packageListCB.SelectedIndex = value;
  286. }
  287. public void setSelectedReportIndex(int value)
  288. {
  289. reportListCB.SelectedIndex = value;
  290. }
  291. public void setConnection(SamplesConnect connection, string cBIUrl)
  292. {
  293. cBIConnection = connection;
  294. cBIServer = connection.CBICMS;
  295. cBIRS = connection.CBIRS;
  296. serverUrlTB.Text = cBIUrl;
  297. }
  298. public void displayPage(string currentPage)
  299. {
  300. string outputFile = "";
  301. object nullObject = null;
  302. CommonFunctions cf = new CommonFunctions();
  303. outputFile = cf.getSamplesPath();
  304. if (!Directory.Exists(outputFile))
  305. {
  306. // could not access the ...\webcontent\samples directory
  307. // use the current directory instead
  308. outputFile = Directory.GetCurrentDirectory();
  309. }
  310. outputFile += "createDrillThroughTargetOutput.htm";
  311. if (File.Exists(outputFile))
  312. {
  313. File.Delete(outputFile);
  314. }
  315. StreamWriter sw = new StreamWriter(outputFile);
  316. sw.WriteLine(currentPage);
  317. sw.Flush();
  318. sw.Close();
  319. outputBrowser.Navigate(outputFile, ref nullObject, ref nullObject, ref nullObject, ref nullObject);
  320. }
  321. private void reportListCB_SelectedIndexChanged(object sender, System.EventArgs e)
  322. {
  323. BaseClassWrapper selectedObject = (BaseClassWrapper)reportListCB.SelectedItem;
  324. if (selectedObject == null)
  325. {
  326. return;
  327. }
  328. reportSearchPathTB.Text = selectedObject.searchPath.value;
  329. }
  330. private void packageListCB_SelectedIndexChanged(object sender, EventArgs e)
  331. {
  332. try
  333. {
  334. setReportList(dtTarget.getPromptedReports(cBIConnection, packageListCB.SelectedItem.ToString()));
  335. setSelectedReportIndex(0);
  336. reportListCB.Enabled = true;
  337. }
  338. catch (SoapException soapEx)
  339. {
  340. displayPage("<br>...the operation failed.<br>The following information was returned by The IBM Cognos Server:<br><br>" +
  341. SamplesException.getExceptionMessage(soapEx));
  342. }
  343. }
  344. }
  345. }