-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportService.cs
More file actions
35 lines (33 loc) · 1.37 KB
/
ReportService.cs
File metadata and controls
35 lines (33 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using DataModel;
using DevExpress.DataAccess.ObjectBinding;
using DevExpress.XtraRichEdit.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Shared {
public class ReportService : IReportService {
public async Task<string> ExportInvoiceReportToPdfAsync(Order order, string baseFolder) {
InvoiceReport report = await GenerateInvoiceReportAsync(order);
string resultFile = Path.Combine(baseFolder, report.Name + ".pdf");
await report.ExportToPdfAsync(resultFile);
return resultFile;
}
public async Task<InvoiceReport> GenerateInvoiceReportAsync(Order order) {
return await Task.Run(async () =>
{
InvoiceReport invoiceReport = new InvoiceReport() { Name = $"Invoice_{order.Id}" };
ObjectDataSource objectDataSource = new ObjectDataSource();
objectDataSource.DataSource = order;
invoiceReport.DataSource = objectDataSource;
await invoiceReport.CreateDocumentAsync();
return invoiceReport;
});
}
}
public interface IReportService {
Task<InvoiceReport> GenerateInvoiceReportAsync(Order order);
Task<string> ExportInvoiceReportToPdfAsync(Order order, string baseFolder);
}
}