Generic Report Running
-
I know this is long, so please try not to TLDR me I have a reporting service that allows users to queue reports. All fine and dandy, they queue it, it goes into a database. I have a service that polls the DB queue and runs reports. I am stuck on the run part right now. The reports are Telerik reports, but it is not really relevant as it would be the same if they were crystal or anything else. I want to store the report type in the DB and pull it at run time. The report queue looks like this:
USE [litigatorPro]
GO/****** Object: Table [dbo].[ReportQueue] Script Date: 07/30/2013 12:36:39 ******/
SET ANSI_NULLS ON
GOSET QUOTED_IDENTIFIER ON
GOCREATE TABLE [dbo].[ReportQueue](
[id] [int] IDENTITY(1,1) NOT NULL,
[reportId] [int] NOT NULL,
[userId] [int] NOT NULL,
[statusId] [int] NOT NULL,
[claimId] [int] NULL,
[propertyId] [int] NULL,
[startDate] [datetime] NULL,
[endDate] [datetime] NULL,
[datestamp] [datetime] NOT NULL,
CONSTRAINT [PK_ReportQueue] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]GO
And the Report table:
USE [litigatorPro]
GO/****** Object: Table [dbo].[Report] Script Date: 07/30/2013 12:37:26 ******/
SET ANSI_NULLS ON
GOSET QUOTED_IDENTIFIER ON
GOCREATE TABLE [dbo].[Report](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](100) NOT NULL,
[fileName] [nvarchar](100) NOT NULL,
[queryString] [nvarchar](2500) NOT NULL,
[scopeId] [int] NOT NULL,
[reportType] [nvarchar](50) NULL,
CONSTRAINT [PK_Report] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]GO
Some of the fields are not use, but the important point is that the service checks the report queue table and gets the report type and parameters. I want to then process the report using something like this:
private bool RunReport(int id) where T: Telerik.Reporting.Report
{
var targetReport = (T)Activator.CreateInstance(typeof(T), new object[] { id });
//Do something, figure out how to pass parameters, maybe make int id into object params
return false;
}The issue, for now, is how to call the function with information from the DB. Here is wh
-
I know this is long, so please try not to TLDR me I have a reporting service that allows users to queue reports. All fine and dandy, they queue it, it goes into a database. I have a service that polls the DB queue and runs reports. I am stuck on the run part right now. The reports are Telerik reports, but it is not really relevant as it would be the same if they were crystal or anything else. I want to store the report type in the DB and pull it at run time. The report queue looks like this:
USE [litigatorPro]
GO/****** Object: Table [dbo].[ReportQueue] Script Date: 07/30/2013 12:36:39 ******/
SET ANSI_NULLS ON
GOSET QUOTED_IDENTIFIER ON
GOCREATE TABLE [dbo].[ReportQueue](
[id] [int] IDENTITY(1,1) NOT NULL,
[reportId] [int] NOT NULL,
[userId] [int] NOT NULL,
[statusId] [int] NOT NULL,
[claimId] [int] NULL,
[propertyId] [int] NULL,
[startDate] [datetime] NULL,
[endDate] [datetime] NULL,
[datestamp] [datetime] NOT NULL,
CONSTRAINT [PK_ReportQueue] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]GO
And the Report table:
USE [litigatorPro]
GO/****** Object: Table [dbo].[Report] Script Date: 07/30/2013 12:37:26 ******/
SET ANSI_NULLS ON
GOSET QUOTED_IDENTIFIER ON
GOCREATE TABLE [dbo].[Report](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](100) NOT NULL,
[fileName] [nvarchar](100) NOT NULL,
[queryString] [nvarchar](2500) NOT NULL,
[scopeId] [int] NOT NULL,
[reportType] [nvarchar](50) NULL,
CONSTRAINT [PK_Report] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]GO
Some of the fields are not use, but the important point is that the service checks the report queue table and gets the report type and parameters. I want to then process the report using something like this:
private bool RunReport(int id) where T: Telerik.Reporting.Report
{
var targetReport = (T)Activator.CreateInstance(typeof(T), new object[] { id });
//Do something, figure out how to pass parameters, maybe make int id into object params
return false;
}The issue, for now, is how to call the function with information from the DB. Here is wh
I've just started using Telerik reports and use the .trdx file, have not worked out how to pass in parameters but I'm certain it can be done then the viewer displays! Ahh the light goes on, you want it to process, I'll await further enlightenment (should have deleted this reply I suppose :( )
Never underestimate the power of human stupidity RAH
-
I've just started using Telerik reports and use the .trdx file, have not worked out how to pass in parameters but I'm certain it can be done then the viewer displays! Ahh the light goes on, you want it to process, I'll await further enlightenment (should have deleted this reply I suppose :( )
Never underestimate the power of human stupidity RAH
I have used Telerik a bit so I am not super unfamiliar with it. So that I am not sitting on my hands all day I decided to just switch() the report name parameter until I can figure out the anonymous access piece.
private bool RunReport(string reportName, int? claimId, int? propertyId, int? ecrId)
{
switch (reportName)
{
case "COR - Cost Summary By Address":
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource(); CostSummaryByAddress myReport = new CostSummaryByAddress(ecrId, claimId); instanceReportSource.ReportDocument = myReport; Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo); string fileName = result.DocumentName + "." + result.Extension; string path = System.IO.Path.GetTempPath(); string filePath = System.IO.Path.Combine(path, fileName); using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } break; } return true; }
And the report class:
public partial class CostSummaryByAddress : Telerik.Reporting.Report
{
public CostSummaryByAddress(int? ecrId, int? claimId)
{
if (ecrId == null)
{
ecrId = 1;
}
InitializeComponent();
using (litigatorProEntities _db = new litigatorProEntities())
{
var model = from d in _db.ECRDatas.Where(e => e.ecrId == ecrId)
select new CostSummaryViewModel
{
claimName = d.ECR.Claim.description,
property = d.property,
totalCost = d.totalCost
};
this.DataSou -
I have used Telerik a bit so I am not super unfamiliar with it. So that I am not sitting on my hands all day I decided to just switch() the report name parameter until I can figure out the anonymous access piece.
private bool RunReport(string reportName, int? claimId, int? propertyId, int? ecrId)
{
switch (reportName)
{
case "COR - Cost Summary By Address":
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource(); CostSummaryByAddress myReport = new CostSummaryByAddress(ecrId, claimId); instanceReportSource.ReportDocument = myReport; Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo); string fileName = result.DocumentName + "." + result.Extension; string path = System.IO.Path.GetTempPath(); string filePath = System.IO.Path.Combine(path, fileName); using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } break; } return true; }
And the report class:
public partial class CostSummaryByAddress : Telerik.Reporting.Report
{
public CostSummaryByAddress(int? ecrId, int? claimId)
{
if (ecrId == null)
{
ecrId = 1;
}
InitializeComponent();
using (litigatorProEntities _db = new litigatorProEntities())
{
var model = from d in _db.ECRDatas.Where(e => e.ecrId == ecrId)
select new CostSummaryViewModel
{
claimName = d.ECR.Claim.description,
property = d.property,
totalCost = d.totalCost
};
this.DataSouWe use SSRS for our server based reporting, Telerik will only be used for reports embedded into the application, there is no integrated viewer for any other reporting system in SilverLight.
Never underestimate the power of human stupidity RAH