Data Sources

Moxy uses two delegates to request data for a report.  These delegates need to be set before using the ReportBuilder to build a report.  They can either be set once and refer to static functions, or they can be set per ReportQuery and refer to a instance of another class.

GetDataSource

This delegate is used to load data associated with a dataSource.

Parameters

ReportDataSource

The details of the data source that is being loaded.  The dataSouce has a number of parameters which can be specified in the XML and can then be used to load the appropriate data.  These parameters are: Source, Select and For.

ReportContext

This stores contextual information about the logged in user, or account.  Example:

var accountId = context.GetContext<Guid>(“AccountId”);

ReportQuery

The query that is being executed.  Report option values can be loaded from the query using query.GetReportOptionValue(id, default).  Data can be added to the Report using query.Report.AddSubjectData(...)

GetReportOptions

This delegate is used to load data associated with a report option. For example, an option may provide a list of customer names which need to be populated from the database.

Parameters

ReportOption

The option that data is being loaded for.  The option XML will specify a data attribute, which can be accessed using option.OptionTypeCode.

The option has a list of ReportOptionItems, each of which have a key and a value.

ReportContext

This stores contextual information about the logged in user, or account.  Example:

var accountId = context.GetContext<Guid>(“AccountId”);

ReportQuery

The query that is being executed.  Report option values can be loaded from the query using query.GetReportOptionValue(id, default).  Data can be added to the Report using query.Report.AddSubjectData(...)

Example

public class ReportService

{        

   public static void GetReportQueryData(ReportOption option, ReportContext context, ReportQuery query)

   { ... }

   public static void GetReportData(ReportOption option, ReportContext context, ReportQuery query)

   { ... }

}

ReportBuilder.DataSourceCallback =

        new ReportBuilder.GetDataSourceCallback(ReportService.GetReportData);

ReportBuilder.ReportOptionsCallback =

        new ReportBuilder.GetReportOptionsCallback(ReportService.GetReportQueryData);


Click to see Comments

Help comments powered by Disqus