如何向stimulsoft报告打印操作发送参数?

问题描述 投票:0回答:2

我有一个由 stimulsoft 在 ASP.NET Core 中创建的报告 并在视图中设置此操作:

@using Stimulsoft.Report.Mvc;

@Html.Stimulsoft().StiMvcViewer(new StiMvcViewerOptions()
{
    Actions =
    {
        GetReport = "GetReport",
        PrintReport = "PrintReport",            
        ViewerEvent = "ViewerEvent"
    }
})

并有3个动作:

public async Task<IActionResult> PrintInsurance(int id)
    {          
       return View();
    }

id 参数需要加载报告信息。

public ActionResult GetReport()
{
var insurance = await _insuranceService.GetInsuranceForEdit(id);
        StiReport report = new StiReport();
        report.Load(StiNetCoreHelper.MapPath(this, 
           "wwwroot/Reports/PrintInsurance.mrt"));

        report.RegData("dt", insurance);
        return StiNetCoreViewer.GetReportResult(this, report);
}

在上述操作中我如何获得ID?

然后打印报告的此操作:

public async Task<IActionResult> PrintReport()
    {
        //Change State To Printed

        bool result = await _insuranceService.ChangeToPrinted((int)id,User.Identity.Name);
        return StiNetCoreViewer.PrintReportResult(this);

    }

在上述操作中我再次需要 ID。如何获取id值???

c# asp.net-core reporting stimulsoft
2个回答
0
投票

将“ID”定义为报告中的变量,然后在加载报告之前尝试将其添加到代码中:

string ID = "ID";
report.Dictionary.Variables("ID").Value = ID;

0
投票

我有同样的问题,事实上,我想从程序内调用带有参数的操作,然后使用存储库创建查询并将从该查询获得的信息发送到报告。如何?我不知道

© www.soinside.com 2019 - 2024. All rights reserved.