var ctx = this.Context;
ISysReportService sysReporSservice = ServiceFactory.GetSysReportService(ctx);
IPermissionService permissionService = ServiceFactory.GetPermissionService(ctx);
var filterMetadata = FormMetaDataCache.GetCachedFilterMetaData(ctx);//加载字段比较条件元数据。
var reportMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, "xxxx");//xxxx 传简单账表标识
var reportFilterMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, "xxxx");//xxxx 传简单账表过滤器标识
var reportFilterServiceProvider = reportFilterMetadata.BusinessInfo.GetForm().GetFormServiceProvider();
var model = new SysReportFilterModel();
model.SetContext(ctx, reportFilterMetadata.BusinessInfo, reportFilterServiceProvider);
model.FormId = reportFilterMetadata.BusinessInfo.GetForm().Id;
model.FilterObject.FilterMetaData = filterMetadata;
model.InitFieldList(reportMetadata, reportFilterMetadata);
model.GetSchemeList();
var entity = model.Load("522ce96c19d7464c84e24e08381058c6");//过滤方案的主键值,可通过该SQL语句查询得到:SELECT * FROM T_BAS_FILTERSCHEME
var filter = model.GetFilterParameter();//获取方案保存参数,也可以自己保存方案,然后查询出来id传入到model.Load(“自己保存参数ID”)
IRptParams rptParams = new RptParams
{
FormId = reportFilterMetadata.BusinessInfo.GetForm().Id,
StartRow = 1,
EndRow = int.MaxValue,//StartRow和EndRow是报表数据分页的起始行数和截至行数,一般取所有数据,所以EndRow取int最大值。
FilterParameter = filter,
FilterFieldInfo = model.FilterFieldInfo
};
rptParams.CustomParams.Add("OpenParameter", "");
rptParams.BaseDataTempTable.AddRange(permissionService.GetBaseDataTempTable(ctx, reportMetadata.BusinessInfo.GetForm().Id));
#endregion
return sysReporSservice.GetDataTableName(ctx, reportMetadata.BusinessInfo, rptParams);
推荐阅读