Compare commits

...

6 Commits

  1. 1
      Business/Business.csproj
  2. 20
      Business/MobileV2/FileStreamResult.cs
  3. 138
      Business/MobileV2/MobileV2Business.cs
  4. 7
      Common/Helper/ApplicationConfig.cs
  5. 8
      Common/Model/JsonRxResponse.cs
  6. 1
      JsonRx/JsonRx.csproj
  7. 5
      JsonRx/Web.config
  8. 2
      Repository/MobileV2/IMobileV2Repo.cs
  9. 103
      Repository/MobileV2/MobileV2Repo.cs

1
Business/Business.csproj

@ -104,6 +104,7 @@
<Compile Include="KftcPasswordRule\PasswordValidationResult.cs" />
<Compile Include="KftcPasswordRule\PatternMatchRule.cs" />
<Compile Include="KftcPasswordRule\ValidationModel.cs" />
<Compile Include="MobileV2\FileStreamResult.cs" />
<Compile Include="MobileV2\IMobileV2Business.cs" />
<Compile Include="Mobile\IMobileServices.cs" />
<Compile Include="Mobile\MobileServices.cs" />

20
Business/MobileV2/FileStreamResult.cs

@ -0,0 +1,20 @@
using Common;
using System.IO;
using System.Net.Http.Headers;
namespace Business.Mobile
{
internal class FileStreamResult : JsonRxResponse
{
private MemoryStream stream;
private MediaTypeHeaderValue mediaTypeHeaderValue;
public FileStreamResult(MemoryStream stream, MediaTypeHeaderValue mediaTypeHeaderValue)
{
this.stream = stream;
this.mediaTypeHeaderValue = mediaTypeHeaderValue;
}
public string FileDownloadName { get; set; }
}
}

138
Business/MobileV2/MobileV2Business.cs

@ -12,12 +12,15 @@ using Repository.MobileV2;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Business.Mobile
{
public class MobileV2Business : IMobileV2Business
@ -314,11 +317,144 @@ namespace Business.Mobile
public JsonRxResponse DownLoadStatement(DateFilterParams search, string userId)
{
//TranHistoryResponse trn = new TranHistoryResponse();
var r= _requestServicesv2.TransactionPrintPdf(search, userId);
if (r?.RecentTransactions == null)
{
// Log or return an error message
return new JsonRxResponse() { ErrorCode = "1", Msg = "No recent transactions 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.RecentTransactions)
{
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.User}</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 filePath = ApplicationConfig.DownloadPdf();
var fileName = $"{userId}-{DateTime.Now.ToString("yyyyMMddHHss")}.pdf";
var fileUrl = Path.Combine(filePath, fileName);
var pdfBytes = GeneratePdf(htmlContent.ToString());
// byte[] data = Encoding.UTF8.GetBytes(htmlContent.ToString());
File.WriteAllBytes(fileUrl, pdfBytes);
var fileUrlName = Path.GetFileName(fileUrl);
var filePathUrl = $"{ HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath.TrimEnd('/')}/Download/{fileUrlName.Replace("//", "\\")}";
//var filePathUrl = $"{HttpContext.Current.Request.Url.Scheme}://{HttpContext.Current.Request.Url.Authority}/{fileUrlName}";
//JsonRxResponse jsonRx = new JsonRxResponse() { ErrorCode = "0", Msg = "Success", Data = filePathUrl };
//return jsonRx;
JsonRxResponse jsonRx = new JsonRxResponse() { ErrorCode = "0", Msg = "Success" };
jsonRx.Data = "http://77.68.15.91:1082/download/sample.pdf";
//JsonRxResponse jrx = _requestServicesv2.PrintPdf(userId);
//jsonRx.Data = "http://77.68.15.91:1082/Download/sample.pdf";
jsonRx.Data = filePathUrl;
return jsonRx;
}
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 = @"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe", // Provide the full path here
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;
}

7
Common/Helper/ApplicationConfig.cs

@ -14,6 +14,13 @@ namespace Common.Helper
return ReadWebConfig("docUploadURL");
}
public static string DownloadPdf()
{
return ReadWebConfig("downloadPath");
}
public static string GetTelecomsIconRelativePath()
{
return ReadWebConfig("telecomsIconRelativePath");

8
Common/Model/JsonRxResponse.cs

@ -1,7 +1,11 @@
namespace Common
using Common.Model;
using System.Collections.Generic;
namespace Common
{
public class JsonRxResponse
{
private string _errorCode = "";
private string _msg = "";
private string _id = "";
@ -76,5 +80,7 @@
Id = id;
Extra = extra;
}
public List<TranHistoryResponse> RecentTransactions { get; set; }
}
}

1
JsonRx/JsonRx.csproj

@ -253,6 +253,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
<Folder Include="Handler\Download\" />
<Folder Include="InboundApi\" />
<Folder Include="Models\" />
<Folder Include="obj\" />

5
JsonRx/Web.config

@ -14,8 +14,8 @@
<!--<add name="LogDB" connectionString="server=77.68.15.91\MSSQLSERVER01,1434;Database=LogDb;uid=sa;pwd=DbAmin123;" providerName="system.data.sqlclient" />
<add name="RemittanceDB" connectionString="server=77.68.15.91\MSSQLSERVER01,1434;Database=FastMoneyPro_Remit;uid=sa;pwd=DbAmin123; Max Pool Size=1000;" providerName="system.data.sqlclient" />-->
<add name="LogDB" connectionString="server=77.68.90.58,1433;Database=LogDb;uid=sa;pwd=zUge=i-W[8;" providerName="system.data.sqlclient" />
<add name="RemittanceDB" connectionString="server=77.68.90.58,1433;Database=FastMoneyPro_Remit;uid=sa;pwd=zUge=i-W[8; Max Pool Size=1000;" providerName="system.data.sqlclient" />
<add name="LogDB" connectionString="server=77.68.15.91\MSSQLSERVER01,1434;Database=LogDb;uid=sa;pwd=DbAmin123;" providerName="system.data.sqlclient" />
<add name="RemittanceDB" connectionString="server=77.68.15.91\MSSQLSERVER01,1434;Database=FastMoneyPro_Remit;uid=sa;pwd=DbAmin123; Max Pool Size=1000;" providerName="system.data.sqlclient" />
<!--<add name="LogDB" connectionString="server=34.92.161.102;Database=logdb;uid=remituserjme;pwd=r3M!tU5Er@jM3r3Mit#?; Max Pool Size=1000;" providerName="system.data.sqlclient" />
<add name="RemittanceDB" connectionString="server=34.92.161.102;Database=FastMoneyPro_Remit;uid=remituserjme;pwd=r3M!tU5Er@jM3r3Mit#?; Max Pool Size=1000;" providerName="system.data.sqlclient" />-->
</connectionStrings>
@ -33,6 +33,7 @@
<!--Local path-->
<add key="rootUrl" value="http://localhost:9500/" />
<add key="docUploadPath" value="E:\" />
<add key="downloadPath" value="E:\IMELONDON\MOBILE_API\JsonRx\Handler\Download" />
<add key="docUploadURL" value="E:\CustomerDocument\" />
<add key="profilePicUploadURL" value="D:\CustomerProfile\" />
<!--Max file size-->

2
Repository/MobileV2/IMobileV2Repo.cs

@ -19,5 +19,7 @@ namespace Repository.MobileV2
DataRow GetResidenceType(string customerId);
JsonRxResponse SaveKycSettings(KycOption kycOption);
JsonRxResponse UpdateCustomerProfile(CustomerDetailV2 req);
//JsonRxResponse PrintPdf(string userId);
JsonRxResponse TransactionPrintPdf(DateFilterParams search, string userId);
}
}

103
Repository/MobileV2/MobileV2Repo.cs

@ -486,5 +486,108 @@ namespace Repository.MobileV2
Extra = _dbRes.Id
};
}
//public JsonRxResponse PrintPdf(TranHistoryResponse tranHistory)
//{
// var sql = "Exec mobile_proc_TranHistory @flag='tran-history-v2'";
// sql += ", @customerId = " + _dao.FilterString(tranHistory.User);
// sql += ", @postalCode = " + _dao.FilterString(req.PostalCode);
// sql += ", @address1 = " + _dao.FilterString(req.Address1);
// sql += ", @address2 = " + _dao.FilterString(req.Address2);
// Log.DebugFormat("UpdateProfile | SQL:{0}", sql);
// var _dbRes = _dao.ParseDbResult(sql);
// return new JsonRxResponse
// {
// ErrorCode = _dbRes.ResponseCode,
// Msg = _dbRes.Msg,
// Extra = _dbRes.Id
// };
//}
public JsonRxResponse TransactionPrintPdf(DateFilterParams search,string userId)
{
MyTransferDto myTransferDto = new MyTransferDto() { RecentTransactions = new List<TranHistoryResponse>() };
JsonRxResponse jsonRx = new JsonRxResponse();
// TranHistoryResponse tran = new TranHistoryResponse();
try
{
var sql1 = "Exec mobile_proc_TranHistory @flag='tran-history-v2'";
sql1 += ", @customerId =" + _dao.FilterString(userId);
//sql1 += ", @fromDate=" + _dao.FilterString(search.FromDate);
//sql1 += ", @toDate=" + _dao.FilterString(search.ToDate);
var dataSet = _dao.ExecuteDataset(sql1);
Log.DebugFormat("GetTransactionHistory | SQL : {0}", sql1);
var ds = _dao.ExecuteDataset(sql1);
if (ds == null || ds.Tables.Count <= 0)
{
myTransferDto.RecentTransactions = null;
}
else
{
DataTable data = ds.Tables[1];
if (ds.Tables.Count > 0)
{
List<TranHistoryResponse> obj = new List<TranHistoryResponse>();
foreach (DataRow dr in data.Rows)
{
obj.Add(new TranHistoryResponse
//TranHistoryResponse tranHistoryResponse = new TranHistoryResponse()
{
User = Convert.ToString(dr["userId"]),
TranId = Convert.ToString(dr["tranId"]),
ControlNo = Convert.ToString(dr["controlNo"]),
CollAmt = Convert.ToString(dr["collAmount"]),
PayoutAmt = Utilities.ShowDecimal(Convert.ToString(dr["payoutAmt"])),
PCurr = Convert.ToString(dr["pCurr"]),
CollCurr = Convert.ToString(dr["collCurr"]),
PayStatus = Convert.ToString(dr["payStatus"]),
PayoutMode = Convert.ToString(dr["payoutMode"]),
SendDate = Convert.ToString(dr["sendDate"]),
PaidDate = Convert.ToString(dr["paidDate"]),
DisplayActions = dr["DisplayActions"].ToString(),
//ColorIcon = GetColor(dr["payStatus"].ToString()),
//ColorCode = GetColorCode(dr["payStatus"].ToString()),
//TextCode = GetTextCode(dr["payStatus"].ToString()),
// PayoutAgent = Convert.ToString(dr["PayoutAgent"]),
});
jsonRx.RecentTransactions = obj;
}
}
}
//jsonRx.ErrorCode = "0";
//jsonRx.Msg = "Success";
//jsonRx.Data = myTransferDto;
return jsonRx;
}
catch (Exception e)
{
Log.DebugFormat($"Exception : {e.ToString()}");
jsonRx.ErrorCode = "1";
//jsonRx.Msg = "Failed";
//var map = Utilities.GetLanguageMapping(RESPONSE_MSG.GET_RECEIVER_INFORMATION_FAIL_2.ToString(), lang);
jsonRx.Msg = $"Exception has occured at GetTransactionHistory";
return jsonRx;
}
}
}
}
Loading…
Cancel
Save