Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Generic Report Running

Generic Report Running

Scheduled Pinned Locked Moved C#
databasehelpdata-structurestoolstutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eddieangel
    wrote on last edited by
    #1

    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
    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:

    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:

    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

    M 1 Reply Last reply
    0
    • E eddieangel

      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
      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:

      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:

      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

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      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

      E 1 Reply Last reply
      0
      • M Mycroft Holmes

        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

        E Offline
        E Offline
        eddieangel
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • E eddieangel

          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

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          We 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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups