ContentStoreExplorerDlg.cs 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665
  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.Data;
  10. using System.Drawing;
  11. using System.Threading;
  12. using System.Reflection;
  13. using System.Collections;
  14. using System.ComponentModel;
  15. using System.Windows.Forms;
  16. using System.Web.Services.Protocols;
  17. using SamplesCommon;
  18. using cognosdotnet_10_2;
  19. namespace ContentStoreExplorer
  20. {
  21. /// <summary>
  22. /// Summary description for Form1.
  23. /// </summary>
  24. public class ContentStoreExplorerDlg : System.Windows.Forms.Form
  25. {
  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 System.Windows.Forms.ToolTip toolTip1;
  32. private System.Windows.Forms.Panel locationPanel;
  33. private System.Windows.Forms.ToolBarButton rootButton;
  34. private System.Windows.Forms.ImageList toolBarImageList;
  35. private System.Windows.Forms.ToolBarButton backButton;
  36. private System.Windows.Forms.ToolBarButton nextButton;
  37. private System.Windows.Forms.Label searchPathLBL;
  38. private System.Windows.Forms.ComboBox searchPathCB;
  39. private System.Windows.Forms.Button buttonGO;
  40. private System.Windows.Forms.TreeView navTree;
  41. private System.Windows.Forms.ImageList treeViewImageList;
  42. private System.Windows.Forms.ListView contentListView;
  43. private System.Windows.Forms.ContextMenu listView_ContextMenu;
  44. private System.Windows.Forms.MenuItem menuItemExplore;
  45. private System.Windows.Forms.MenuItem menuItemProperties;
  46. private System.Windows.Forms.MenuItem menuItemView;
  47. private System.Windows.Forms.MenuItem menuItemRefresh;
  48. private System.Windows.Forms.MenuItem menuItemSmallIcons;
  49. private System.Windows.Forms.MenuItem menuItemLargeIcons;
  50. private System.Windows.Forms.MenuItem menuItemList;
  51. private System.Windows.Forms.MenuItem menuItemDetails;
  52. private System.Windows.Forms.ColumnHeader columnHeaderName;
  53. private System.Windows.Forms.ColumnHeader columnHeaderType;
  54. private System.Windows.Forms.ColumnHeader columnHeaderDateModified;
  55. private System.Windows.Forms.ColumnHeader columnHeaderSearchPath;
  56. private System.Windows.Forms.StatusBar statusBar1;
  57. private System.ComponentModel.IContainer components;
  58. private static contentManagerService1 cBIServer = null;
  59. private int navigationArrayIdx = 0;
  60. private ArrayList navigationArray = new ArrayList();
  61. private int previousNodeIdx = 0;
  62. private TreeNode[] previousNodeList = new TreeNode[] {new TreeNode(),
  63. new TreeNode(),
  64. new TreeNode(),
  65. new TreeNode(),
  66. new TreeNode()};
  67. private TreeNode currentNode = null;
  68. private TreeNode rootNode = null;
  69. private bool sitesToolBarEnabled = true;
  70. private static bool isConnected = false;
  71. private static string connectMessage = "";
  72. private baseClass[] cBIBCList = null;
  73. private System.Windows.Forms.MenuItem menuItemSeparator1;
  74. private System.Windows.Forms.Label accountLBL;
  75. private System.Windows.Forms.Panel panel1;
  76. private System.Windows.Forms.Splitter splitter1;
  77. private System.Windows.Forms.Button buttonConnect;
  78. private System.Windows.Forms.Label labelSites;
  79. private System.Windows.Forms.MenuItem menuItemViewSites;
  80. private System.Windows.Forms.MenuItem menuItemSites;
  81. private System.Windows.Forms.ToolBar buttonToolBar;
  82. private System.Windows.Forms.ProgressBar progressBar;
  83. private System.Windows.Forms.ComboBox cBIUrlCB;
  84. private System.Windows.Forms.TextBox serverUrlTB;
  85. private bool doUpdate = true;
  86. public ContentStoreExplorerDlg()
  87. {
  88. //
  89. // Required for Windows Form Designer support
  90. //
  91. InitializeComponent();
  92. //
  93. // TODO: Add any constructor code after InitializeComponent call
  94. //
  95. }
  96. /// <summary>
  97. /// Clean up any resources being used.
  98. /// </summary>
  99. protected override void Dispose( bool disposing )
  100. {
  101. if( disposing )
  102. {
  103. if (components != null)
  104. {
  105. components.Dispose();
  106. }
  107. }
  108. base.Dispose( disposing );
  109. }
  110. #region Windows Form Designer generated code
  111. /// <summary>
  112. /// Required method for Designer support - do not modify
  113. /// the contents of this method with the code editor.
  114. /// </summary>
  115. private void InitializeComponent()
  116. {
  117. this.components = new System.ComponentModel.Container();
  118. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ContentStoreExplorerDlg));
  119. this.mainMenu1 = new System.Windows.Forms.MainMenu();
  120. this.menuItemFile = new System.Windows.Forms.MenuItem();
  121. this.menuItemExit = new System.Windows.Forms.MenuItem();
  122. this.menuItemViewSites = new System.Windows.Forms.MenuItem();
  123. this.menuItemSites = new System.Windows.Forms.MenuItem();
  124. this.menuItemHelp = new System.Windows.Forms.MenuItem();
  125. this.menuItemAbout = new System.Windows.Forms.MenuItem();
  126. this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
  127. this.serverUrlTB = new System.Windows.Forms.TextBox();
  128. this.searchPathLBL = new System.Windows.Forms.Label();
  129. this.searchPathCB = new System.Windows.Forms.ComboBox();
  130. this.buttonToolBar = new System.Windows.Forms.ToolBar();
  131. this.rootButton = new System.Windows.Forms.ToolBarButton();
  132. this.backButton = new System.Windows.Forms.ToolBarButton();
  133. this.nextButton = new System.Windows.Forms.ToolBarButton();
  134. this.toolBarImageList = new System.Windows.Forms.ImageList(this.components);
  135. this.locationPanel = new System.Windows.Forms.Panel();
  136. this.buttonGO = new System.Windows.Forms.Button();
  137. this.navTree = new System.Windows.Forms.TreeView();
  138. this.listView_ContextMenu = new System.Windows.Forms.ContextMenu();
  139. this.menuItemExplore = new System.Windows.Forms.MenuItem();
  140. this.menuItemProperties = new System.Windows.Forms.MenuItem();
  141. this.menuItemSeparator1 = new System.Windows.Forms.MenuItem();
  142. this.menuItemView = new System.Windows.Forms.MenuItem();
  143. this.menuItemSmallIcons = new System.Windows.Forms.MenuItem();
  144. this.menuItemLargeIcons = new System.Windows.Forms.MenuItem();
  145. this.menuItemList = new System.Windows.Forms.MenuItem();
  146. this.menuItemDetails = new System.Windows.Forms.MenuItem();
  147. this.menuItemRefresh = new System.Windows.Forms.MenuItem();
  148. this.treeViewImageList = new System.Windows.Forms.ImageList(this.components);
  149. this.contentListView = new System.Windows.Forms.ListView();
  150. this.columnHeaderName = new System.Windows.Forms.ColumnHeader();
  151. this.columnHeaderType = new System.Windows.Forms.ColumnHeader();
  152. this.columnHeaderDateModified = new System.Windows.Forms.ColumnHeader();
  153. this.columnHeaderSearchPath = new System.Windows.Forms.ColumnHeader();
  154. this.statusBar1 = new System.Windows.Forms.StatusBar();
  155. this.accountLBL = new System.Windows.Forms.Label();
  156. this.panel1 = new System.Windows.Forms.Panel();
  157. this.splitter1 = new System.Windows.Forms.Splitter();
  158. this.cBIUrlCB = new System.Windows.Forms.ComboBox();
  159. this.labelSites = new System.Windows.Forms.Label();
  160. this.buttonConnect = new System.Windows.Forms.Button();
  161. this.progressBar = new System.Windows.Forms.ProgressBar();
  162. this.locationPanel.SuspendLayout();
  163. this.panel1.SuspendLayout();
  164. this.SuspendLayout();
  165. //
  166. // mainMenu1
  167. //
  168. this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  169. this.menuItemFile,
  170. this.menuItemViewSites,
  171. this.menuItemHelp});
  172. //
  173. // menuItemFile
  174. //
  175. this.menuItemFile.Index = 0;
  176. this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  177. this.menuItemExit});
  178. this.menuItemFile.Text = "File";
  179. //
  180. // menuItemExit
  181. //
  182. this.menuItemExit.Index = 0;
  183. this.menuItemExit.Text = "Exit";
  184. this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
  185. //
  186. // menuItemViewSites
  187. //
  188. this.menuItemViewSites.Index = 1;
  189. this.menuItemViewSites.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  190. this.menuItemSites});
  191. this.menuItemViewSites.Text = "View";
  192. //
  193. // menuItemSites
  194. //
  195. this.menuItemSites.Checked = true;
  196. this.menuItemSites.Index = 0;
  197. this.menuItemSites.Text = "Sites";
  198. this.menuItemSites.Click += new System.EventHandler(this.menuItemSites_Click);
  199. //
  200. // menuItemHelp
  201. //
  202. this.menuItemHelp.Index = 2;
  203. this.menuItemHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  204. this.menuItemAbout});
  205. this.menuItemHelp.Text = "Help";
  206. //
  207. // menuItemAbout
  208. //
  209. this.menuItemAbout.Index = 0;
  210. this.menuItemAbout.Text = "About";
  211. this.menuItemAbout.Click += new System.EventHandler(this.menuItemAbout_Click);
  212. //
  213. // serverUrlTB
  214. //
  215. this.serverUrlTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  216. | System.Windows.Forms.AnchorStyles.Right)));
  217. this.serverUrlTB.BackColor = System.Drawing.SystemColors.Control;
  218. this.serverUrlTB.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  219. this.serverUrlTB.Location = new System.Drawing.Point(0, 0);
  220. this.serverUrlTB.Name = "serverUrlTB";
  221. this.serverUrlTB.Size = new System.Drawing.Size(728, 20);
  222. this.serverUrlTB.TabIndex = 103;
  223. this.serverUrlTB.Text = "";
  224. this.toolTip1.SetToolTip(this.serverUrlTB, "Server connected to");
  225. //
  226. // searchPathLBL
  227. //
  228. this.searchPathLBL.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  229. this.searchPathLBL.Enabled = false;
  230. this.searchPathLBL.Font = new System.Drawing.Font("Arial", 8.25F);
  231. this.searchPathLBL.Location = new System.Drawing.Point(0, 48);
  232. this.searchPathLBL.Name = "searchPathLBL";
  233. this.searchPathLBL.Size = new System.Drawing.Size(88, 21);
  234. this.searchPathLBL.TabIndex = 0;
  235. this.searchPathLBL.Text = "Search Path:";
  236. this.searchPathLBL.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  237. this.toolTip1.SetToolTip(this.searchPathLBL, "Query for the list of children objects for the specified searchPath");
  238. //
  239. // searchPathCB
  240. //
  241. this.searchPathCB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  242. | System.Windows.Forms.AnchorStyles.Right)));
  243. this.searchPathCB.BackColor = System.Drawing.SystemColors.Control;
  244. this.searchPathCB.Enabled = false;
  245. this.searchPathCB.Location = new System.Drawing.Point(88, 48);
  246. this.searchPathCB.Name = "searchPathCB";
  247. this.searchPathCB.Size = new System.Drawing.Size(616, 21);
  248. this.searchPathCB.TabIndex = 3;
  249. this.toolTip1.SetToolTip(this.searchPathCB, "Query for the list of children objects for the specified searchPath");
  250. this.searchPathCB.KeyDown += new System.Windows.Forms.KeyEventHandler(this.searchPathCB_OnKeyPress);
  251. //
  252. // buttonToolBar
  253. //
  254. this.buttonToolBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  255. | System.Windows.Forms.AnchorStyles.Right)));
  256. this.buttonToolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
  257. this.rootButton,
  258. this.backButton,
  259. this.nextButton});
  260. this.buttonToolBar.ButtonSize = new System.Drawing.Size(89, 22);
  261. this.buttonToolBar.Dock = System.Windows.Forms.DockStyle.None;
  262. this.buttonToolBar.DropDownArrows = true;
  263. this.buttonToolBar.ImageList = this.toolBarImageList;
  264. this.buttonToolBar.Location = new System.Drawing.Point(0, 16);
  265. this.buttonToolBar.Name = "buttonToolBar";
  266. this.buttonToolBar.ShowToolTips = true;
  267. this.buttonToolBar.Size = new System.Drawing.Size(735, 28);
  268. this.buttonToolBar.TabIndex = 2;
  269. this.buttonToolBar.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
  270. this.buttonToolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.buttonToolBar_ButtonClick);
  271. //
  272. // rootButton
  273. //
  274. this.rootButton.Enabled = false;
  275. this.rootButton.ImageIndex = 3;
  276. this.rootButton.Text = "All Objects";
  277. this.rootButton.ToolTipText = "List all objects in the Content Store";
  278. //
  279. // backButton
  280. //
  281. this.backButton.Enabled = false;
  282. this.backButton.ImageIndex = 1;
  283. this.backButton.Text = "Back";
  284. this.backButton.ToolTipText = "Previous View";
  285. //
  286. // nextButton
  287. //
  288. this.nextButton.Enabled = false;
  289. this.nextButton.ImageIndex = 2;
  290. this.nextButton.Text = "Forward";
  291. this.nextButton.ToolTipText = "Next View";
  292. //
  293. // toolBarImageList
  294. //
  295. this.toolBarImageList.ImageSize = new System.Drawing.Size(16, 16);
  296. this.toolBarImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("toolBarImageList.ImageStream")));
  297. this.toolBarImageList.TransparentColor = System.Drawing.Color.Transparent;
  298. //
  299. // locationPanel
  300. //
  301. this.locationPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  302. this.locationPanel.Controls.Add(this.buttonGO);
  303. this.locationPanel.Controls.Add(this.searchPathCB);
  304. this.locationPanel.Controls.Add(this.searchPathLBL);
  305. this.locationPanel.Dock = System.Windows.Forms.DockStyle.Top;
  306. this.locationPanel.Location = new System.Drawing.Point(0, 0);
  307. this.locationPanel.Name = "locationPanel";
  308. this.locationPanel.Size = new System.Drawing.Size(736, 72);
  309. this.locationPanel.TabIndex = 2;
  310. //
  311. // buttonGO
  312. //
  313. this.buttonGO.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  314. this.buttonGO.Enabled = false;
  315. this.buttonGO.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
  316. this.buttonGO.Location = new System.Drawing.Point(704, 48);
  317. this.buttonGO.Name = "buttonGO";
  318. this.buttonGO.Size = new System.Drawing.Size(32, 21);
  319. this.buttonGO.TabIndex = 4;
  320. this.buttonGO.Text = "GO";
  321. this.buttonGO.Click += new System.EventHandler(this.buttonGO_Click);
  322. //
  323. // navTree
  324. //
  325. this.navTree.ContextMenu = this.listView_ContextMenu;
  326. this.navTree.Dock = System.Windows.Forms.DockStyle.Left;
  327. this.navTree.HideSelection = false;
  328. this.navTree.HotTracking = true;
  329. this.navTree.ImageList = this.treeViewImageList;
  330. this.navTree.Location = new System.Drawing.Point(0, 0);
  331. this.navTree.Name = "navTree";
  332. this.navTree.Size = new System.Drawing.Size(200, 504);
  333. this.navTree.TabIndex = 1;
  334. this.navTree.MouseDown += new System.Windows.Forms.MouseEventHandler(this.navTree_MouseDown);
  335. this.navTree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.navTree_AfterSelect);
  336. //
  337. // listView_ContextMenu
  338. //
  339. this.listView_ContextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  340. this.menuItemExplore,
  341. this.menuItemProperties,
  342. this.menuItemSeparator1,
  343. this.menuItemView,
  344. this.menuItemRefresh});
  345. //
  346. // menuItemExplore
  347. //
  348. this.menuItemExplore.Index = 0;
  349. this.menuItemExplore.Text = "Explore";
  350. this.menuItemExplore.Visible = false;
  351. this.menuItemExplore.Click += new System.EventHandler(this.menuItemExplore_Click);
  352. //
  353. // menuItemProperties
  354. //
  355. this.menuItemProperties.Index = 1;
  356. this.menuItemProperties.Text = "Properties";
  357. this.menuItemProperties.Visible = false;
  358. this.menuItemProperties.Click += new System.EventHandler(this.menuItemProperties_Click);
  359. //
  360. // menuItemSeparator1
  361. //
  362. this.menuItemSeparator1.Index = 2;
  363. this.menuItemSeparator1.Text = "-";
  364. //
  365. // menuItemView
  366. //
  367. this.menuItemView.Index = 3;
  368. this.menuItemView.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  369. this.menuItemSmallIcons,
  370. this.menuItemLargeIcons,
  371. this.menuItemList,
  372. this.menuItemDetails});
  373. this.menuItemView.Text = "View";
  374. this.menuItemView.Visible = false;
  375. //
  376. // menuItemSmallIcons
  377. //
  378. this.menuItemSmallIcons.Index = 0;
  379. this.menuItemSmallIcons.Text = "Small Icons";
  380. this.menuItemSmallIcons.Click += new System.EventHandler(this.menuItemSmallIcons_Click);
  381. //
  382. // menuItemLargeIcons
  383. //
  384. this.menuItemLargeIcons.Index = 1;
  385. this.menuItemLargeIcons.Text = "Large Icons";
  386. this.menuItemLargeIcons.Click += new System.EventHandler(this.menuItemLargeIcons_Click);
  387. //
  388. // menuItemList
  389. //
  390. this.menuItemList.Index = 2;
  391. this.menuItemList.Text = "List";
  392. this.menuItemList.Click += new System.EventHandler(this.menuItemList_Click);
  393. //
  394. // menuItemDetails
  395. //
  396. this.menuItemDetails.Index = 3;
  397. this.menuItemDetails.Text = "Details";
  398. this.menuItemDetails.Click += new System.EventHandler(this.menuItemDetails_Click);
  399. //
  400. // menuItemRefresh
  401. //
  402. this.menuItemRefresh.Index = 4;
  403. this.menuItemRefresh.Text = "Refresh Tree";
  404. this.menuItemRefresh.Click += new System.EventHandler(this.menuItemRefresh_Click);
  405. //
  406. // treeViewImageList
  407. //
  408. this.treeViewImageList.ImageSize = new System.Drawing.Size(16, 16);
  409. this.treeViewImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("treeViewImageList.ImageStream")));
  410. this.treeViewImageList.TransparentColor = System.Drawing.Color.Transparent;
  411. //
  412. // contentListView
  413. //
  414. this.contentListView.AllowColumnReorder = true;
  415. this.contentListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  416. this.columnHeaderName,
  417. this.columnHeaderType,
  418. this.columnHeaderDateModified,
  419. this.columnHeaderSearchPath});
  420. this.contentListView.ContextMenu = this.listView_ContextMenu;
  421. this.contentListView.Dock = System.Windows.Forms.DockStyle.Fill;
  422. this.contentListView.Font = new System.Drawing.Font("Garamond", 12F);
  423. this.contentListView.HideSelection = false;
  424. this.contentListView.LargeImageList = this.treeViewImageList;
  425. this.contentListView.Location = new System.Drawing.Point(200, 0);
  426. this.contentListView.MultiSelect = false;
  427. this.contentListView.Name = "contentListView";
  428. this.contentListView.Size = new System.Drawing.Size(536, 504);
  429. this.contentListView.SmallImageList = this.treeViewImageList;
  430. this.contentListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
  431. this.contentListView.TabIndex = 2;
  432. this.contentListView.View = System.Windows.Forms.View.Details;
  433. this.contentListView.DoubleClick += new System.EventHandler(this.contentListView_DoubleClick);
  434. this.contentListView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.contentListView_MouseUp);
  435. this.contentListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.contentListView_ColumnClick);
  436. //
  437. // columnHeaderName
  438. //
  439. this.columnHeaderName.Text = "Name";
  440. this.columnHeaderName.Width = 50;
  441. //
  442. // columnHeaderType
  443. //
  444. this.columnHeaderType.Text = "Type";
  445. this.columnHeaderType.Width = 44;
  446. //
  447. // columnHeaderDateModified
  448. //
  449. this.columnHeaderDateModified.Text = "Date Modified";
  450. this.columnHeaderDateModified.Width = 105;
  451. //
  452. // columnHeaderSearchPath
  453. //
  454. this.columnHeaderSearchPath.Text = "Search Path";
  455. this.columnHeaderSearchPath.Width = 400;
  456. //
  457. // statusBar1
  458. //
  459. this.statusBar1.Location = new System.Drawing.Point(0, 576);
  460. this.statusBar1.Name = "statusBar1";
  461. this.statusBar1.Size = new System.Drawing.Size(736, 22);
  462. this.statusBar1.TabIndex = 5;
  463. this.statusBar1.Text = "[";
  464. //
  465. // accountLBL
  466. //
  467. this.accountLBL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  468. | System.Windows.Forms.AnchorStyles.Right)));
  469. this.accountLBL.Font = new System.Drawing.Font("Garamond", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  470. this.accountLBL.Location = new System.Drawing.Point(272, 24);
  471. this.accountLBL.Name = "accountLBL";
  472. this.accountLBL.Size = new System.Drawing.Size(456, 21);
  473. this.accountLBL.TabIndex = 7;
  474. this.accountLBL.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  475. //
  476. // panel1
  477. //
  478. this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  479. | System.Windows.Forms.AnchorStyles.Left)
  480. | System.Windows.Forms.AnchorStyles.Right)));
  481. this.panel1.Controls.Add(this.splitter1);
  482. this.panel1.Controls.Add(this.contentListView);
  483. this.panel1.Controls.Add(this.navTree);
  484. this.panel1.Location = new System.Drawing.Point(0, 72);
  485. this.panel1.Name = "panel1";
  486. this.panel1.Size = new System.Drawing.Size(736, 504);
  487. this.panel1.TabIndex = 8;
  488. //
  489. // splitter1
  490. //
  491. this.splitter1.Location = new System.Drawing.Point(200, 0);
  492. this.splitter1.Name = "splitter1";
  493. this.splitter1.Size = new System.Drawing.Size(3, 504);
  494. this.splitter1.TabIndex = 5;
  495. this.splitter1.TabStop = false;
  496. //
  497. // cBIUrlCB
  498. //
  499. this.cBIUrlCB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  500. | System.Windows.Forms.AnchorStyles.Right)));
  501. this.cBIUrlCB.Location = new System.Drawing.Point(88, 0);
  502. this.cBIUrlCB.Name = "cBIUrlCB";
  503. this.cBIUrlCB.Size = new System.Drawing.Size(576, 21);
  504. this.cBIUrlCB.TabIndex = 101;
  505. this.cBIUrlCB.Text = "http://localhost:9300/p2pd/servlet/dispatch";
  506. //
  507. // labelSites
  508. //
  509. this.labelSites.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  510. this.labelSites.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  511. this.labelSites.Location = new System.Drawing.Point(0, 0);
  512. this.labelSites.Name = "labelSites";
  513. this.labelSites.Size = new System.Drawing.Size(88, 21);
  514. this.labelSites.TabIndex = 102;
  515. this.labelSites.Text = "Sites:";
  516. this.labelSites.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
  517. //
  518. // buttonConnect
  519. //
  520. this.buttonConnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  521. this.buttonConnect.Location = new System.Drawing.Point(664, 0);
  522. this.buttonConnect.Name = "buttonConnect";
  523. this.buttonConnect.Size = new System.Drawing.Size(75, 21);
  524. this.buttonConnect.TabIndex = 0;
  525. this.buttonConnect.Text = "Connect";
  526. this.buttonConnect.Click += new System.EventHandler(this.buttonConnect_Click);
  527. //
  528. // progressBar
  529. //
  530. this.progressBar.Location = new System.Drawing.Point(616, 576);
  531. this.progressBar.Name = "progressBar";
  532. this.progressBar.TabIndex = 105;
  533. this.progressBar.Visible = false;
  534. //
  535. // ContentStoreExplorerDlg
  536. //
  537. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  538. this.ClientSize = new System.Drawing.Size(736, 598);
  539. this.Controls.Add(this.buttonConnect);
  540. this.Controls.Add(this.labelSites);
  541. this.Controls.Add(this.cBIUrlCB);
  542. this.Controls.Add(this.accountLBL);
  543. this.Controls.Add(this.statusBar1);
  544. this.Controls.Add(this.buttonToolBar);
  545. this.Controls.Add(this.serverUrlTB);
  546. this.Controls.Add(this.locationPanel);
  547. this.Controls.Add(this.panel1);
  548. this.Controls.Add(this.progressBar);
  549. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  550. this.IsMdiContainer = true;
  551. this.Menu = this.mainMenu1;
  552. this.Name = "ContentStoreExplorerDlg";
  553. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  554. this.Text = "Content Store Explorer";
  555. this.Load += new System.EventHandler(this.ContentStoreExplorerDlg_Load);
  556. this.locationPanel.ResumeLayout(false);
  557. this.panel1.ResumeLayout(false);
  558. this.ResumeLayout(false);
  559. }
  560. #endregion
  561. /// <summary>
  562. /// The main entry point for the application.
  563. /// </summary>
  564. [STAThread]
  565. static void Main()
  566. {
  567. Application.Run(new ContentStoreExplorerDlg());
  568. }
  569. private void menuItemExit_Click(object sender, System.EventArgs e)
  570. {
  571. this.Close();
  572. }
  573. private void menuItemAbout_Click(object sender, System.EventArgs e)
  574. {
  575. SamplesAbout about = new SamplesAbout();
  576. about.applicationName = "Content Store Explorer Sample";
  577. about.applicationVersion = "1.1";
  578. about.ShowDialog();
  579. }
  580. private void buttonToolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
  581. {
  582. bool backButtonClicked = false;
  583. doUpdate = false;
  584. if ( e.Button == rootButton)
  585. {
  586. navTree.SelectedNode = null;
  587. addAllObjectInListView();
  588. initializeButtonToolBar(true);
  589. }
  590. else if (e.Button == backButton)
  591. {
  592. navTree.SelectedNode = (TreeNode)navigationArray[--navigationArrayIdx];
  593. }
  594. else if (e.Button == nextButton)
  595. {
  596. navTree.SelectedNode = (TreeNode)navigationArray[++navigationArrayIdx];
  597. }
  598. setNavigationState();
  599. doUpdate = true;
  600. }
  601. private void buttonGO_Click(object sender, System.EventArgs e)
  602. {
  603. string inputSearchPath = (string)searchPathCB.SelectedItem;
  604. if ( (inputSearchPath == null) || (0 == inputSearchPath.CompareTo("")) )
  605. {
  606. // if it's a user entered text:
  607. inputSearchPath = searchPathCB.Text;
  608. if ( (inputSearchPath == null) || (0 == inputSearchPath.CompareTo("")) )
  609. {
  610. return;
  611. }
  612. }
  613. if ( (!inputSearchPath.StartsWith("/")) && (!inputSearchPath.StartsWith("CAMID(")) )
  614. {
  615. MessageBox.Show("Please enter a valid searchPath");
  616. return;
  617. }
  618. TreeNode treeNode = null;
  619. if (searchPathInTree(inputSearchPath, navTree.Nodes, ref treeNode))
  620. {
  621. navTree.SelectedNode = treeNode;
  622. addItemsInListView(treeNode);
  623. }
  624. }
  625. private void ContentStoreExplorerDlg_Load(object sender, System.EventArgs e)
  626. {
  627. buttonConnect.Focus();
  628. }
  629. private void menuItemExplore_Click(object sender, System.EventArgs e)
  630. {
  631. openSelectedListViewItem();
  632. }
  633. private void menuItemProperties_Click(object sender, System.EventArgs e)
  634. {
  635. PropertiesDlg propDlg = null;
  636. try
  637. {
  638. if ( (contentListView.SelectedItems != null) && (contentListView.SelectedItems.Count == 1) )
  639. {
  640. propDlg = new PropertiesDlg();
  641. ListView.SelectedListViewItemCollection selectedItems = contentListView.SelectedItems;
  642. propDlg.setItemSearchPath((string)contentListView.SelectedItems[0].Tag);
  643. propDlg.setConnection(cBIServer);
  644. propDlg.Show();
  645. }
  646. }
  647. catch(SoapException ex)
  648. {
  649. SamplesException.ShowExceptionMessage( ex, true, "IBM Cognos Error" );
  650. statusBar1.Text = "IBM Cognos Error: " + ex.Message;
  651. propDlg.Close();
  652. return;
  653. }
  654. catch(Exception ex)
  655. {
  656. if (0 != ex.Message.CompareTo("INPUT_CANCELLED_BY_USER"))
  657. {
  658. SamplesException.ShowExceptionMessage( ex.Message, true, "ContentStoreExplorer Error" );
  659. statusBar1.Text = "ContentStoreExplorer Error: " + ex.Message;
  660. }
  661. propDlg.Close();
  662. return;
  663. }
  664. }
  665. private void menuItemSmallIcons_Click(object sender, System.EventArgs e)
  666. {
  667. contentListView.View = View.SmallIcon;
  668. }
  669. private void menuItemLargeIcons_Click(object sender, System.EventArgs e)
  670. {
  671. contentListView.View = View.LargeIcon;
  672. }
  673. private void menuItemList_Click(object sender, System.EventArgs e)
  674. {
  675. contentListView.View = View.List;
  676. }
  677. private void menuItemDetails_Click(object sender, System.EventArgs e)
  678. {
  679. contentListView.View = View.Details;
  680. }
  681. private void menuItemRefresh_Click(object sender, System.EventArgs e)
  682. {
  683. loadUI(false, "", cBIServer);
  684. }
  685. private void navTree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
  686. {
  687. if (doUpdate)
  688. {
  689. for (int i = navigationArray.Count-1; i > navigationArrayIdx; i--)
  690. {
  691. navigationArray.RemoveAt(i);
  692. }
  693. navigationArray.Add(navTree.SelectedNode);
  694. if (0 != navTree.SelectedNode.Text.CompareTo("/"))
  695. {
  696. navigationArrayIdx++;
  697. }
  698. setNavigationState();
  699. }
  700. updateSearchPathList(((baseClass)e.Node.Tag).searchPath.value);
  701. addItemsInListView(e.Node);
  702. e.Node.Expand();
  703. }
  704. private void addItemsInListView(TreeNode node)
  705. {
  706. ListViewItem item = null;
  707. if (node.Nodes == null)
  708. {
  709. return;
  710. }
  711. baseClass bcChild = null;
  712. contentListView.Items.Clear();
  713. for (int i=0; i<node.Nodes.Count; i++)
  714. {
  715. bcChild = (baseClass)node.Nodes[i].Tag;
  716. item = new ListViewItem(bcChild.defaultName.value, getImageIndex(bcChild));
  717. item.SubItems.Add(bcChild.objectClass.value.ToString());
  718. item.SubItems.Add(bcChild.modificationTime.value.ToShortDateString() + " " +
  719. bcChild.modificationTime.value.ToShortTimeString());
  720. item.SubItems.Add(bcChild.searchPath.value);
  721. item.Tag = bcChild.searchPath.value;
  722. contentListView.Items.AddRange(new ListViewItem[]{item});
  723. }
  724. contentListView.Columns[0].Width = -2; // autosize
  725. contentListView.Columns[1].Width = -2;
  726. contentListView.Columns[2].Width = -2;
  727. contentListView.Columns[3].Width = -2;
  728. statusBar1.Text = " " + node.Nodes.Count.ToString() + " Objects";
  729. }
  730. private void addAllObjectInListView()
  731. {
  732. baseClass bcChild = null;
  733. ListViewItem item = null;
  734. contentListView.Items.Clear();
  735. for (int i=0; i < cBIBCList.GetLength(0); i++)
  736. {
  737. bcChild = cBIBCList[i];
  738. item = new ListViewItem(bcChild.defaultName.value, getImageIndex(bcChild));
  739. item.SubItems.Add(bcChild.objectClass.value.ToString());
  740. item.SubItems.Add(bcChild.modificationTime.value.ToShortDateString() + " " +
  741. bcChild.modificationTime.value.ToShortTimeString());
  742. item.SubItems.Add(bcChild.searchPath.value);
  743. item.Tag = bcChild.searchPath.value;
  744. contentListView.Items.AddRange(new ListViewItem[]{item});
  745. }
  746. contentListView.Columns[0].Width = -2; // autosize
  747. contentListView.Columns[1].Width = -2;
  748. contentListView.Columns[2].Width = -2;
  749. contentListView.Columns[3].Width = -2;
  750. statusBar1.Text = " " + cBIBCList.GetLength(0).ToString() + " Objects";
  751. }
  752. private void contentListView_DoubleClick(object sender, System.EventArgs e)
  753. {
  754. openSelectedListViewItem();
  755. }
  756. private void navTree_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
  757. {
  758. if(e.Button == MouseButtons.Right)
  759. {
  760. menuItemExplore.Visible = false;
  761. menuItemProperties.Visible = false;
  762. menuItemSeparator1.Visible = false;
  763. menuItemView.Visible = false;
  764. menuItemRefresh.Visible = true;
  765. }
  766. }
  767. private void contentListView_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
  768. {
  769. if(e.Button == MouseButtons.Right)
  770. {
  771. if ( (contentListView.SelectedItems != null) && (contentListView.SelectedItems.Count == 1) )
  772. {
  773. menuItemExplore.Visible = true;
  774. menuItemProperties.Visible = true;
  775. menuItemSeparator1.Visible = true;
  776. menuItemView.Visible = true;
  777. menuItemRefresh.Visible = true;
  778. }
  779. else
  780. {
  781. menuItemExplore.Visible = false;
  782. menuItemProperties.Visible = false;
  783. menuItemSeparator1.Visible = false;
  784. menuItemView.Visible = true;
  785. menuItemRefresh.Visible = true;
  786. }
  787. }
  788. }
  789. private void cBIUrlCB_OnKeyPress(object sender, KeyEventArgs e)
  790. {
  791. if (e.KeyCode == Keys.Enter)
  792. {
  793. buttonConnect_Click(null, null);
  794. }
  795. }
  796. private void searchPathCB_OnKeyPress(object sender, KeyEventArgs e)
  797. {
  798. if (e.KeyCode == Keys.Enter)
  799. {
  800. buttonGO_Click(null, null);
  801. }
  802. }
  803. //common use for column sorting
  804. private void contentListView_ColumnClick(object sender, ColumnClickEventArgs e)
  805. {
  806. if (contentListView.Sorting==SortOrder.Descending)
  807. {
  808. //toggle to ascending
  809. contentListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
  810. }
  811. else
  812. {
  813. //toggle to Descending
  814. contentListView.Sorting = System.Windows.Forms.SortOrder.Descending;
  815. }
  816. //use the column number that the user clicked as a constructor argument
  817. //to tell the compare function which column to be working on.
  818. //ListViewItemSorter tells the listview control what custom class implements the
  819. //IComparer interface, and therefore the compare function it needs to be able to sort
  820. contentListView.ListViewItemSorter=new ColumnSort(e.Column);
  821. //now actually call the sort routine which uses the ColumnSort object's compare function
  822. contentListView.Sort();
  823. }
  824. /*********************************************************************************************
  825. *
  826. * Public Functions
  827. *
  828. ******************************************************************************************* */
  829. public void setNavigationState()
  830. {
  831. if (navigationArrayIdx >= navigationArray.Count-1)
  832. {
  833. nextButton.Enabled = false;
  834. }
  835. else
  836. {
  837. nextButton.Enabled = true;
  838. }
  839. if (navigationArrayIdx == 0)
  840. {
  841. backButton.Enabled = false;
  842. }
  843. else
  844. {
  845. backButton.Enabled = true;
  846. }
  847. }
  848. /*
  849. * This function is called when an Item is double clicked in the ListView
  850. * or Right-Click->Open is selected on a ListView Item.
  851. *
  852. * OutCome:
  853. * The selected Item is 'opened': it becomes the selected node in the TreeView
  854. * and the ListView now shows the Item children.
  855. *
  856. */
  857. public void openSelectedListViewItem()
  858. {
  859. try
  860. {
  861. TreeNode selectedNode = navTree.SelectedNode;
  862. // get the collection of items currently in the List View
  863. ListView.SelectedListViewItemCollection selectedItems = contentListView.SelectedItems;
  864. if (selectedItems == null)
  865. {
  866. return;
  867. }
  868. // We only care when 1 item is selected
  869. if (selectedItems.Count == 1)
  870. {
  871. TreeNode treeNode = null;
  872. searchPathInTree((string)selectedItems[0].Tag,
  873. navTree.SelectedNode.Nodes,
  874. ref treeNode);
  875. navTree.SelectedNode = treeNode;
  876. }
  877. }
  878. catch(SoapException ex)
  879. {
  880. SamplesException.ShowExceptionMessage( ex, true, "IBM Cognos Error" );
  881. statusBar1.Text = "IBM Cognos Error: " + ex.Message;
  882. return;
  883. }
  884. catch(Exception ex)
  885. {
  886. if (0 != ex.Message.CompareTo("INPUT_CANCELLED_BY_USER"))
  887. {
  888. SamplesException.ShowExceptionMessage( ex.Message, true, "ContentStoreExplorer Error" );
  889. statusBar1.Text = "ContentStoreExplorer Error: " + ex.Message;
  890. }
  891. return;
  892. }
  893. }
  894. /*
  895. * This function searches the children of a given TreeNode and returns the childNode
  896. * corresponding to the given searchPath
  897. *
  898. * Input
  899. * (string) searchPath : searchPath of the TreeNode we're looking for
  900. * (TreeNode) Parent : the TreeNode that will be searched.
  901. * if null, the whole tree will be searched.
  902. *
  903. * Output:
  904. * (TreeNode) ChildNode
  905. *
  906. */
  907. public TreeNode getTreeNode(string searchPath, TreeNode parent)
  908. {
  909. TreeNode foundNode = null;
  910. if (parent == null)
  911. {
  912. // start from the root node
  913. parent = navTree.Nodes[0];
  914. }
  915. TreeNodeCollection childNodes = parent.Nodes;
  916. for(int i=0; i<childNodes.Count; i++)
  917. {
  918. foundNode = childNodes[i];
  919. if ( 0 == searchPath.CompareTo((string)foundNode.Tag) )
  920. {
  921. return foundNode;
  922. }
  923. }
  924. return null;
  925. }
  926. public void updateSearchPathList(string searchPath)
  927. {
  928. if (!searchPathCB.Items.Contains(searchPath))
  929. {
  930. searchPathCB.Items.Insert(0, searchPath);
  931. if (searchPathCB.Items.Count > 10) // maintain a max of 10 searchPaths
  932. {
  933. searchPathCB.Items.RemoveAt(10);
  934. }
  935. searchPathCB.SelectedIndex = 0;
  936. }
  937. else
  938. {
  939. searchPathCB.SelectedIndex = searchPathCB.Items.IndexOf(searchPath);
  940. }
  941. }
  942. public string getCurrentAccountName()
  943. {
  944. string accountName = "";
  945. baseClass[] bc = new baseClass[1];
  946. propEnum[] props =
  947. new propEnum[] { propEnum.searchPath, propEnum.defaultName };
  948. try
  949. {
  950. searchPathMultipleObject homeDir = new searchPathMultipleObject();
  951. homeDir.Value = "~";
  952. bc = cBIServer.query(homeDir, props, new sort[] {}, new queryOptions());
  953. if ( (bc != null) && (bc.GetLength(0) >0) )
  954. {
  955. accountName = bc[0].defaultName.value;
  956. }
  957. }
  958. catch(System.Exception ex)
  959. {
  960. return "";
  961. }
  962. return accountName;
  963. }
  964. private void menuItemSites_Click(object sender, System.EventArgs e)
  965. {
  966. if (sitesToolBarEnabled)
  967. {
  968. disableSitesToolBar();
  969. }
  970. else
  971. {
  972. enableSitesToolBar();
  973. }
  974. }
  975. /* This function is the starting point of the application.
  976. * The sequence of operation is as follows:
  977. * 1. Connect to the server
  978. * 2. Update the User Interface: enable controls that can be used after the tree is loaded
  979. * 3. Create the Root Node
  980. * 4. Build the root children and grand children
  981. * 5. expand the root Node and populate the listView with the rootNode's children.
  982. */
  983. private void buttonConnect_Click(object sender, System.EventArgs e)
  984. {
  985. // 1. Connect to the server
  986. statusBar1.Text = "Connecting to site: " + cBIUrlCB.Text + " ... Please wait.";
  987. // Add the site to the comboBox list
  988. if (!cBIUrlCB.Items.Contains(cBIUrlCB.Text))
  989. {
  990. cBIUrlCB.Items.Insert(0, cBIUrlCB.Text);
  991. if (cBIUrlCB.Items.Count > 10) // maintain a max of 10 sites
  992. {
  993. cBIUrlCB.Items.RemoveAt(10);
  994. }
  995. cBIUrlCB.SelectedIndex = 0;
  996. }
  997. serverUrlTB.Text = cBIUrlCB.Text;
  998. // Connect to the server in a separate thread to preserve UI functionality
  999. ConnectToCognosServer connect = new ConnectToCognosServer(cBIUrlCB.Text,
  1000. new ConnectionCallBack(ConnectionCallBackResult));
  1001. Thread connectionThread = new Thread(new ThreadStart(connect.makeConnection));
  1002. connectionThread.IsBackground = true;
  1003. connectionThread.Name = "ConnectionThread";
  1004. connectionThread.Start();
  1005. }
  1006. /*
  1007. * This method is executed when the connection thread has finished executing
  1008. * The arguments of this method are returned values of the ConnectionThread
  1009. */
  1010. public void ConnectionCallBackResult(bool connectionState, string resultMessage,
  1011. contentManagerService1 cmService)
  1012. {
  1013. isConnected = connectionState;
  1014. connectMessage = resultMessage;
  1015. cBIServer = cmService;
  1016. if (InvokeRequired)
  1017. {
  1018. // We're not in the UI thread, so we need to call BeginInvoke
  1019. IAsyncResult aResult = BeginInvoke(new ConnectionCallBack(loadUI),
  1020. new Object[]{connectionState,
  1021. resultMessage,
  1022. cmService});
  1023. aResult.AsyncWaitHandle.WaitOne();
  1024. EndInvoke(aResult);
  1025. return;
  1026. }
  1027. }
  1028. public void loadUI(bool connectionState, string resultMessage,
  1029. contentManagerService1 cmService)
  1030. {
  1031. try
  1032. {
  1033. // Must be on the UI thread if we've got this far
  1034. statusBar1.Text = connectMessage;
  1035. if (!isConnected)
  1036. {
  1037. disableUI();
  1038. // keep the sites toolbar enabled for another connection attempt
  1039. enableSitesToolBar();
  1040. return;
  1041. }
  1042. // 2. Update the User Interface: enable controls that can be used after the tree is loaded
  1043. enableUI();
  1044. disableSitesToolBar();
  1045. accountLBL.Text = getCurrentAccountName();
  1046. // 3. Create the Root Node
  1047. statusBar1.Text = "Loading Objects...";
  1048. cBIBCList = makeQuery("//*");
  1049. //string bcsearchPathList = printBCList(cBIBCList);
  1050. //MessageBox.Show(bcsearchPathList);
  1051. baseClass bcRoot = getBaseClassFromList(cBIBCList, "/");
  1052. rootNode = new TreeNode("/", 0, 0);
  1053. rootNode.Tag = bcRoot;
  1054. navTree.Nodes.Add(rootNode);
  1055. // 4. Query for all objects in the server and build them into the treeView
  1056. buildTree(rootNode, cBIBCList, "/");
  1057. // 5. expand the root Node and populate the listView with the rootNode's children.
  1058. navTree.SelectedNode = rootNode;
  1059. rootNode.Expand();
  1060. navTree.Focus();
  1061. }
  1062. catch(SoapException ex)
  1063. {
  1064. SamplesException.ShowExceptionMessage( ex, true, "IBM Cognos Error" );
  1065. statusBar1.Text = "IBM Cognos Error: " + ex.Message;
  1066. return;
  1067. }
  1068. catch(Exception ex)
  1069. {
  1070. if (0 != ex.Message.CompareTo("INPUT_CANCELLED_BY_USER"))
  1071. {
  1072. SamplesException.ShowExceptionMessage( ex.Message, true, "ContentStoreExplorer Error" );
  1073. statusBar1.Text = "ContentStoreExplorer Error: " + ex.Message;
  1074. }
  1075. return;
  1076. }
  1077. }
  1078. public string printBCList(baseClass[] cmBCList)
  1079. {
  1080. string bcsearchPathList = "";
  1081. for(int i=0; i < cmBCList.GetLength(0); i++)
  1082. {
  1083. bcsearchPathList += cmBCList[i].searchPath.value;
  1084. bcsearchPathList += ",\n";
  1085. }
  1086. return bcsearchPathList;
  1087. }
  1088. public void buildTree(TreeNode parentNode, baseClass[] cmBCList, string parentSearchPath)
  1089. {
  1090. int imgIdx = 0;
  1091. TreeNode childNode = null;
  1092. baseClass childBaseClass = null;
  1093. for (int i=0; i < cmBCList.GetLength(0); i++)
  1094. {
  1095. childBaseClass = cmBCList[i];
  1096. //parent will be null for root
  1097. if ( (childBaseClass.parent.value != null)
  1098. && (0 == parentSearchPath.CompareTo(childBaseClass.parent.value[0].searchPath.value)) )
  1099. {
  1100. imgIdx = getImageIndex(childBaseClass);
  1101. childNode = new TreeNode(childBaseClass.defaultName.value, imgIdx, imgIdx);
  1102. childNode.Tag = childBaseClass;
  1103. parentNode.Nodes.Add(childNode);
  1104. buildTree(childNode, cmBCList, childBaseClass.searchPath.value);
  1105. }
  1106. }
  1107. }
  1108. public bool searchPathInTree(string searchPath, TreeNodeCollection nodeCollection, ref TreeNode treeNode)
  1109. {
  1110. for (int i=0; i < nodeCollection.Count; i++)
  1111. {
  1112. TreeNode childNode = nodeCollection[i];
  1113. if (0 == searchPath.CompareTo( ((baseClass)childNode.Tag).searchPath.value ))
  1114. {
  1115. treeNode = childNode;
  1116. break;
  1117. }
  1118. else
  1119. {
  1120. searchPathInTree(searchPath, childNode.Nodes, ref treeNode);
  1121. }
  1122. }
  1123. if (treeNode == null)
  1124. {
  1125. return false;
  1126. }
  1127. else
  1128. {
  1129. return true;
  1130. }
  1131. }
  1132. public baseClass getBaseClassFromList(baseClass[] cmBCList, string searchPath)
  1133. {
  1134. baseClass bc = null;
  1135. foreach (baseClass bcObject in cmBCList)
  1136. {
  1137. if (0 == searchPath.CompareTo(bcObject.searchPath.value))
  1138. {
  1139. bc = bcObject;
  1140. break;
  1141. }
  1142. }
  1143. return bc;
  1144. }
  1145. public void disableUI()
  1146. {
  1147. navTree.Nodes.Clear();
  1148. navTree.Width = 200;
  1149. contentListView.Items.Clear();
  1150. disableSitesToolBar();
  1151. initializeButtonToolBar(false);
  1152. disableSearchPathToolBar();
  1153. accountLBL.Text = "";
  1154. }
  1155. public void enableUI()
  1156. {
  1157. navTree.Nodes.Clear();
  1158. navTree.Width = 200;
  1159. contentListView.Items.Clear();
  1160. enableSitesToolBar();
  1161. initializeButtonToolBar(true);
  1162. enableSearchPathToolBar();
  1163. }
  1164. public void initializeButtonToolBar(bool rootEnabled)
  1165. {
  1166. // reset the button toolBar
  1167. previousNodeIdx = 0;
  1168. previousNodeList[0].Text = "";
  1169. previousNodeList[1].Text = "";
  1170. previousNodeList[2].Text = "";
  1171. previousNodeList[3].Text = "";
  1172. previousNodeList[4].Text = "";
  1173. rootButton.Enabled = rootEnabled;
  1174. navigationArray.Clear();
  1175. navigationArrayIdx = 0;
  1176. setNavigationState();
  1177. }
  1178. public void disableSitesToolBar()
  1179. {
  1180. labelSites.Visible = false;
  1181. cBIUrlCB.Visible = false;
  1182. buttonConnect.Visible = false;
  1183. menuItemSites.Checked = false;
  1184. sitesToolBarEnabled = false;
  1185. }
  1186. public void enableSitesToolBar()
  1187. {
  1188. labelSites.Visible = true;
  1189. cBIUrlCB.Visible = true;
  1190. buttonConnect.Visible = true;
  1191. menuItemSites.Checked = true;
  1192. sitesToolBarEnabled = true;
  1193. }
  1194. public void enableSearchPathToolBar()
  1195. {
  1196. searchPathLBL.Enabled = true;
  1197. searchPathCB.Enabled = true;
  1198. searchPathCB.BackColor = System.Drawing.SystemColors.Window;
  1199. buttonGO.Enabled = true;
  1200. }
  1201. public void disableSearchPathToolBar()
  1202. {
  1203. searchPathLBL.Enabled = false;
  1204. searchPathCB.Enabled = false;
  1205. searchPathCB.BackColor = System.Drawing.SystemColors.Control;
  1206. buttonGO.Enabled = false;
  1207. }
  1208. public baseClass[] makeQuery(string searchPath)
  1209. {
  1210. baseClass[] bcResultArr = new baseClass[0];
  1211. sort[] sortOptions = { new sort() };
  1212. sortOptions[0].order = orderEnum.ascending;
  1213. sortOptions[0].propName = propEnum.defaultName;
  1214. propEnum[] props = new propEnum[] { propEnum.searchPath,
  1215. propEnum.defaultName,
  1216. propEnum.objectClass,
  1217. propEnum.modificationTime,
  1218. propEnum.hasChildren,
  1219. propEnum.parent};
  1220. searchPathMultipleObject cmSearchPath = new searchPathMultipleObject();
  1221. cmSearchPath.Value = searchPath;
  1222. try
  1223. {
  1224. bcResultArr = cBIServer.query(cmSearchPath, props, sortOptions, new queryOptions());
  1225. }
  1226. catch(SoapException ex)
  1227. {
  1228. SamplesException.ShowExceptionMessage( ex, true, "IBM Cognos Error" );
  1229. statusBar1.Text = "IBM Cognos Error: " + ex.Message;
  1230. return null;
  1231. }
  1232. catch(Exception ex)
  1233. {
  1234. if (0 != ex.Message.CompareTo("INPUT_CANCELLED_BY_USER"))
  1235. {
  1236. SamplesException.ShowExceptionMessage( ex.Message, true, "ContentStoreExplorer Error" );
  1237. statusBar1.Text = "ContentStoreExplorer Error: " + ex.Message;
  1238. }
  1239. return null;
  1240. }
  1241. return bcResultArr;
  1242. }
  1243. public int getImageIndex(baseClass bcObj)
  1244. {
  1245. switch (bcObj.objectClass.value)
  1246. {
  1247. case classEnum.root:
  1248. return 0;
  1249. case classEnum.capability:
  1250. case classEnum.directory:
  1251. return 1;
  1252. case classEnum.package:
  1253. return 2;
  1254. case classEnum.folder:
  1255. if (0 == bcObj.defaultName.value.CompareTo("My Folders"))
  1256. {
  1257. return 22;
  1258. }
  1259. else
  1260. {
  1261. return 3;
  1262. }
  1263. case classEnum.report:
  1264. return 4;
  1265. case classEnum.securedFeature:
  1266. return 5;
  1267. case classEnum.securedFunction:
  1268. return 6;
  1269. case classEnum.dispatcher:
  1270. return 7;
  1271. case classEnum.agentService:
  1272. case classEnum.batchReportService:
  1273. case classEnum.contentManagerService:
  1274. case classEnum.dataIntegrationService:
  1275. case classEnum.deliveryService:
  1276. case classEnum.eventManagementService:
  1277. case classEnum.indexDataService:
  1278. case classEnum.indexSearchService:
  1279. case classEnum.indexUpdateService:
  1280. // case classEnum.jobAndScheduleMonitoringService:
  1281. case classEnum.jobService:
  1282. case classEnum.logService:
  1283. case classEnum.metadataService:
  1284. case classEnum.metricsManagerService:
  1285. case classEnum.monitorService:
  1286. case classEnum.planningRuntimeService:
  1287. case classEnum.planningTaskService:
  1288. case classEnum.presentationService:
  1289. case classEnum.reportService:
  1290. case classEnum.systemService:
  1291. case classEnum.runTimeState:
  1292. return 8;
  1293. case classEnum.@namespace:
  1294. return 9;
  1295. case classEnum.contact:
  1296. return 10;
  1297. case classEnum.dataSource:
  1298. return 11;
  1299. case classEnum.dataSourceConnection:
  1300. return 12;
  1301. case classEnum.dataSourceSignon:
  1302. return 13;
  1303. case classEnum.printer:
  1304. return 14;
  1305. case classEnum.group:
  1306. return 16;
  1307. case classEnum.role:
  1308. return 17;
  1309. case classEnum.distributionList:
  1310. return 18;
  1311. case classEnum.importDeployment:
  1312. case classEnum.exportDeployment:
  1313. return 19;
  1314. case classEnum.query:
  1315. return 20;
  1316. case classEnum.content:
  1317. return 21;
  1318. case classEnum.model:
  1319. return 23;
  1320. case classEnum.jobDefinition:
  1321. return 24;
  1322. case classEnum.configuration:
  1323. return 25;
  1324. // case classEnum.importDeploymentFolder:
  1325. // case classEnum.exportDeploymentFolder:
  1326. // return 26;
  1327. // case classEnum.deploymentHistory:
  1328. case classEnum.history:
  1329. case classEnum.historyDetail:
  1330. case classEnum.historyDetailAgentService:
  1331. case classEnum.historyDetailRelatedHistory:
  1332. case classEnum.historyDetailRelatedReports:
  1333. case classEnum.historyDetailReportService:
  1334. case classEnum.historyDetailRequestArguments:
  1335. return 27;
  1336. case classEnum.jobStepDefinition:
  1337. return 28;
  1338. /***************************
  1339. * classes not handled yet
  1340. * TBD
  1341. case classEnum.account:
  1342. case classEnum.adminFolder:
  1343. case classEnum.agentDefinition:
  1344. case classEnum.agentDefinitionView:
  1345. case classEnum.agentOutputHotList:
  1346. case classEnum.agentState:
  1347. case classEnum.agentTaskDefinition:
  1348. case classEnum.agentTaskState:
  1349. case classEnum.analysis:
  1350. case classEnum.configuration:
  1351. case classEnum.configurationFolder:
  1352. case classEnum.contentTask:
  1353. case classEnum.credential:
  1354. case classEnum.dataSourceNameBinding:
  1355. case classEnum.deploymentDetail:
  1356. case classEnum.drillPath:
  1357. case classEnum.graphic:
  1358. case classEnum.indexUpdateTask:
  1359. case classEnum.installedComponent:
  1360. case classEnum.memo:
  1361. case classEnum.metricsDataSourceETLTask:
  1362. case classEnum.metricsExportTask:
  1363. case classEnum.metricsFileImportTask:
  1364. case classEnum.metricsMaintenanceTask:
  1365. case classEnum.modelView:
  1366. case classEnum.namespaceFolder:
  1367. case classEnum.output:
  1368. case classEnum.packageConfiguration:
  1369. case classEnum.page:
  1370. case classEnum.pageDefinition:
  1371. case classEnum.pagelet:
  1372. case classEnum.pageletFolder:
  1373. case classEnum.pageletInstance:
  1374. case classEnum.planningAdministrationConsoleService:
  1375. case classEnum.planningApplication:
  1376. case classEnum.planningEList:
  1377. case classEnum.planningTask:
  1378. case classEnum.portal:
  1379. case classEnum.portalPackage:
  1380. case classEnum.portalSkin:
  1381. case classEnum.portalSkinFolder:
  1382. case classEnum.portlet:
  1383. case classEnum.portletFolder:
  1384. case classEnum.portletInstance:
  1385. case classEnum.portletProducer:
  1386. case classEnum.powerPlayCube:
  1387. case classEnum.powerPlayReport:
  1388. case classEnum.reportTemplate:
  1389. case classEnum.reportVersion:
  1390. case classEnum.reportView:
  1391. case classEnum.schedule:
  1392. case classEnum.session:
  1393. case classEnum.shortcut:
  1394. case classEnum.shortcutRSSTask:
  1395. case classEnum.SQL:
  1396. case classEnum.storedProcedureTask:
  1397. case classEnum.transientStateFolder:
  1398. case classEnum.URL:
  1399. case classEnum.urlRSSTask:
  1400. case classEnum.webServiceTask:
  1401. */
  1402. /*
  1403. case classEnum.output:
  1404. if (0 == bcObj.outputFormat.CompareTo("HTML"))
  1405. {
  1406. return 29;
  1407. }
  1408. else if (0 == bcObj.outputFormat.CompareTo("XHTML"))
  1409. {
  1410. return 30;
  1411. }
  1412. else if (0 == bcObj.outputFormat.CompareTo("CSV"))
  1413. {
  1414. return 31;
  1415. }
  1416. else if (0 == bcObj.outputFormat.CompareTo("PDF"))
  1417. {
  1418. return 32;
  1419. }
  1420. else if (0 == bcObj.outputFormat.CompareTo("EXCEL"))
  1421. {
  1422. return 33;
  1423. }
  1424. else if (0 == bcObj.outputFormat.CompareTo("XML"))
  1425. {
  1426. return 34;
  1427. }
  1428. else
  1429. {
  1430. return 99;
  1431. }
  1432. */
  1433. default:
  1434. return 99;
  1435. }
  1436. }
  1437. }
  1438. public delegate void ConnectionCallBack(bool connectionState, string resultMessage,
  1439. contentManagerService1 cmService);
  1440. public class ConnectToCognosServer
  1441. {
  1442. private static string savedUserName = "";
  1443. private static string savedUserPassword = "";
  1444. private static string savedNamespace = "";
  1445. private string cBIUrl = "";
  1446. private ConnectionCallBack callback;
  1447. public ConnectToCognosServer(string cmUrl, ConnectionCallBack callbackDelegate)
  1448. {
  1449. cBIUrl = cmUrl;
  1450. callback = callbackDelegate;
  1451. }
  1452. public void makeConnection()
  1453. {
  1454. contentManagerService1 cmService = new contentManagerService1();
  1455. try
  1456. {
  1457. cmService.Url = cBIUrl;
  1458. searchPathMultipleObject homeDir = new searchPathMultipleObject();
  1459. homeDir.Value = "~";
  1460. //Test for Anonymous Authentication
  1461. baseClass[] bc = cmService.query ( homeDir, new propEnum[]{} , new sort[]{}, new queryOptions () );
  1462. if (bc != null)
  1463. {
  1464. if (callback != null)
  1465. callback(true, "Connected to Server: " + cBIUrl, cmService);
  1466. return;
  1467. }
  1468. }
  1469. catch(Exception ex)
  1470. {
  1471. //If security is turned on, we will end up here and fall into the logon code below
  1472. }
  1473. // Attempt to log on.
  1474. SamplesLogon logon = new SamplesLogon( cmService );
  1475. logon.setUserName(savedUserName);
  1476. logon.setUserPassword(savedUserPassword);
  1477. logon.setNamespace(savedNamespace);
  1478. logon.ShowDialog( );
  1479. if( !logon.loggedOn )
  1480. {
  1481. if (callback != null)
  1482. callback(false, "Unable to login to: \"" + cBIUrl+ "\"... ", cmService);
  1483. return;
  1484. }
  1485. else
  1486. {
  1487. savedUserName = logon.getUserName();
  1488. savedUserPassword = logon.getUserPassword();
  1489. savedNamespace = logon.getNamespace();
  1490. }
  1491. if (callback != null)
  1492. callback(true, "Connected to Server: " + cBIUrl, cmService);
  1493. }
  1494. }
  1495. public class NodeObject : baseClass
  1496. {
  1497. public string outputFormat = "";
  1498. public NodeObject()
  1499. {
  1500. this.defaultName = new tokenProp();
  1501. this.searchPath = new stringProp();
  1502. this.objectClass = new classEnumProp();
  1503. this.modificationTime = new dateTimeProp();
  1504. }
  1505. public override string ToString()
  1506. {
  1507. return this.defaultName.value;
  1508. }
  1509. }
  1510. public class FieldObject
  1511. {
  1512. public string fieldName = "";
  1513. public string fieldValue = null;
  1514. public FieldObject()
  1515. {
  1516. this.fieldName = "";
  1517. this.fieldValue = "";
  1518. }
  1519. }
  1520. /// class that implements IComparer interface
  1521. /// for the purpose of sorting based on subitems,
  1522. /// which are columns in a listview's detail/report view
  1523. public class ColumnSort:IComparer
  1524. {
  1525. private int columnNum;
  1526. public ColumnSort(int column_to_sort)
  1527. {
  1528. //retrieve what column it is the user is trying to sort
  1529. columnNum=column_to_sort;
  1530. }
  1531. //this function must be implemented from the IComparer interface
  1532. //the function always(?) takes in two generic object parameters
  1533. //that must be cast to the appropriate type
  1534. //in this case a ListViewItem
  1535. public int Compare(object a, object b)
  1536. {
  1537. ListViewItem listItemA=(System.Windows.Forms.ListViewItem)a;
  1538. ListViewItem listItemB=(System.Windows.Forms.ListViewItem)b;
  1539. //after the objects have been cast you can retrieve the item or subitem text for
  1540. //string comparison. you return the result so the sort funtion knows which
  1541. //subitem is greater than the other. to switch between ascending and descending
  1542. //is multiply the result by -1 to change the sign.
  1543. if (listItemA.ListView.Sorting==System.Windows.Forms.SortOrder.Ascending)
  1544. //here i grab the enum value for what type of sorting the user has specified...i really don't know how
  1545. //i am able to access the listView properties (the parent of the listitem)....but it works
  1546. {
  1547. return (String.Compare(listItemA.SubItems[columnNum].Text,listItemB.SubItems[columnNum].Text)*-1);
  1548. }
  1549. else
  1550. {
  1551. return String.Compare(listItemA.SubItems[columnNum].Text,listItemB.SubItems[columnNum].Text);
  1552. }
  1553. }
  1554. }
  1555. }