Click here to Skip to main content
15,886,137 members
Home / Discussions / C#
   

C#

 
QuestionOO Design Pin
KeithF30-Jul-13 22:53
KeithF30-Jul-13 22:53 
QuestionRe: OO Design Pin
Eddy Vluggen31-Jul-13 8:36
professionalEddy Vluggen31-Jul-13 8:36 
AnswerRe: OO Design Pin
KeithF31-Jul-13 21:58
KeithF31-Jul-13 21:58 
Questionfilter interface Pin
Atul Kumar Singh230-Jul-13 19:44
Atul Kumar Singh230-Jul-13 19:44 
AnswerRe: filter interface Pin
Abhinav S30-Jul-13 19:53
Abhinav S30-Jul-13 19:53 
GeneralRe: filter interface Pin
Atul Kumar Singh21-Aug-13 6:35
Atul Kumar Singh21-Aug-13 6:35 
AnswerRe: filter interface Pin
Richard Andrew x641-Aug-13 11:22
professionalRichard Andrew x641-Aug-13 11:22 
QuestionGeneric Report Running Pin
eddieangel30-Jul-13 9:43
eddieangel30-Jul-13 9:43 
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:

SQL
USE [litigatorPro]
GO

/****** Object:  Table [dbo].[ReportQueue]    Script Date: 07/30/2013 12:36:39 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

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:

SQL
USE [litigatorPro]
GO

/****** Object:  Table [dbo].[Report]    Script Date: 07/30/2013 12:37:26 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

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:

C#
private bool RunReport<T>(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:

C#
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<type>(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:

C#
if (RunReport<type>(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
AnswerRe: Generic Report Running Pin
Mycroft Holmes30-Jul-13 12:40
professionalMycroft Holmes30-Jul-13 12:40 
GeneralRe: Generic Report Running Pin
eddieangel30-Jul-13 12:49
eddieangel30-Jul-13 12:49 
GeneralRe: Generic Report Running Pin
Mycroft Holmes30-Jul-13 14:20
professionalMycroft Holmes30-Jul-13 14:20 
QuestionHow to monitor and block a registry key change? Pin
turbosupramk330-Jul-13 8:07
turbosupramk330-Jul-13 8:07 
AnswerRe: How to monitor and block a registry key change? Pin
Dave Kreskowiak30-Jul-13 9:27
mveDave Kreskowiak30-Jul-13 9:27 
GeneralRe: How to monitor and block a registry key change? Pin
turbosupramk331-Jul-13 4:13
turbosupramk331-Jul-13 4:13 
GeneralRe: How to monitor and block a registry key change? Pin
Dave Kreskowiak31-Jul-13 5:58
mveDave Kreskowiak31-Jul-13 5:58 
GeneralRe: How to monitor and block a registry key change? Pin
Eddy Vluggen31-Jul-13 8:39
professionalEddy Vluggen31-Jul-13 8:39 
AnswerRe: How to monitor and block a registry key change? Pin
FIorian Schneidereit30-Jul-13 15:54
FIorian Schneidereit30-Jul-13 15:54 
GeneralRe: How to monitor and block a registry key change? Pin
turbosupramk331-Jul-13 2:41
turbosupramk331-Jul-13 2:41 
QuestionProblem in creating Report Pin
Arun kumar Gautam30-Jul-13 3:32
Arun kumar Gautam30-Jul-13 3:32 
AnswerRe: Problem in creating Report Pin
Mycroft Holmes30-Jul-13 12:42
professionalMycroft Holmes30-Jul-13 12:42 
JokeRe: Problem in creating Report Pin
UL UL ALBAB30-Jul-13 23:32
UL UL ALBAB30-Jul-13 23:32 
QuestionSystem,Timers.Timer to slow in C# Pin
Member 994007329-Jul-13 23:28
Member 994007329-Jul-13 23:28 
AnswerRe: System,Timers.Timer to slow in C# Pin
Pete O'Hanlon30-Jul-13 0:23
mvePete O'Hanlon30-Jul-13 0:23 
GeneralRe: System,Timers.Timer to slow in C# Pin
Member 994007330-Jul-13 1:49
Member 994007330-Jul-13 1:49 
GeneralRe: System,Timers.Timer to slow in C# Pin
AmitGajjar30-Jul-13 2:41
professionalAmitGajjar30-Jul-13 2:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.