Report processor architecture issue

I am trying to have a ReportHandler service to handle reporting. Reports can contain several different parameters that can be set. There are currently several different methods for creating reports in the system (MS report services, html reports, etc.) and a method for generating data for each report. I am trying to consolidate everything in ActiveReports. I cannot change the system and change the parameters, so in some cases I essentially get a where clause to generate the results, and in another case I get the key / value pairs that I have to use to generate the results. I was thinking about using the factory pattern, but due to the different number of query filters this will not work.

I would like to have one ReportHandler who will use my various materials and spit out the report. At the moment, I see no other way than using the large switch statement to process each report based on the name of the report. Any suggestions how I could solve this better?

+3
source share
3 answers

From your description, if you are looking for a template that is better than Factory, try Strategy:

Strategy template

  • Context can be a custom class that encapsulates and abstracts the various report inputs (you can use the AbstractFactory template for this part)
  • Your strategy . - , , .

, !

+3

. . , , . - SQL- . , , :

public class ReportContainer{
          public ReportContainer ( IReportEngine reportEngine, IStorageEngine storage, IDeliveryEngine delivery...)
}
}

/// In your service layer you resolve which engines to use
// Either with a bunch of if statements / Factory / config ... 

IReportEngine rptEngine = EngineFactory.GetEngine<IReportEngine>( pass in some values)

IStorageEngine stgEngine = EngineFactory.GetEngine<IStorageEngien>(pass in some values)

IDeliverEngine delEngine = EngineFactory.GetEngine<IDeliverEngine>(pass in some values)



ReportContainer currentContext = new ReportContainer (rptEngine, stgEngine,delEngine);

ReportContainer ...

+3

We had a similar problem, and we went with the concept of “connectors”, which are the interfaces between the main report generator and various reporting mechanisms. By doing this, we were able to create a universal report server application. You should check this out at www.versareports.com.

0
source

Source: https://habr.com/ru/post/1698148/


All Articles