简体   繁体   English

如何将参数传递给Windward DocGen?

[英]How do I pass parameters to Windward DocGen?

I need to pass parameters (variables) in to my document template when running a report. 运行报告时,我需要将参数(变量)传递到我的文档模板中。 How do I do this? 我该怎么做呢? I am using the .NET version of Windward. 我正在使用.NET版本的Windward。

You pass the parameters in by attaching them to each datasource. 您可以通过将参数附加到每个数据源来传递参数。 You can set a different set of parameters and values for each datasource. 您可以为每个数据源设置一组不同的参数和值。

You do this by creating a WindwardInterfaces.net.windward.api.csharp.KeyPairDictionary that contains the parameters. 您可以通过创建包含参数的WindwardInterfaces.net.windward.api.csharp.KeyPairDictionary来实现。 The key is a String with the variable name. 密钥是带有变量名称的字符串。 The value can be a String, Number, or DateTime. 该值可以是字符串,数字或日期时间。 The value type should match database column types if the variable will be used as a parameter in a select. 如果将变量用作选择中的参数,则值类型应与数据库列类型匹配。

These are set in the datasource by assigning to the IReportDataSource.Map property. 这些是通过分配给IReportDataSource.Map属性在数据源中设置的。 AdoDataSourceImpl and XmlDataSourceImpl both implement IReportDataSource. AdoDataSourceImpl和XmlDataSourceImpl都实现IReportDataSource。

IReportDataSource datasource = new XmlDataSourceImpl("data.xml");
KeyPairDictionary map = new KeyPairDictionary();
map.Add("now", DateTime.Now);
datasource.Map = map;

Note that variables are carried across datasources if multiple datasources are applied to a template. 请注意,如果将多个数据源应用于模板,则跨数据源携带变量。 If a variable is set in the first datasource, and is not set in the second, it will retain its value from the first. 如果在第一个数据源中设置了变量,而在第二个数据源中未设置,则它将保留第一个数据源中的值。 If it is set in the second, that will override the saved value. 如果在第二个中设置,它将覆盖保存的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM