I developed a method for processing multiple subscriptions in an rdlc report, but since I tried to make it universal and repeatable, I had to take a model and tweak it a little for each case.
For example, if I define an abstract interface, for example, I just cut and paste it from winform into winform as needed:
abstract class ISolutionStrategy { public abstract void AlgorithmInterface(Int64 searchCriteria, SubreportProcessingEventArgs e); }
First, I want to be able to bring this into every form by including a has-a object. I also want to encapsulate the dispatch processing behavior of the delegate and make the processing methods "generic" as well.
So, design requirements:
- Create an object that can be included in winform to handle multiple subscription processing
- Create and customize an object in winform
- Create a distribution table or switch / case statement in winform
- Pass all the processing methods for specific requirements of this winform report viewer
The goal is to make an object that you can test autonomously and make reliable, and also do not need to cut and paste the wheel and perform a bunch of manual settings for each new winform.
It seems to me that someone has found a better design there than the one I have.
Create an object that can be included in winform to handle multiple subscription processing
So far, I have a delegate in the local forms load event:
this.reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
which is processed by the switch statement in the * LocalReport_SubreportProcessing * method.
The body of the method contains a switch statement:
void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e) { String commonSubreportKey = _commonSubreportKey; switch (e.ReportPath) { case "rptSubAlternateParts": runSubAlternatePart(e, commonSubreportKey, new GetAlternateParts()); break; case "rptSubGetAssemblies": runSubFailurePart(e, commonSubreportKey, new GetAssemblies()); break; case "rptSubGetAssemblies": runSubGetGetEndItemLRMFailureInfo(e, commonSubreportKey, new GetEndItemLRMFailureInfo()); break; case "rptSubGetAssemblies": runSubGetSubAssemblies(e, commonSubreportKey, new GetSubAssemblies()); break; default: break; }
Aside:In my opinion, the switch is mostly human readable compared to the alternative I was considering. I examined the use of a hash with the report name as a key and function call data as a value. However, I did not know how to do this, and I thought it would be harder for someone else to understand.
After that, the function is called, which reorders the information passed from the function call in the switch statement:
private static void runSubAlternatePart(SubreportProcessingEventArgs e1, String commonReportKey, GetAlternatePart myAP) { myAP.AlgorithmInterface(commonReportKey, e1); }
This rearrangement is certainly a stuttering code, but it seems to be a necessary gap to the strategy template that I am trying to implement:
abstract class IStrategy { public abstract void AlgorithmInterface(String searchParam, SubreportProcessingEventArgs e); }
Here is a concrete implementation of the Strategy for one of the reports:
class GetAlternatePart : IStrategy { private BLL.AlternatePartBLL ds = new BLL.AlternatePartBLL(); public override void AlgorithmInterface(String searchParam, SubreportProcessingEventArgs e) { e.DataSources.Clear(); DataTable myDataTable = ds.GetAlternativePart(searchParam); DataSet myDataSet = new DataSet(); myDataSet.Tables.Add(myDataTable); e.DataSources.Add(new ReportDataSource("BLL_AlternatePartBLL", myDataSet.Tables[0])); } } }
In any case, my desire is not to translate the same logic between reports, since I have many reports with several reports.
I would like the library quality method to use a class to dynamically create middle parts where stuttering occurs, and I would like to pass a “anonymous” funciton that actually implements a detailed subheading connection with its corresponding source data.
For one report with subtitles or even several one-time reports, what I do is all right, but how can it be made less manual, more reliable and more verifiable?
My environment is Visual Studio 2008 with the goal of .NET 3.5; there seems to be a difference in how abstract classes are declared and how they are compiled.