End Google Ads 201810 - BS.net 01 --> 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 ONGO SET QUOTED_IDENTIFIER ONGO CREATE 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 ONGO SET QUOTED_IDENTIFIER ONGO CREATE 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 what I am looking at with crossed eyes right now:

private int ProcessReport(ReportQueue item) { using (litigatorProEntities _db = new litigatorProEntities()) { ReportPolling.Model.Report report = _db.Reports.Single(r => r.id == item.reportId); Type type = Type.GetType(report.reportType); if (RunReport(report)) { return 1; } return 2; } return 2; }
I need to figure out how to supply the type based on a text field from the DB as seen in the line that says:

if (RunReport(report))
After that I will figure out how to pass the arguments (userId, claimId, propertyId, etc...)

I am not great with some of the fundamental items like generics and boxing, so forgive me if the question is stupid.

Cheers, --EA