/// <summary>
        /// Creates a node of type ReportTreeNode based on information specified from the XML report
        /// configuration file.
        /// </summary>
        /// <param name="currentNode">Current report XML node from config file</param>
        /// <returns></returns>
        private TreeNode GetReportTreeNode(XmlNode currentNode)
        {
            string            nodeFileName;
            string            nodeNameLabel;
            string            nodeReportDefinition;
            bool              nodeDisplayHosts;
            bool              nodeDisplayFilter;
            bool              nodeDisplayUsers;
            bool              nodeDisplayAuditObjects;
            OrderedDictionary nodeParamDict;
            WlbReportInfo     reportInfo;
            TreeNode          reportTreeNode;

            nodeFileName = currentNode.Attributes["File"].Value;

            XmlElement queryParametersXmlElement = GetCustomXmlElement(currentNode, "Creedence", "QueryParameters");

            // If the report definition node doesn't exist (old WLB version), load the definition from the
            // local file system.  Otherwise, the definition is present in the config from the WLB server
            if (currentNode.SelectSingleNode(@"Rdlc") == null)
            {
                XmlDocument xmlReportDefinition = new XmlDocument();
                xmlReportDefinition.Load(String.Format(@"{0}\{1}", Application.StartupPath.ToString(), nodeFileName));
                nodeReportDefinition = xmlReportDefinition.OuterXml.ToString();
            }
            else
            {
                nodeReportDefinition = currentNode.SelectSingleNode(@"Rdlc").InnerText;
            }


            // If the report definition was obtained from the WLB server, use the localized name provided.
            // Otherwise, get the label locally.  If all else fails, just use NameLabel attribute from
            // xml config
            if (currentNode.Attributes["Name"] != null)
            {
                nodeNameLabel = currentNode.Attributes["Name"].Value;
            }
            else if (Messages.ResourceManager.GetObject(currentNode.Attributes["NameLabel"].Value) != null)
            {
                nodeNameLabel = Messages.ResourceManager.GetObject(currentNode.Attributes["NameLabel"].Value).ToString();
            }
            else
            {
                nodeNameLabel = currentNode.Attributes["NameLabel"].Value;
            }


            // Boolean variuable to determine the display the Filter drop down menu?
            if (currentNode.SelectSingleNode(@"QueryParameters/QueryParameter[@Name='Filter']") == null)
            {
                nodeDisplayFilter = false;
            }
            else
            {
                nodeDisplayFilter = true;
            }


            // Boolean variuable to determine the display the Host drop down menu?
            if (currentNode.SelectSingleNode(@"QueryParameters/QueryParameter[@Name='HostID']") == null)
            {
                nodeDisplayHosts = false;
            }
            else
            {
                nodeDisplayHosts = true;
            }

            // Boolean variable to determine the display of the User drop down menu
            if (currentNode.SelectSingleNode(@"QueryParameters/QueryParameter[@Name='AuditUser']") == null)
            {
                nodeDisplayUsers = false;
            }
            else
            {
                nodeDisplayUsers = true;
            }

            // Boolean variable to determine the display of the Object drop down menu
            if (currentNode.SelectSingleNode(@"QueryParameters/QueryParameter[@Name='AuditObject']") == null)
            {
                nodeDisplayAuditObjects = false;
            }
            else
            {
                nodeDisplayAuditObjects = true;
            }

            // Get a list of query params
            nodeParamDict = GetSQLQueryParamNames(currentNode, queryParametersXmlElement);

            // Create a report node and add it to the treeview for the current report
            reportInfo = new WlbReportInfo(nodeNameLabel,
                                           nodeFileName,
                                           nodeReportDefinition,
                                           nodeDisplayHosts,
                                           nodeDisplayFilter,
                                           nodeDisplayUsers,
                                           nodeDisplayAuditObjects,
                                           nodeParamDict);

            reportTreeNode                    = new TreeNode();
            reportTreeNode.Tag                = reportInfo;
            reportTreeNode.Text               = nodeNameLabel;
            reportTreeNode.ImageIndex         = 0;
            reportTreeNode.SelectedImageIndex = 0;

            return(reportTreeNode);
        }
Exemple #2
0
        /// <summary>
        /// Reset reportViewer after reportInfo is changed
        /// </summary>
        /// <param name="reportInfo">ReportInfo instance</param>
        public void SynchReportViewer(WlbReportInfo reportInfo)
        {
            this.ViewerReportInfo = reportInfo;

            if (ResetReportViewer == true)
            {
                this.reportViewer1.Reset();
            }

            ResetReportViewer = true;

            // Enable the run and disable subscribe buttons
            this.btnRunReport.Enabled = true;
            this.btnSubscribe.Enabled = false;

            // If host is a parameter for the selected report, show it
            if (reportInfo.DisplayHosts == true)
            {
                // Some serious hackage to get the correct host selected in the dropdown if the
                // parameter is being forced through other means (subreport or drillthrough)
                if (this.ViewerLocalReport != null)
                {
                    string currentHostID;

                    for (int i = 0; i < this.ViewerLocalReport.OriginalParametersToDrillthrough.Count; i++)
                    {
                        if (this.ViewerLocalReport.OriginalParametersToDrillthrough[i].Name == "HostID")
                        {
                            currentHostID = this.ViewerLocalReport.OriginalParametersToDrillthrough[i].Values[0];

                            for (int j = 0; j < this.hostComboBox.Items.Count; j++)
                            {
                                if (((Host)this.hostComboBox.Items[j]).uuid == currentHostID)
                                {
                                    this.hostComboBox.SelectedIndex = j;
                                    break;
                                }
                            }
                        }
                    }
                }

                // If none of the above worked out, we set it here
                if ((this.hostComboBox.SelectedIndex < 0) && (this.hostComboBox.Items.Count > 0))
                {
                    this.hostComboBox.SelectedIndex = 0;
                }

                // Set control items accordingly
                this.panelHosts.Visible = true;
            }
            else
            {
                // Host dropdown does not need to be displayed
                this.panelHosts.Visible = false;
            }

            if (reportInfo.DisplayFilter)
            {
                this.panelShow.Visible = true;
                SetViewComboBox(reportInfo.ReportFile);
                this.comboBoxView.SelectedIndex = 0;
            }
            else
            {
                this.panelShow.Visible = false;
            }

            this.Visible = true;
        }