123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- using System;
- using System.IO;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Web.Services.Protocols;
- using SamplesCommon;
- using cognosdotnet_10_2;
- namespace CreateDrillThroughTarget
- {
-
-
-
- public class CreateDrillThroughTargetDlg : System.Windows.Forms.Form
- {
- private System.Windows.Forms.MainMenu mainMenu1;
- private System.Windows.Forms.MenuItem menuItemFile;
- private System.Windows.Forms.MenuItem menuItemExit;
- private System.Windows.Forms.MenuItem menuItemHelp;
- private System.Windows.Forms.MenuItem menuItemAbout;
- private IContainer components;
- private System.Windows.Forms.Button buttonCreateDrillThroughTarget;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label reportNameLBL;
- private System.Windows.Forms.ComboBox reportListCB;
- private AxSHDocVw.AxWebBrowser outputBrowser;
- private System.Windows.Forms.TextBox reportSearchPathTB;
- private System.Windows.Forms.TextBox serverUrlTB;
- private static contentManagerService1 cBIServer = null;
- private static reportService1 cBIRS = null;
- private ComboBox packageListCB;
- private Label packageLabel;
- private static SamplesConnect cBIConnection = null;
- private CreateDrillThroughTarget dtTarget = new CreateDrillThroughTarget();
- public CreateDrillThroughTargetDlg()
- {
-
-
-
- InitializeComponent();
-
-
-
- }
-
-
-
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows Form Designer generated code
-
-
-
-
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CreateDrillThroughTargetDlg));
- this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
- this.menuItemFile = new System.Windows.Forms.MenuItem();
- this.menuItemExit = new System.Windows.Forms.MenuItem();
- this.menuItemHelp = new System.Windows.Forms.MenuItem();
- this.menuItemAbout = new System.Windows.Forms.MenuItem();
- this.buttonCreateDrillThroughTarget = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.serverUrlTB = new System.Windows.Forms.TextBox();
- this.reportNameLBL = new System.Windows.Forms.Label();
- this.reportListCB = new System.Windows.Forms.ComboBox();
- this.outputBrowser = new AxSHDocVw.AxWebBrowser();
- this.reportSearchPathTB = new System.Windows.Forms.TextBox();
- this.packageListCB = new System.Windows.Forms.ComboBox();
- this.packageLabel = new System.Windows.Forms.Label();
- ((System.ComponentModel.ISupportInitialize)(this.outputBrowser)).BeginInit();
- this.SuspendLayout();
-
-
-
- this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItemFile,
- this.menuItemHelp});
-
-
-
- this.menuItemFile.Index = 0;
- this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItemExit});
- this.menuItemFile.Text = "File";
-
-
-
- this.menuItemExit.Index = 0;
- this.menuItemExit.Text = "Exit";
- this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
-
-
-
- this.menuItemHelp.Index = 1;
- this.menuItemHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItemAbout});
- this.menuItemHelp.Text = "Help";
-
-
-
- this.menuItemAbout.Index = 0;
- this.menuItemAbout.Text = "About";
- this.menuItemAbout.Click += new System.EventHandler(this.menuItemAbout_Click);
-
-
-
- this.buttonCreateDrillThroughTarget.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonCreateDrillThroughTarget.Location = new System.Drawing.Point(560, 136);
- this.buttonCreateDrillThroughTarget.Name = "buttonCreateDrillThroughTarget";
- this.buttonCreateDrillThroughTarget.Size = new System.Drawing.Size(125, 46);
- this.buttonCreateDrillThroughTarget.TabIndex = 0;
- this.buttonCreateDrillThroughTarget.Text = "Create Target";
- this.buttonCreateDrillThroughTarget.Click += new System.EventHandler(this.buttonCreateDrillThroughTarget_Click);
-
-
-
- this.label1.Location = new System.Drawing.Point(19, 18);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(199, 19);
- this.label1.TabIndex = 1;
- this.label1.Text = "Server URL";
-
-
-
- this.serverUrlTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.serverUrlTB.BackColor = System.Drawing.SystemColors.Control;
- this.serverUrlTB.Location = new System.Drawing.Point(19, 37);
- this.serverUrlTB.Name = "serverUrlTB";
- this.serverUrlTB.Size = new System.Drawing.Size(666, 22);
- this.serverUrlTB.TabIndex = 2;
-
-
-
- this.reportNameLBL.Location = new System.Drawing.Point(19, 125);
- this.reportNameLBL.Name = "reportNameLBL";
- this.reportNameLBL.Size = new System.Drawing.Size(96, 18);
- this.reportNameLBL.TabIndex = 3;
- this.reportNameLBL.Text = "Report Name";
-
-
-
- this.reportListCB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.reportListCB.Enabled = false;
- this.reportListCB.Location = new System.Drawing.Point(19, 155);
- this.reportListCB.Name = "reportListCB";
- this.reportListCB.Size = new System.Drawing.Size(522, 24);
- this.reportListCB.TabIndex = 4;
- this.reportListCB.SelectedIndexChanged += new System.EventHandler(this.reportListCB_SelectedIndexChanged);
-
-
-
- this.outputBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.outputBrowser.Enabled = true;
- this.outputBrowser.Location = new System.Drawing.Point(19, 255);
- this.outputBrowser.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("outputBrowser.OcxState")));
- this.outputBrowser.Size = new System.Drawing.Size(666, 358);
- this.outputBrowser.TabIndex = 5;
-
-
-
- this.reportSearchPathTB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.reportSearchPathTB.BackColor = System.Drawing.SystemColors.Control;
- this.reportSearchPathTB.Location = new System.Drawing.Point(19, 209);
- this.reportSearchPathTB.Name = "reportSearchPathTB";
- this.reportSearchPathTB.Size = new System.Drawing.Size(666, 22);
- this.reportSearchPathTB.TabIndex = 6;
-
-
-
- this.packageListCB.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.packageListCB.Location = new System.Drawing.Point(19, 91);
- this.packageListCB.MaxDropDownItems = 32;
- this.packageListCB.Name = "packageListCB";
- this.packageListCB.Size = new System.Drawing.Size(522, 24);
- this.packageListCB.Sorted = true;
- this.packageListCB.TabIndex = 7;
- this.packageListCB.SelectedIndexChanged += new System.EventHandler(this.packageListCB_SelectedIndexChanged);
-
-
-
- this.packageLabel.Location = new System.Drawing.Point(19, 67);
- this.packageLabel.Name = "packageLabel";
- this.packageLabel.Size = new System.Drawing.Size(65, 21);
- this.packageLabel.TabIndex = 8;
- this.packageLabel.Text = "Package";
-
-
-
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
- this.ClientSize = new System.Drawing.Size(704, 629);
- this.Controls.Add(this.packageLabel);
- this.Controls.Add(this.packageListCB);
- this.Controls.Add(this.reportSearchPathTB);
- this.Controls.Add(this.serverUrlTB);
- this.Controls.Add(this.outputBrowser);
- this.Controls.Add(this.reportListCB);
- this.Controls.Add(this.reportNameLBL);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.buttonCreateDrillThroughTarget);
- this.Menu = this.mainMenu1;
- this.Name = "CreateDrillThroughTargetDlg";
- this.Text = "Create DrillThrough Target Sample";
- ((System.ComponentModel.ISupportInitialize)(this.outputBrowser)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- #endregion
- private void menuItemExit_Click(object sender, System.EventArgs e)
- {
- this.Close();
- }
- private void menuItemAbout_Click(object sender, System.EventArgs e)
- {
- SamplesAbout about = new SamplesAbout();
- about.applicationName = "CreateDrillThroughTarget Sample";
- about.applicationVersion = "1.1";
- about.Show();
- }
- private void buttonCreateDrillThroughTarget_Click(object sender, System.EventArgs e)
- {
- string output = "";
- BaseClassWrapper selectedObject = (BaseClassWrapper)reportListCB.SelectedItem;
- try
- {
- if (selectedObject == null)
- {
- MessageBox.Show("Please select a valid entry.");
- return;
- }
-
- output = dtTarget.createDrillThrough(cBIConnection, (BaseClassWrapper)selectedObject, packageListCB.SelectedItem.ToString());
- displayPage(output);
- }
- catch(SoapException ex)
- {
- displayPage("<br>...the operation failed.<br>The following information was returned:<br><br>" +
- SamplesException.getExceptionMessage( ex));
- return;
- }
- catch(System.Exception ex)
- {
- if (0 != ex.Message.CompareTo("INPUT_CANCELLED_BY_USER"))
- {
- SamplesException.ShowExceptionMessage( ex.Message, true, "CreateDrillThroughTarget Sample" );
- displayPage("\n...the operation failed.\nThe page could not be displayed.");
- }
- return;
- }
- }
- public void setReportList(BaseClassWrapper[] reportAndQueryList)
- {
- reportListCB.Items.AddRange(reportAndQueryList);
- }
- public void setPackageList(string[] packageNameList)
- {
- packageListCB.Items.AddRange(packageNameList);
- }
- public void setSelectedPackageIndex(int value)
- {
- packageListCB.SelectedIndex = value;
- }
- public void setSelectedReportIndex(int value)
- {
- reportListCB.SelectedIndex = value;
- }
- public void setConnection(SamplesConnect connection, string cBIUrl)
- {
- cBIConnection = connection;
- cBIServer = connection.CBICMS;
- cBIRS = connection.CBIRS;
- serverUrlTB.Text = cBIUrl;
- }
- public void displayPage(string currentPage)
- {
- string outputFile = "";
- object nullObject = null;
- CommonFunctions cf = new CommonFunctions();
- outputFile = cf.getSamplesPath();
- if (!Directory.Exists(outputFile))
- {
-
-
- outputFile = Directory.GetCurrentDirectory();
- }
- outputFile += "createDrillThroughTargetOutput.htm";
- if (File.Exists(outputFile))
- {
- File.Delete(outputFile);
- }
- StreamWriter sw = new StreamWriter(outputFile);
- sw.WriteLine(currentPage);
- sw.Flush();
- sw.Close();
- outputBrowser.Navigate(outputFile, ref nullObject, ref nullObject, ref nullObject, ref nullObject);
- }
- private void reportListCB_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- BaseClassWrapper selectedObject = (BaseClassWrapper)reportListCB.SelectedItem;
- if (selectedObject == null)
- {
- return;
- }
- reportSearchPathTB.Text = selectedObject.searchPath.value;
- }
- private void packageListCB_SelectedIndexChanged(object sender, EventArgs e)
- {
- try
- {
- setReportList(dtTarget.getPromptedReports(cBIConnection, packageListCB.SelectedItem.ToString()));
- setSelectedReportIndex(0);
- reportListCB.Enabled = true;
- }
- catch (SoapException soapEx)
- {
- displayPage("<br>...the operation failed.<br>The following information was returned by The IBM Cognos Server:<br><br>" +
- SamplesException.getExceptionMessage(soapEx));
- }
-
- }
- }
- }
|