shakun
9 months ago
21 changed files with 481 additions and 19 deletions
-
BINCustomerOnlineV2/.vs/CustomerOnlineV2/DesignTimeBuild/.dtbcache.v2
-
BINCustomerOnlineV2/.vs/CustomerOnlineV2/v17/.futdcache.v2
-
BINCustomerOnlineV2/.vs/CustomerOnlineV2/v17/.suo
-
BINCustomerOnlineV2/.vs/ProjectEvaluation/customeronlinev2.metadata.v7.bin
-
BINCustomerOnlineV2/.vs/ProjectEvaluation/customeronlinev2.projects.v7.bin
-
1CustomerOnlineV2/CustomerOnlineV2.Business/Business/TransactionBusiness/ITransactionBusiness.cs
-
21CustomerOnlineV2/CustomerOnlineV2.Business/Business/TransactionBusiness/TransactionBusiness.cs
-
5CustomerOnlineV2/CustomerOnlineV2.Common/Helper/ApplicationConfig.cs
-
21CustomerOnlineV2/CustomerOnlineV2.Common/Helper/Utilities.cs
-
1CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/TransactionRepository/ITransactionRepository.cs
-
32CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/TransactionRepository/TransactionRepository.cs
-
BINCustomerOnlineV2/CustomerOnlineV2.Repository/obj/Debug/net7.0/CustomerOnlineV2.Repository.csproj.AssemblyReference.cache
-
186CustomerOnlineV2/CustomerOnlineV2/Controllers/ReportController.cs
-
8CustomerOnlineV2/CustomerOnlineV2/Controllers/TransactionController.cs
-
1CustomerOnlineV2/CustomerOnlineV2/CustomerOnlineV2.csproj
-
2CustomerOnlineV2/CustomerOnlineV2/Properties/PublishProfiles/FolderProfile.pubxml.user
-
145CustomerOnlineV2/CustomerOnlineV2/Views/Report/GeneratePdf.cshtml
-
62CustomerOnlineV2/CustomerOnlineV2/Views/Transaction/SendMoney.cshtml
-
8CustomerOnlineV2/CustomerOnlineV2/Views/TransactionReport/TranReport.cshtml
-
3CustomerOnlineV2/CustomerOnlineV2/appsettings.json
-
4CustomerOnlineV2/CustomerOnlineV2/wwwroot/js/Custom.js
@ -0,0 +1,186 @@ |
|||
using CustomerOnlineV2.Business.Business.TransactionBusiness; |
|||
using CustomerOnlineV2.Common.Helper; |
|||
using CustomerOnlineV2.Common.Models.HomeModel; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
//using DinkToPdf.PdfTools.Load;
|
|||
using System.Diagnostics; |
|||
using System.Text; |
|||
|
|||
namespace CustomerOnlineV2.Controllers |
|||
{ |
|||
public class ReportController : Controller |
|||
{ |
|||
|
|||
private readonly ITransactionBusiness _transactionBusiness; |
|||
|
|||
public ReportController(ITransactionBusiness transactionBusiness) |
|||
{ |
|||
|
|||
_transactionBusiness = transactionBusiness; |
|||
|
|||
} |
|||
//private readonly IConverter _converter = new SynchronizedConverter(new PdfTools());
|
|||
//private byte[] GeneratePdfBytes(string htmlContent)
|
|||
//{
|
|||
// var globalSettings = new GlobalSettings
|
|||
// {
|
|||
// PaperSize = PaperKind.A4,
|
|||
// Orientation = Orientation.Portrait,
|
|||
// Margins = new MarginSettings { Top = 10, Bottom = 10, Left = 10, Right = 10 },
|
|||
// };
|
|||
|
|||
// var objectSettings = new ObjectSettings
|
|||
// {
|
|||
// PagesCount = true,
|
|||
// HtmlContent = htmlContent,
|
|||
// };
|
|||
|
|||
// var pdf = new HtmlToPdfDocument()
|
|||
// {
|
|||
// GlobalSettings = globalSettings,
|
|||
// Objects = { objectSettings }
|
|||
// };
|
|||
|
|||
// if (_converter != null)
|
|||
// {
|
|||
// return _converter.Convert(pdf);
|
|||
// }
|
|||
// else
|
|||
// {
|
|||
// // Handle the case where _converter is null
|
|||
// throw new InvalidOperationException("_converter is not properly initialized.");
|
|||
// }
|
|||
//}
|
|||
// [HttpGet("generate-pdf")]
|
|||
//[HttpPost]
|
|||
public IActionResult GeneratePdf(CustomerTransaction customerTransaction) |
|||
{ |
|||
//if (TempData["ResponseCode"] == null || string.IsNullOrEmpty(TempData["ResponseCode"].ToString()))
|
|||
//{
|
|||
// TempData["ResponseCode"] = "0";
|
|||
//}
|
|||
//else
|
|||
//{
|
|||
// TempData["ResponseCode"] = "1";
|
|||
//}
|
|||
|
|||
var loginDetails = HttpContext.GetLoginDetails(); |
|||
var r = _transactionBusiness.GetTransactionReportList(loginDetails, customerTransaction); |
|||
|
|||
if (r?.Result?.CustomerTransaction == null) |
|||
{ |
|||
|
|||
return NotFound("Transaction Not Found"); |
|||
} |
|||
StringBuilder htmlContent = new StringBuilder(); |
|||
var imageUrl = "data:image/png;base64," + Convert.ToBase64String(System.IO.File.ReadAllBytes("wwwroot/images/logo.png")); |
|||
var svgContent = System.IO.File.ReadAllText("wwwroot/images/imelondon.svg"); |
|||
var imageUrl1 = $"data:image/svg+xml;base64,{Convert.ToBase64String(Encoding.UTF8.GetBytes(svgContent))}"; |
|||
htmlContent.AppendLine("<html><head><style> .header {overflow: auto;}" + |
|||
".img1 {float: left; width: 350px; height: 60px; }" + |
|||
".img {float: right; width: 150px; height: 60px;-webkit-filter: grayscale(100%); filter: grayscale(100%);}" + |
|||
" .parag {text-align: justify;} " + |
|||
"</style></head> <body> " + |
|||
" <div class='header'>" + |
|||
$"<img class='img' src='{imageUrl}' />" + |
|||
$"<img class='img1' src='{imageUrl1}' />" + |
|||
"<div class=\"parag\"><p>" + |
|||
"<br /><br /><br /><br /><b> IME is the trading name of Subhida UK Ltd company.</b>" + |
|||
"<br /> Registration No.: 6432399" + |
|||
"<br />FCA Registration No.: 576127" + |
|||
"<br />HMRC Registration No.: 12663526" + |
|||
"<br /> Registered Address : Pentax House South Hill Avenue, South Harrow," + |
|||
"<br />London, HA2 0DU" + |
|||
"<br />Email:info@imelondon.co.uk</p> </div></div>" + |
|||
"<h1>Transaction List</h1>"); |
|||
htmlContent.AppendLine("<table style='border-collapse: collapse;'><thead><tr>" + |
|||
"<th style='border: 1px solid black; padding: 5px;'>S.N</th>" + |
|||
"<th style='border: 1px solid black; padding: 5px;'>Receiver Name</th>" + |
|||
"<th style='border: 1px solid black; padding: 5px;'>Send Date</th>" + |
|||
"<th style='border: 1px solid black; padding: 5px;'>Tran Id</th>" + |
|||
"<th style='border: 1px solid black; padding: 5px;'>Control No</th>" + |
|||
"<th style='border: 1px solid black; padding: 5px;'>Delivery Method</th>" + |
|||
"<th style='border: 1px solid black; padding: 5px;'>Status</th>" + |
|||
"<th style='border: 1px solid black; padding: 5px;'>Transfer Amt</th>" + |
|||
"<th style='border: 1px solid black; padding: 5px;'>Receive Amt</th>" + |
|||
"</tr></thead><tbody>"); |
|||
|
|||
int sn = 1; |
|||
decimal totalPayoutAmt = 0; |
|||
foreach (var transa in r.Result.CustomerTransaction) |
|||
{ |
|||
if (decimal.TryParse(transa.PayoutAmt, out decimal payoutAmtDecimal)) |
|||
{ |
|||
totalPayoutAmt += payoutAmtDecimal; |
|||
} |
|||
htmlContent.AppendLine( |
|||
$"<tr style='border: 1px solid black;'>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>{sn}</td>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>{transa.Id}</td>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>{transa.SendDate}</td>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>{transa.TranId}</td>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>{transa.ControlNo}</td>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>{transa.PayoutMode}</td>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>{transa.PayStatus}</td>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>{transa.CollAmt}</td>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>{transa.PayoutAmt}</td>" + |
|||
$"</tr>"); |
|||
sn++; |
|||
} |
|||
|
|||
htmlContent.AppendLine( |
|||
$"<tr style='border: 1px solid black;'>" + |
|||
$"<td></td>" + |
|||
$"<td></td>" + |
|||
$"<td></td>" + |
|||
$"<td></td>" + |
|||
$"<td></td>" + |
|||
$"<td></td>" + |
|||
$"<td></td>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>Total:</td>" + |
|||
$"<td style='border: 1px solid black; padding: 5px;'>{totalPayoutAmt}</td>" + |
|||
$"</tr>"); |
|||
|
|||
htmlContent.AppendLine("</tbody></table></body></html>"); |
|||
var pdfBytes = GeneratePdf(htmlContent.ToString()); |
|||
|
|||
// Return the PDF as a file result
|
|||
return File(pdfBytes, "application/pdf", "TransactionReport.pdf"); |
|||
|
|||
} |
|||
|
|||
private byte[] GeneratePdf(string htmlContent) |
|||
{ |
|||
var fileName = Path.GetTempFileName(); |
|||
|
|||
// Save the HTML content to a temporary file
|
|||
System.IO.File.WriteAllText(fileName + ".html", htmlContent); |
|||
|
|||
// Run the WkHtmlToPdf process
|
|||
var process = new Process() |
|||
{ |
|||
StartInfo = new ProcessStartInfo |
|||
{ |
|||
FileName = ApplicationConfig.GetpdfLibPath(), |
|||
Arguments = $"{fileName}.html {fileName}.pdf", |
|||
RedirectStandardOutput = true, |
|||
RedirectStandardError = true, |
|||
UseShellExecute = false, |
|||
CreateNoWindow = true, |
|||
} |
|||
}; |
|||
process.Start(); |
|||
process.WaitForExit(); |
|||
|
|||
// Read the generated PDF into a byte array
|
|||
var pdfBytes = System.IO.File.ReadAllBytes($"{fileName}.pdf"); |
|||
|
|||
// Cleanup temporary files
|
|||
//System.IO.File.Delete($"{fileName}.html");
|
|||
//System.IO.File.Delete($"{fileName}.pdf");
|
|||
|
|||
return pdfBytes; |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,145 @@ |
|||
|
|||
@{ |
|||
ViewData["Title"] = "Transaction Report"; |
|||
} |
|||
|
|||
<a href="/Report/GeneratePdf" target="_blank">Download Transaction Report</a> |
|||
|
|||
|
|||
@* <!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<style> |
|||
.header { |
|||
overflow: auto; |
|||
} |
|||
|
|||
.img { |
|||
float: left; |
|||
width: 250px; |
|||
height: 150px; |
|||
} |
|||
|
|||
.parag { |
|||
text-align: justify; |
|||
} |
|||
|
|||
/* .tab, .trr { |
|||
border: 1px solid black; |
|||
} */ |
|||
</style> |
|||
|
|||
</head> |
|||
<body> |
|||
<br /> |
|||
<div class="header"><img class="img" src="/images/logo.png" /> |
|||
|
|||
<div class="parag"> |
|||
<p> |
|||
<b> IME is the trading name of Subhida UK Ltd company.</b><br /> |
|||
Registration No.: 6432399<br /> |
|||
FCA Registration No.: 576127<br /> |
|||
HMRC Registration No.: 12663526<br /> |
|||
Registered Address : Pentax House South Hill Avenue, South Harrow,<br /> |
|||
London, HA2 0DU<br /> |
|||
Email:info@imelondon.co.uk |
|||
</p> |
|||
</div> |
|||
</div> |
|||
|
|||
@* <div class="px-4"> |
|||
<div class="col-lg-12"> |
|||
<h5 class="mb-4"> Remitter Transactions Report </h5> |
|||
</div> |
|||
<h5 class="mb-4"> |
|||
Remitter Details |
|||
</h5> |
|||
<table class="table"> |
|||
<tr> |
|||
<td>Member Id :</td> |
|||
<td> |
|||
<strong><span id="rName"></span></strong> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Name :</td> |
|||
<td> |
|||
<strong><span id="mNumber"></span></strong> |
|||
</td> |
|||
</tr> |
|||
|
|||
<tr> |
|||
<td>Address :</td> |
|||
<td> |
|||
<strong><span id="country"></span></strong> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Telephone :</td> |
|||
<td> |
|||
<strong><span id="pmode"></span></strong> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> Date Of Birth :</td> |
|||
<td> |
|||
<strong><span id="bname"></span></strong> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> Nationality :</td> |
|||
<td> |
|||
<strong><span id="acountNumber"></span></strong> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td> ID Details :</td> |
|||
<td> |
|||
<strong><span id="Branch"></span></strong> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td>Date Of Issue :</td> |
|||
<td> |
|||
<strong><span id="relationship"></span></strong> |
|||
</td> |
|||
</tr> |
|||
</table> |
|||
|
|||
</div> *@ |
|||
@* <h5 class="mb-4"> |
|||
Transactions |
|||
</h5> |
|||
{{table}} |
|||
|
|||
<script> |
|||
$(document).ready(function () { |
|||
downloadPdf(); |
|||
}); |
|||
function downloadPdf() { |
|||
$.ajax({ |
|||
type: "POST", |
|||
url: "/Report/GeneratePdf", |
|||
data: JSON.stringify(yourData), // Pass any necessary data to the server |
|||
contentType: "application/json; charset=utf-8", |
|||
success: function (data) { |
|||
// Create a Blob from the PDF data and create a download link |
|||
var blob = new Blob([data], { type: "application/pdf" }); |
|||
var link = document.createElement('a'); |
|||
link.href = window.URL.createObjectURL(blob); |
|||
link.download = "TransactionReport.pdf"; |
|||
document.body.appendChild(link); |
|||
link.click(); |
|||
document.body.removeChild(link); |
|||
}, |
|||
error: function (error) { |
|||
console.error("Error generating PDF: ", error); |
|||
} |
|||
}); |
|||
} |
|||
</script> |
|||
|
|||
</body> |
|||
|
|||
</html> |
|||
*@ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue