public void SerializationTest() { const string ReportName = "Report"; const string KeyName = "item "; const string ValueName = "value "; const int ParamCount = 2; var reportParameters = new Dictionary<string, object>(); for (var i = 0; i < ParamCount; i++) { reportParameters.Add(KeyName + i, ValueName + i); } var report = new ReportInfo(ReportName, reportParameters); var serializedReport = report.ToString(); var deserializedReport = serializedReport.ToReportInfo(); Assert.AreEqual(deserializedReport.ReportName, ReportName); for (var i = 0; i < ParamCount; i++) { Assert.AreEqual(deserializedReport.ReportParametres[KeyName + i], ValueName + i); } }
protected void btnSaveReportAs_Click(object sender, EventArgs e) { AdminController aCont = new AdminController(); ReportInfo Report = new ReportInfo(); Report.PortalId = PortalId; if (ddlReportType.SelectedIndex != 0) { Report.ReportType = Convert.ToInt32(ddlReportType.SelectedValue); } if (ddlReportAdvertiser.SelectedIndex != 0) { Report.AdvertiserId = Convert.ToInt32(ddlReportAdvertiser.SelectedValue); } if (ddlReportAgency.SelectedIndex != 0) { Report.AgencyId = Convert.ToInt32(ddlReportAgency.SelectedValue); } if (ddlReportFrequency.SelectedIndex != 0) { Report.Frequency = ddlReportFrequency.SelectedValue; } if (ddlReportStatus.SelectedIndex != 0) { Report.Status = Convert.ToInt32(ddlReportStatus.SelectedValue); } Report.EmailMessage = txtEmailMessage.Text; Report.EmailTo = txtReportEmailTo.Text; try { Report.FirstReportDate = Convert.ToDateTime(txtReportStartDate.Text); } catch { } Report.isActive = chkReportActive.Checked; Report.Keyword = txtReportKeyword.Text; Report.ReportName = txtReportName.Text; Report.LastModifiedById = UserId; Report.LastModifiedDate = DateTime.Now; Report.CreatedById = UserId; Report.DateCreated = DateTime.Now; int ReportId = aCont.Add_Report(Report); txtSelectedReport.Value = Report.ToString(); txtReportCreatedBy.Value = UserId.ToString(); txtReportCreatedBy.Value = DateTime.Now.Ticks.ToString(); lblReportsMessage.Text = "Report Saved."; btnDeleteReport.Enabled = true; btnSaveReportAs.Enabled = true; fillReports(); }
/// <summary> /// Gets the report stream. /// </summary> /// <param name="item">The item.</param> /// <param name="reportName">Name of the report.</param> /// <returns>MemoryStream.</returns> private MemoryStream GetReportStream(IEditableRoot item, string reportName) { var dict = GetReportParametersDict(item); var reportProcessor = new ReportProcessor(); reportProcessor.Error += ReportProcessorError; var reportInfo = new ReportInfo(string.Format(CultureInfo.InvariantCulture, "?<customReport title=\"\" description=\"\" fileName=\"{0}\" />", reportName), dict); var reportSource = TheReportResolver.Resolve(reportInfo.ToString()); Telerik.Reporting.Processing.RenderingResult result; // Mq1ReportResolver changes the principal, so we'll have to restore it later. var user = ApplicationContext.User; try { result = reportProcessor.RenderReport("PDF", reportSource, null); } finally { ApplicationContext.User = user; } return new MemoryStream(result.DocumentBytes); }