示例#1
0
        protected void btnShowXml_Click(object sender, EventArgs e)
        {
            this.rowXmlSource.Visible = false;
            this.rowResults.Visible   = false;

            try
            {
                // Update data source settings
                this.UpdateDataSourceSettings();

                // Execute the DataSource
                var results = ReportsController.ExecuteReport(this.Report, null,
                                                              true, this);

                // Serialize the results to Xml
                var writer = new StringWriter();
                results.WriteXml(writer);
                this.txtXmlSource.Text    = writer.ToString();
                this.rowXmlSource.Visible = true;
            }
            catch (DataSourceException ex)
            {
                // Format an error message
                this.lblQueryResults.Text =
                    string.Format(Localization.GetString("TestDSFail.Message", this.LocalResourceFile),
                                  ex.LocalizedMessage);
                this.lblQueryResults.CssClass = "NormalRed";
                this.imgQueryResults.ImageUrl = "~/images/red-error.gif";
                this.rowResults.Visible       = true;
                this.rowXmlSource.Visible     = false;
            }
        }
示例#2
0
        protected void btnTestQuery_Click(object sender, EventArgs e)
        {
            this.rowXmlSource.Visible = false;
            this.rowResults.Visible   = false;

            try
            {
                // Update data source settings
                this.UpdateDataSourceSettings();

                // Execute the DataSource
                var results = ReportsController.ExecuteReport(this.Report, null,
                                                              true, this);

                // Format a success message
                this.lblQueryResults.Text = string.Format(Localization.GetString("TestDSSuccess.Message",
                                                                                 this.LocalResourceFile),
                                                          results.Rows.Count);
                this.lblQueryResults.CssClass = "NormalBold";
                this.imgQueryResults.ImageUrl = "~/images/green-ok.gif";
            }
            catch (DataSourceException ex)
            {
                // Format an error message
                this.lblQueryResults.Text =
                    string.Format(Localization.GetString("TestDSFail.Message", this.LocalResourceFile),
                                  ex.LocalizedMessage);
                this.lblQueryResults.CssClass = "NormalRed";
                this.imgQueryResults.ImageUrl = "~/images/red-error.gif";
            }

            // Display the results/error message
            this.rowResults.Visible = true;
        }
示例#3
0
 private bool AutoExecuteReport(VisualizerControlBase ctlVisualizer, ReportInfo report, ref DataTable results,
                                bool fromCache)
 {
     try
     {
         results = ReportsController.ExecuteReport(
             report, string.Concat(ReportsConstants.CACHEKEY_Reports, Convert.ToString(this.ModuleId)),
             report.CacheDuration <= 0, this, ref fromCache);
     }
     catch (DataSourceException ex)
     {
         // Display the error message to host users only
         if (this.UserInfo.IsSuperUser)
         {
             Skin.AddModuleMessage(this,
                                   string.Format(Localization.GetString("HostExecuteError.Message",
                                                                        this.LocalResourceFile),
                                                 ex.LocalizedMessage),
                                   ModuleMessage.ModuleMessageType.RedError);
         }
         else if (this.IsEditable)
         {
             Skin.AddModuleMessage(this,
                                   Localization.GetString("AdminExecuteError.Message",
                                                          this.LocalResourceFile),
                                   ModuleMessage.ModuleMessageType.RedError);
         }
         Services.Exceptions.Exceptions.LogException(ex);
         ctlVisualizer.Visible = false;
         return(false);
     }
     return(true);
 }