Как отправить параметр в действие печати отчета stimulsoft?

#c# #asp.net-core #reporting #stimulsoft

#c# #asp.net-core #отчетность #stimulsoft

Вопрос:

У меня есть отчет, созданный stimulsoft в asp.net ядро и в поле зрения установите это действие:

 @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);
}
  

в приведенном выше действии, как я могу получить идентификатор??

а затем это действие для печати отчета:

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

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

    }
  

в приведенном выше действии мне снова нужен идентификатор. как получить доступ к значению идентификатора???

Комментарии:

1. Что такое _insuranceService и идентификатор, который вы хотите получить?

Ответ №1:

Определите «ID» в качестве переменной в вашем отчете, затем попробуйте добавить это в свой код перед загрузкой отчета:

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