downgrade Lib and Report API เพื่อรองรับการใช้งาน Report
This commit is contained in:
parent
9c610407f4
commit
041a4d8f3d
151 changed files with 1374 additions and 2188 deletions
64
BMA.EHR.Report.Service/GenericReportGenerator.cs
Normal file
64
BMA.EHR.Report.Service/GenericReportGenerator.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Telerik.Reporting;
|
||||
using Telerik.Reporting.Processing;
|
||||
|
||||
namespace BMA.EHR.Report.Service
|
||||
{
|
||||
public class GenericReportGenerator
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public GenericReportGenerator(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
||||
public virtual byte[] GenerateReport(string fileName, string exportType)
|
||||
{
|
||||
try
|
||||
{
|
||||
//var rptFile = Path.Combine("Reports", fileName);
|
||||
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report? report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(fileName))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||
}
|
||||
|
||||
//report.DataSource = command;
|
||||
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report
|
||||
};
|
||||
|
||||
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo);
|
||||
|
||||
var content = result.DocumentBytes;
|
||||
|
||||
return content;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue