В настоящее время я работаю над проектом FastReport в приложении .NET и сталкиваюсь с исключением CompilerException при попытке использовать источник данных OperationSupplies. Вот контекст моей проблемы:
Описание проблемы
Я определил в своем отчете FastReport два источника данных: Operations и OperationSupplies. Хотя источник данных Operations работает правильно, у меня возникли проблемы с источником данных OperationSupplies. В частности, я получаю следующие ошибки компиляции:
FastReport.Utils.CompilerException: (Cell191): ошибка CS0103: имя «OperationSupplies» не существует в текущем контексте
(Cell192): ошибка CS0103: имя «OperationSupplies» не существует в текущем контексте
(Cell193): Ошибка CS0103: Имя «OperationSupplies» не существует в текущем контексте
(Cell194): Ошибка CS0103: Имя «OperationSupplies» не существует в текущем контексте
мой источник данных
и мой код
public async Task PrintOperationsListReport(int type, DateTime? DateFrom, DateTime? DateTo, int? DoctorId)
{
var DoctorName = "";
var model = await _operationsRepository.GetOperationsForReport(DateFrom, DateTo, DoctorId);
if (DoctorId != 0)
{
var doctorRequestModel = new GetDoctorOneQuery()
{
DoctorId = DoctorId ?? 0,
};
var doctorInfo = await mediator.Send(doctorRequestModel);
DoctorName = doctorInfo.FirstName + " " + doctorInfo.LastName;
}
WebReport web = new WebReport();
string path = "";
string reportName = type == 0 ? "OperationsListReport" : "OperationsListReportWithConsumables";
path = Directory.GetCurrentDirectory() + $"\\wwwroot\\reports\\{reportName}.frx";
web.Report.Load(path);
PictureObject picture = web.Report.FindObject("Picture1") as PictureObject;
var company = await mediator.Send(new GetCompanyInfoQuery());
string url = company == null ? "" : company.UrlReport;
picture.ImageLocation = Directory.GetCurrentDirectory() + "\\wwwroot\\Upload\\" + url;
var total = model.Sum(a => a.Total);
var operationsTotalPrice = model.Sum(a => a.OperationPrice);
web.Report.SetParameterValue("FromDate", DateFrom.Value.ToString("MM/dd/yyyy"));
web.Report.SetParameterValue("ToDate", DateTo.Value.ToString("MM/dd/yyyy"));
web.Report.SetParameterValue("AllTotal", total);
web.Report.SetParameterValue("OperationsPriceTotal", operationsTotalPrice);
web.Report.SetParameterValue("NetProfit", operationsTotalPrice - total);
web.Report.SetParameterValue("DoctorName", DoctorName);
web.Report.RegisterData(model, "Operations");
// Register nested data source
foreach (var operation in model)
{
web.Report.RegisterData(operation.OperationSupplies, "Operations.OperationSupplies");
}
//var check = web.Report.GetDataSource("Operations");
//var check2 = web.Report.GetDataSource("Operations.OperationSupplies");
web.Report.Prepare();
string export = Directory.GetCurrentDirectory() + $"\\wwwroot\\export\\{reportName}.pdf";
web.Report.Export(new PDFSimpleExport(), export);
return Ok(true);
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... urce-opera