From 5c871932f395d6afd6144681fae302cf9efaa054 Mon Sep 17 00:00:00 2001 From: Leeza Baidar Date: Fri, 7 Jun 2024 15:34:40 +0545 Subject: [PATCH] #30711 inbound txn file upload module --- Swift.DAL/Remittance/TxnFileUpload/TxnDao.cs | 57 ++++++ Swift.DAL/Swift.DAL.csproj | 1 + Swift.web/AgentPanel/UploadFIle/TranFile.aspx | 85 ++++++++ .../AgentPanel/UploadFIle/TranFile.aspx.cs | 160 ++++++++++++++++ .../UploadFIle/TranFile.aspx.designer.cs | 53 +++++ Swift.web/AgentPanel/UploadFIle/TxnList.aspx | 125 ++++++++++++ .../AgentPanel/UploadFIle/TxnList.aspx.cs | 181 ++++++++++++++++++ .../UploadFIle/TxnList.aspx.designer.cs | 98 ++++++++++ Swift.web/Library/GetStatic.cs | 142 +++++++++++++- Swift.web/Swift.web.csproj | 16 ++ 10 files changed, 917 insertions(+), 1 deletion(-) create mode 100644 Swift.DAL/Remittance/TxnFileUpload/TxnDao.cs create mode 100644 Swift.web/AgentPanel/UploadFIle/TranFile.aspx create mode 100644 Swift.web/AgentPanel/UploadFIle/TranFile.aspx.cs create mode 100644 Swift.web/AgentPanel/UploadFIle/TranFile.aspx.designer.cs create mode 100644 Swift.web/AgentPanel/UploadFIle/TxnList.aspx create mode 100644 Swift.web/AgentPanel/UploadFIle/TxnList.aspx.cs create mode 100644 Swift.web/AgentPanel/UploadFIle/TxnList.aspx.designer.cs diff --git a/Swift.DAL/Remittance/TxnFileUpload/TxnDao.cs b/Swift.DAL/Remittance/TxnFileUpload/TxnDao.cs new file mode 100644 index 0000000..9fa4c62 --- /dev/null +++ b/Swift.DAL/Remittance/TxnFileUpload/TxnDao.cs @@ -0,0 +1,57 @@ +using Swift.DAL.SwiftDAL; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Swift.DAL.Remittance.TxnFileUpload +{ + public class TxnDao : RemittanceDao + { + public DbResult GetFileName(string fileName) + { + var sql = "Exec proc_UploadedFileTxnHistory @flag='checkFileName'"; + sql += " ,@showFileName =" + FilterString(fileName); + return ParseDbResult(sql.ToString()); + } + public DbResult InsertData(string user, string fileName, string agentCode, string xml) + { + var sql = "Exec proc_UploadedFileTxnHistory @flag='insertData'"; + sql += " ,@user =" + FilterString(user); + sql += " ,@showFileName =" + FilterString(fileName); + sql += " ,@agentCode =" + FilterString(agentCode); + sql += ",@xml ='" + xml + "'"; + return ParseDbResult(sql); + } + public DataTable ShowFileList() + { + var sql = "Exec proc_UploadedFileTxnHistory @flag='showFileList'"; + return ExecuteDataTable(sql.ToString()); + } + + public DataTable ShowTxnList(string UploadedFileId, string txnType) + { + var sql = "Exec proc_UploadedFileTxnHistory @flag='showTxnList'"; + sql += " ,@uploadedFileId =" + Convert.ToInt32(UploadedFileId); + sql += " ,@txnType =" + FilterString(txnType); + return ExecuteDataTable(sql.ToString()); + } + public DbResult ProcessTxn(string user, string rowIds) + { + var sql = "Exec proc_UploadedFileTxnHistory @flag='processTxn'"; + sql += " ,@user =" + FilterString(user); + sql += " ,@rowIds =" + FilterString(rowIds); + return ParseDbResult(sql.ToString()); + } + public DbResult DeleteTxn(string user, string rowId) + { + var sql = "Exec proc_UploadedFileTxnHistory @flag='deleteTxn'"; + sql += " ,@user =" + FilterString(user); + sql += " ,@rowId =" + FilterString(rowId); + return ParseDbResult(sql.ToString()); + } + } +} diff --git a/Swift.DAL/Swift.DAL.csproj b/Swift.DAL/Swift.DAL.csproj index c132f79..61550cf 100644 --- a/Swift.DAL/Swift.DAL.csproj +++ b/Swift.DAL/Swift.DAL.csproj @@ -412,6 +412,7 @@ + diff --git a/Swift.web/AgentPanel/UploadFIle/TranFile.aspx b/Swift.web/AgentPanel/UploadFIle/TranFile.aspx new file mode 100644 index 0000000..2b5ba1e --- /dev/null +++ b/Swift.web/AgentPanel/UploadFIle/TranFile.aspx @@ -0,0 +1,85 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TranFile.aspx.cs" Inherits="Swift.web.AgentPanel.UploadFIle.TranFile" %> + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+
+
+
+
+
+

Upload Transaction File +

+
+ +
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+

Uploaded Files +

+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/Swift.web/AgentPanel/UploadFIle/TranFile.aspx.cs b/Swift.web/AgentPanel/UploadFIle/TranFile.aspx.cs new file mode 100644 index 0000000..40fd392 --- /dev/null +++ b/Swift.web/AgentPanel/UploadFIle/TranFile.aspx.cs @@ -0,0 +1,160 @@ +using Swift.DAL.Remittance.TxnFileUpload; +using Swift.web.Component.Grid; +using Swift.web.Component.Grid.gridHelper; +using Swift.web.Library; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Swift.web.AgentPanel.UploadFIle +{ + public partial class TranFile : System.Web.UI.Page + { + protected const string GridName = "grdUploadedFiles"; + const string ViewFunctionID = "90620000"; + readonly RemittanceLibrary _sl = new RemittanceLibrary(); + readonly TxnDao txnDao = new TxnDao(); + private readonly SwiftGrid grid = new SwiftGrid(); + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + _sl.CheckSession(); + Authenticate(); + } + LoadFile(); + } + + private void Authenticate() + { + _sl.CheckAuthentication(ViewFunctionID); + } + + private void LoadFile() + { + grid.FilterList = new List + { + new GridFilter("ShowFileName", "File Name:", "LT"), + }; + + + grid.ColumnList = new List + { + new GridColumn("SN", "S.N.", "", "T"), + new GridColumn("ShowFileName", "File Name", "", "T"), + new GridColumn("UploadedDate", "Uploaded Date", "", "T"), + new GridColumn("TotalProcessedTxn", "No. of ProcessedTxn", "", "T"), + new GridColumn("TotalUnProcessedTxn", "No. of Not-ProcessedTxn", "", "T"), + new GridColumn("TotalInvalidTxn", "No. of InvalidTxn", "", "T") + }; + + + + grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB; + grid.GridType = 1; + grid.InputPerRow = 4; + grid.GridName = GridName; + grid.ShowFilterForm = true; + grid.ShowPagingBar = true; + grid.DisableSorting = false; + grid.RowIdField = "UploadedFileId"; + grid.AlwaysShowFilterForm = true; + grid.AllowCustomLink = true; + grid.AllowCustomLink = true; + var customLinkText = new StringBuilder(); + customLinkText.Append(""); + grid.CustomLinkText = customLinkText.ToString(); + grid.CustomLinkVariables = "UploadedFileId"; + grid.ThisPage = "TranFile.aspx"; + grid.SetComma(); + grid.InputLabelOnLeftSide = true; + string sql = "proc_UploadedFileTxnHistory @flag='showFileList'"; + + rpt_grid.InnerHtml = grid.CreateGrid(sql); + } + protected void btnUpload_Click(object sender, EventArgs e) + { + string msg = ""; + string agentCode = "IME" + GetStatic.ReadSession("mapCodeDom", "").ToString(); + + if (fileUpload.FileContent.Length >= 1000000) + msg = "File size must be less than 1 mb"; + + else if (fileUpload.FileContent.Length > 0) + { + var fileName = fileUpload.FileName; + + var dbResult = txnDao.GetFileName(fileName); + if (dbResult.ErrorCode != "0") + msg = dbResult.Msg; + + else + { + string fileExt = Path.GetExtension(fileName.ToString()).ToLower(); + if (fileExt == ".csv") + { + string dirPath = Server.MapPath("~") + "doc\\FileUpload\\" + GetStatic.GetAgent(); + + if (!Directory.Exists(dirPath)) + Directory.CreateDirectory(dirPath); + + string path = dirPath + "\\" + fileName; + if (File.Exists(path)) + File.Delete(path); + + fileUpload.SaveAs(path); + + string[] defaultHeaders = new string[24]; + defaultHeaders[0] = "partnerid"; + defaultHeaders[1] = "pinno"; + defaultHeaders[2] = "customername"; + defaultHeaders[3] = "customeraddress"; + defaultHeaders[4] = "customercontact"; + defaultHeaders[5] = "customercity"; + defaultHeaders[6] = "customeridnumber"; + defaultHeaders[7] = "customeridtype"; + defaultHeaders[8] = "benename"; + defaultHeaders[9] = "beneaddress"; + defaultHeaders[10] = "benecontact"; + defaultHeaders[11] = "beneid"; + defaultHeaders[12] = "receivingamount"; + defaultHeaders[13] = "transactiondate"; + defaultHeaders[14] = "payoutlocationid"; + defaultHeaders[15] = "paymentmethod"; + defaultHeaders[16] = "bankname"; + defaultHeaders[17] = "bankbranchname"; + defaultHeaders[18] = "bankaccountnumber"; + defaultHeaders[19] = "remittancereason"; + defaultHeaders[20] = "relationship"; + defaultHeaders[21] = "sourceoffund"; + defaultHeaders[22] = "settlementrate"; + defaultHeaders[23] = "sendingcountry"; + // defaultHeaders[24] = "receivingcountry"; + var xml = GetStatic.GetCSVFileInXML(path, defaultHeaders); + if (xml.Length < 23) + msg = "File has mis-matched columns !!"; + + else + { + dbResult = txnDao.InsertData(GetStatic.GetUser(), fileName, agentCode, xml); + msg = dbResult.Msg; + } + // File.Delete(path); + } + else + msg = "Invalid file format !!"; + } + } + else + msg = "You must choose a file for uploading process !!"; + + GetStatic.AlertMessage(this, msg); + LoadFile(); + } + } +} \ No newline at end of file diff --git a/Swift.web/AgentPanel/UploadFIle/TranFile.aspx.designer.cs b/Swift.web/AgentPanel/UploadFIle/TranFile.aspx.designer.cs new file mode 100644 index 0000000..90347f4 --- /dev/null +++ b/Swift.web/AgentPanel/UploadFIle/TranFile.aspx.designer.cs @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swift.web.AgentPanel.UploadFIle +{ + + + public partial class TranFile + { + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// fileUpload control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.FileUpload fileUpload; + + /// + /// btnUpload control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnUpload; + + /// + /// rpt_grid control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl rpt_grid; + } +} diff --git a/Swift.web/AgentPanel/UploadFIle/TxnList.aspx b/Swift.web/AgentPanel/UploadFIle/TxnList.aspx new file mode 100644 index 0000000..a5c17e4 --- /dev/null +++ b/Swift.web/AgentPanel/UploadFIle/TxnList.aspx @@ -0,0 +1,125 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TxnList.aspx.cs" Inherits="Swift.web.AgentPanel.UploadFIle.TxnList" %> + +<%@ Register TagPrefix="cc1" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit, Version=3.0.20820.16598, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" %> + + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+
+
+ +
+
+
+
+

Transaction List +

+
+ +
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+ + + diff --git a/Swift.web/AgentPanel/UploadFIle/TxnList.aspx.cs b/Swift.web/AgentPanel/UploadFIle/TxnList.aspx.cs new file mode 100644 index 0000000..61e6c6d --- /dev/null +++ b/Swift.web/AgentPanel/UploadFIle/TxnList.aspx.cs @@ -0,0 +1,181 @@ +using Swift.DAL.Remittance.TxnFileUpload; +using Swift.web.Library; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Swift.web.AgentPanel.UploadFIle +{ + public partial class TxnList : System.Web.UI.Page + { + const string ViewFunctionID = "90620000"; + readonly RemittanceLibrary _sl = new RemittanceLibrary(); + readonly TxnDao txnDao = new TxnDao(); + DataTable dt = new DataTable(); + private string rowIds = ""; + int index; + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + _sl.CheckSession(); + Authenticate(); + index = 1; + LoadTran("Unprocessed"); + + } + rowIds = (Request.Form["chkId"] ?? "").ToString(); + } + private void Authenticate() + { + _sl.CheckAuthentication(ViewFunctionID); + } + private void LoadTran(string txnType) + { + var UploadedFileId = GetStatic.ReadQueryString("UploadedFileId", ""); + if (!string.IsNullOrEmpty(GetStatic.ReadQueryString("IsDelete", "")) && index == 1) + { + txnType = "Invalid"; + index = 2; + } + + dt = txnDao.ShowTxnList(UploadedFileId, txnType); + + var str = new StringBuilder(""); + str.Append(""); + if (dt == null) + { + str.Append("
No Record Found For Display !!
"); + tblGrid.InnerHtml = str.ToString(); + return; + } + else if (dt.Rows.Count <= 0) + { + str.Append(""); + for (var i = 0; i < dt.Columns.Count; i++) + { + processbtn.Visible = false; + showUnProcessed.Checked = false; + showProcessed.Checked = false; + showInvalid.Checked = false; + if (txnType.Equals("Unprocessed")) + showUnProcessed.Checked = true; + + else if (txnType.Equals("Processed")) + showProcessed.Checked = true; + + else if (txnType.Equals("Invalid")) + showInvalid.Checked = true; + + str.Append(string.Format("
{0}
", dt.Columns[i])); + } + str.Append(" No Record Found For Display !! "); + tblGrid.InnerHtml = str.ToString(); + return; + } + + str.Append(""); + for (var i = 0; i < dt.Columns.Count; i++) + { + if (i == 1) + { + processbtn.Visible = false; + showUnProcessed.Checked = false; + showProcessed.Checked = false; + showInvalid.Checked = false; + if (txnType.Equals("Unprocessed")) + { + str.Append("√|×"); + processbtn.Visible = true; + showUnProcessed.Checked = true; + } + else if (txnType.Equals("Processed")) + { + showProcessed.Checked = true; + } + else if (txnType.Equals("Invalid")) + { + str.Append(""); + showInvalid.Checked = true; + } + continue; + } + str.Append(string.Format("
{0}
", dt.Columns[i])); + } + str.Append(""); + + foreach (DataRow dr in dt.Rows) + { + str.Append(""); + for (var i = 0; i < dt.Columns.Count; i++) + { + if (i == 1) + { + if (txnType.Equals("Unprocessed")) + str.Append(""); + else if (txnType.Equals("Invalid")) + { + str.Append("" + + ""); + } + + continue; + } + str.Append("" + dr[i].ToString() + ""); + + } + str.Append(""); + } + str.Append(""); + tblGrid.InnerHtml = str.ToString(); + + } + + protected void btnProcessTxn_Click(object sender, EventArgs e) + { + if (rowIds.Length <= 0) + { + GetStatic.AlertMessage(Page, "Please choose at least one transaction for process"); + return; + } + var dbResult = txnDao.ProcessTxn(GetStatic.GetUser(), rowIds); + if (dbResult.ErrorCode != "0") + { + GetStatic.AlertMessage(Page, dbResult.Msg); + return; + } + else + { + GetStatic.AlertMessage(Page, dbResult.Msg); + LoadTran("Processed"); + } + } + + protected void showProcessed_CheckedChanged(object sender, EventArgs e) + { + LoadTran("Processed"); + } + + protected void showUnProcessed_CheckedChanged(object sender, EventArgs e) + { + LoadTran("Unprocessed"); + } + + protected void showInvalid_CheckedChanged(object sender, EventArgs e) + { + LoadTran("Invalid"); + } + + [System.Web.Services.WebMethod] + public static void DeleteRow(string rowId) + { + var txnDao = new TxnDao(); + var dbResult = txnDao.DeleteTxn(GetStatic.GetUser(), rowId); + } + } +} \ No newline at end of file diff --git a/Swift.web/AgentPanel/UploadFIle/TxnList.aspx.designer.cs b/Swift.web/AgentPanel/UploadFIle/TxnList.aspx.designer.cs new file mode 100644 index 0000000..76eb5b6 --- /dev/null +++ b/Swift.web/AgentPanel/UploadFIle/TxnList.aspx.designer.cs @@ -0,0 +1,98 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swift.web.AgentPanel.UploadFIle +{ + + + public partial class TxnList + { + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// script control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.ScriptManager script; + + /// + /// showUnProcessed control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RadioButton showUnProcessed; + + /// + /// showProcessed control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RadioButton showProcessed; + + /// + /// showInvalid control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RadioButton showInvalid; + + /// + /// tblGrid control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl tblGrid; + + /// + /// processbtn control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl processbtn; + + /// + /// btnProcessTxn control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnProcessTxn; + + /// + /// ConfirmButtonExtender1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::AjaxControlToolkit.ConfirmButtonExtender ConfirmButtonExtender1; + } +} diff --git a/Swift.web/Library/GetStatic.cs b/Swift.web/Library/GetStatic.cs index d62121b..3e01fb0 100644 --- a/Swift.web/Library/GetStatic.cs +++ b/Swift.web/Library/GetStatic.cs @@ -21,6 +21,7 @@ using System.IO; using System.Xml.Serialization; using SelectPdf; using Newtonsoft.Json; +using System.Linq; //using SelectPdf; @@ -1692,7 +1693,7 @@ namespace Swift.web.Library { if (HttpContext.Current.Session["message"] == null) { - //CallBackJs1(page, "Remove Message", "window.parent.RemoveMessageBox();"); + //CallBackJs1(page, "Remove Message", "SetMessageBox();"); return; } @@ -2659,5 +2660,144 @@ namespace Swift.web.Library { return MimeTypes.MimeTypeMap.GetExtension(contentType); } + + public static string GetCSVFileInXML(string path, string[] defaultHeaders, bool hasHeader = true) + { + var columnList = new ArrayList(); + var sb = new StringBuilder(""); + using (CsvReader reader = new CsvReader(path)) + { + foreach (string[] values in reader.RowEnumerator) + { + defaultHeaders = defaultHeaders.Select(a => a.Trim()).ToArray().Select(s => s.ToLowerInvariant()).ToArray(); + var fileHeaders = values.Select(a => a.Trim()).ToArray().Select(s => s.ToLowerInvariant()).ToArray(); + var areEqual = Enumerable.SequenceEqual(defaultHeaders, fileHeaders); + + if (hasHeader) + { + if (areEqual) + { + foreach (var item in defaultHeaders) + { + columnList.Add(item); + } + columnList.Add("trantype"); + columnList.Add("invalidreason"); + hasHeader = false; + continue; + } + else + break; + } + + if (values.Length > 0) + { + var trimValues = values.Select(a => a.Trim()).ToArray(); + bool isFirstLoop = true; + bool isInvalid = false; + string misMatchedColumn = ""; + + sb.Append(""); + for (int i = 0; i < trimValues.Length; i++) + { + //mandatory fields + if (isFirstLoop && (string.IsNullOrEmpty(trimValues[0]) || !IsValidPartner(trimValues[0]) || string.IsNullOrEmpty(trimValues[1]) || string.IsNullOrEmpty(trimValues[2]) || string.IsNullOrEmpty(trimValues[3]) || + string.IsNullOrEmpty(trimValues[4]) || string.IsNullOrEmpty(trimValues[6]) || string.IsNullOrEmpty(trimValues[7]) || string.IsNullOrEmpty(trimValues[8]) || + string.IsNullOrEmpty(trimValues[9]) || string.IsNullOrEmpty(trimValues[12]) || string.IsNullOrEmpty(trimValues[13]) || !IsValidDate(trimValues[13]) || + string.IsNullOrEmpty(trimValues[15]) || !IsValidPaymentMethod(trimValues[15]) || (trimValues[15].ToLower().Equals("w") && (!IsValidNumber(trimValues[10]) || trimValues[14].ToLower() != "imepay")) || + (trimValues[15].ToLower().Equals("b") && (string.IsNullOrEmpty(trimValues[14]) || string.IsNullOrEmpty(trimValues[16]) || string.IsNullOrEmpty(trimValues[18]) || !IsValidBankid(trimValues[14]))) || + string.IsNullOrEmpty(trimValues[19]) || string.IsNullOrEmpty(trimValues[20]) || (IsRateRequiredPartner(trimValues[0]) && string.IsNullOrEmpty(trimValues[22])) || string.IsNullOrEmpty(trimValues[23]))) + { + isInvalid = true; + isFirstLoop = false; + } + + // to assign invalidreason for empty columns values + if (string.IsNullOrEmpty(trimValues[i]) && (i == 0 || i == 1 || i == 2 || i == 3 || i == 4 || i == 6 || i == 7 || i == 8 + || i == 9 || i == 12 || i == 13 || i == 15 || i == 19 || i == 20)) + misMatchedColumn += string.IsNullOrEmpty(misMatchedColumn) ? columnList[i].ToString() : ',' + columnList[i].ToString(); + + // to assign invalidreason for invalid columns values + else if ((i == 0 && !IsValidPartner(trimValues[0])) || (i == 10 && trimValues[15].ToLower().Equals("w") && !IsValidNumber(trimValues[10])) || + (i == 13 && !IsValidDate(trimValues[13])) || (i == 14 && trimValues[15].ToLower().Equals("w") && trimValues[14].ToLower() != "imepay") || + (i == 14 && trimValues[15].ToLower().Equals("b") && string.IsNullOrEmpty(trimValues[14])) || (i == 15 && !IsValidPaymentMethod(trimValues[15])) || + (i == 16 && trimValues[15].ToLower().Equals("b") && string.IsNullOrEmpty(trimValues[16])) || (i == 18 && trimValues[15].ToLower().Equals("b") && string.IsNullOrEmpty(trimValues[18])) || + (i == 14 && trimValues[15].ToLower().Equals("b") && !IsValidBankid(trimValues[14])) || (i == 22 && IsRateRequiredPartner(trimValues[0]) && string.IsNullOrEmpty(trimValues[22])) || string.IsNullOrEmpty(trimValues[23])) + { + misMatchedColumn += string.IsNullOrEmpty(misMatchedColumn) ? columnList[i].ToString() : ',' + columnList[i].ToString(); + } + sb.Append(string.Format(" <{0}>{1}", columnList[i], values[i])); + + } + if (isInvalid) + sb.Append(string.Format(" <{0}>{1}", columnList[24], "Invalid")); + else + sb.Append(string.Format(" <{0}>{1}", columnList[24], "Valid")); + + sb.Append(string.Format(" <{0}>{1}", columnList[25], misMatchedColumn)); + sb.Append(" "); + } + } + } + sb.Append(""); + return sb.ToString(); + } + + public static bool IsValidPaymentMethod(string name) + { + string[] nameArray = { "c", "b", "w" }; + if (Array.Exists(nameArray, element => element == name.ToLower())) + return true; + return false; + } + public static bool IsValidNumber(string number) + { + if (Regex.Match(number, @"^9(61|62|74|75|80|81|82|84|85|86|88)[0-9]{7}$").Success) + return true; + return false; + } + public static bool IsValidDate(string date) + { + string[] format = { "yyyy-mm-dd" }; + DateTime parsedDateTime; + if (DateTime.TryParseExact(date, format, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.NoCurrentDateDefault, out parsedDateTime)) + return true; + return false; + } + public static bool IsValidPartner(string partnerId) + { + var db = new RemittanceDao(); + var sql = "EXEC proc_UploadedFileTxnHistory @flag = 'checkPartner', @partnerId = '" + partnerId + "'"; + var dbResult = db.ParseDbResult(sql); + if (dbResult.ErrorCode == "0") + return true; + return false; + } + public static bool IsRateRequiredPartner(string partnerId) + { + var rateRequiredPartners = ConfigurationManager.AppSettings["rate_required_partners"]; + + List lst = new List(); + if (rateRequiredPartners != null) + { + lst = rateRequiredPartners.Split('|').ToList(); + + if (lst.Contains(partnerId)) + return true; + + } + return false; + } + public static bool IsValidBankid(string bankId) + { + if (string.IsNullOrEmpty(bankId)) + return false; + var db = new RemittanceDao(); + var sql = "EXEC proc_UploadedFileTxnHistory @flag = 'checkbankCode', @partnerId = '" + bankId + "'"; + var dbResult = db.ParseDbResult(sql); + if (dbResult.ErrorCode == "0") + return true; + return false; + } } } \ No newline at end of file diff --git a/Swift.web/Swift.web.csproj b/Swift.web/Swift.web.csproj index a724f3f..63de5b6 100644 --- a/Swift.web/Swift.web.csproj +++ b/Swift.web/Swift.web.csproj @@ -396,6 +396,7 @@ + @@ -438,6 +439,7 @@ + @@ -4487,6 +4489,13 @@ List.aspx + + TranFile.aspx + ASPXCodeBehind + + + TranFile.aspx + Calculator.aspx ASPXCodeBehind @@ -4784,6 +4793,13 @@ TransferToVaultManage.aspx + + TxnList.aspx + ASPXCodeBehind + + + TxnList.aspx + Upload.aspx ASPXCodeBehind