PermissionsDlg.cs 9.7 KB

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