Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        /// <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;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reset reportViewer after reportInfo is changed
        /// </summary>
        /// <param name="reportInfo">ReportInfo instance</param>
        public void SynchReportViewer(WlbReportInfo reportInfo)
        {
            if(reportInfo.ReportFile.StartsWith("pool_audit_history"))
            {
                _isAuditReport = true;
                InitializeAuditReport();
            }
            else
            {
                _isAuditReport = false;
            }

            this.btnLaterReport.Visible = false;
            this.ViewerReportInfo = reportInfo;

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

            ResetReportViewer = true;

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

            // Set the run button text
            this.btnRunReport.Text = Messages.RUN_REPORT;

            // 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;
            }


            if (reportInfo.DisplayUsers)
            {
                // User dropdown needs to be displayed
                this.panelUsers.Visible = true;
                if(!_userComboSet)
                {
                    // Fill user dropdown with user list retrieved from WLB server
                    string audit_users_string = reportInfo.ReportQueryParameterNames["AuditUser"].ToString();
                    string[] audit_users = audit_users_string.Length > 0 ? audit_users_string.Split(',') : (new string[0]);
                    Array.Sort(audit_users, StringComparer.InvariantCulture);
                    this.SetUserComboBox(audit_users);
                    _userComboSet = true;
                }

            }
            else
            {
                // Users dropdown does not need to be displayed
                this.panelUsers.Visible = false;
            }


            if (reportInfo.DisplayAuditObjects)
            {
                // Object dropdown needs to be displayed
                this.panelObjects.Visible = true;
                if(!_objectComboSet)
                {
                    // Fill object dropdown with object list retrieved from WLB server
                    string audit_objects_string = reportInfo.ReportQueryParameterNames["AuditObject"].ToString();
                    string[] audit_objects = audit_objects_string.Length > 0 ? audit_objects_string.Split(',') : (new string[0]);
                    Array.Sort(audit_objects, StringComparer.InvariantCulture);
                    this.SetObjectComboBox(audit_objects);
                    _objectComboSet = true;
                }

            }
            else
            {
                // Objects dropdown does not need to be displayed
                this.panelObjects.Visible = false;
            }


            this.Visible = true;
        }