示例#1
0
        public static async Task getRegionList(int userId, string token)
        {
            try
            {
                String uriAPI = "https://bkp.cqfutures.com/CQAPI/api/CQBO/region/GetRegionList";

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(uriAPI);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Add($"Authorization", $"Bearer " + token);
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpResponseMessage response = await client.GetAsync(uriAPI + "?userId=" + userId + "&Form_Code=DIVDCD&ref_codeID=US");

                    if (response.IsSuccessStatusCode)
                    {
                        var content = await response.Content.ReadAsStringAsync();

                        USRegionList = JsonConvert.DeserializeObject <CQAPIRegionList>(content);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
                throw ex;
            }
        }
示例#2
0
        public void SearchRegion(CQAPIRegionList regRes, string regionCD)
        {
            try {
                bool retRegVal = false;


                retRegVal = validateRegionCD(regRes, regionCD); //check by region code

                //checkbyname if code is invalid
                if (!retRegVal)
                {
                    retRegVal = validateRegionName(regRes, regionCD);
                }

                //if region is valid
                if (retRegVal)
                {
                    Console.WriteLine("Your Region Code " + regionCD + " is valid.");
                }
                else
                {
                    //if region is invalid
                    Console.WriteLine("Your Region Code is invalid");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in SearchRegion: " + ex.Message);
                //  throw ex;
            }


            // return retRegVal;
        }
示例#3
0
        private string DoSearch(CQAPICountryList countryRes, string fieldVal, CQAPIRegionList regionRes)
        {
            string retVal    = string.Empty;
            string newFldVal = fieldVal.Replace(",", " ");

            newFldVal = newFldVal.Replace("/", " ");
            newFldVal = newFldVal.Replace(".", " ");

            // Search for Address Field in Bank Order fields Address, 1 ,2 and 3
            bool validCode = false;

            string[] arrVal = newFldVal.Split(" ");
            foreach (var val in arrVal.Reverse())
            {
                string newVal = val.Replace(",", "");
                //newVal = val.Replace(".", "");
                //newVal = val.Replace("/", "");
                //newVal = val.Replace(@"\", "");
                newVal = newVal.ToString() == "USA" ? "US" : newVal.ToString();

                if (IsUSRegion(regionRes, val.ToString()))
                {
                    newVal = "US";
                }
                else
                {
                    newVal = newVal.ToString() == "YORK" ? "US" : newVal.ToString() == "NEWYORK" ? "US" : newVal.ToString();
                    newVal = newVal.ToString() == "MEX" ? "MX" : newVal.ToString();
                    newVal = newVal.ToString() == "ENGLAND" ? "GB" : newVal.ToString() == "LONDON" ? "GB" : newVal.ToString();
                    newVal = newVal.ToString() == "SAUDI" ? "SA" : newVal.ToString() == "KSA" ? "SA" : newVal.ToString();
                    newVal = newVal.ToString() == "RUSSIAN" ? "RU" : newVal.ToString() == "RUSSIA" ? "RU" : newVal.ToString();
                    newVal = newVal.ToString() == "JOHANNESBURG" ? "ZA" : newVal.ToString() == "AFRICA" ? "ZA" : newVal.ToString() == "PIETERMARITZBURG" ? "ZA" : newVal.ToString();                     //PIETERMARITZBURG
                    newVal = newVal.ToString() == "UAE" ? "AE" : newVal.ToString() == "EMIRATES" ? "AE" : newVal.ToString() == "EMIRATES/AE" ? "AE" : newVal.ToString();
                    newVal = newVal.ToString() == "AIRESARGENTINA" ? "AR" : newVal.ToString() == "AIRES" ? "AR" : newVal.ToString();
                    newVal = newVal.ToString() == "DOMINICANA" ? "DO" : newVal.ToString() == "DOMINICAN" ? "DO" : newVal.ToString();
                    newVal = newVal.ToString() == "HONG" ? "HK" : newVal.ToString() == "KONG" ? "HK" : newVal.ToString();
                    newVal = newVal.ToString() == "NSW" ? "AU" : newVal.ToString() == "WALES" ? "AU" : newVal.ToString();
                    newVal = newVal.ToString() == "VIET" ? "VN" : newVal.ToString() == "HANOI" ? "VN" : newVal.ToString();
                }


                validCode = ValidCountryCode(countryRes, newVal);
                if (validCode)
                {
                    retVal = newVal.ToString();
                    break;
                }
                else
                {
                    retVal = GetCountryCodeByName(countryRes, newVal);
                    if (retVal != "")
                    {
                        return(retVal);
                    }
                }
            }
            return(retVal);
        }
示例#4
0
        public bool IsUSRegion(CQAPIRegionList regionList, string regionCode)
        {
            bool retVal = false;

            var cCode = regionList.data.Where(x => x.form_CodeID == regionCode).FirstOrDefault();

            if (cCode != null)
            {
                if (cCode.form_CodeID != "")
                {
                    retVal = true;
                }
            }
            return(retVal);
        }
示例#5
0
        public static async Task getRegionList(CQAPIResultData ValidUser, string ctryCode, string regionCD)
        {
            try
            {
                String uriAPI = "https://bkp.cqfutures.com/CQAPI/api/CQBO/region/GetRegionList";

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(uriAPI);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Add($"Authorization", $"Bearer " + ValidUser.token);
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpResponseMessage response = await client.GetAsync(uriAPI + "?userId=" + ValidUser.userId + "&Form_Code=DIVDCD&ref_codeID=" + ctryCode);

                    if (response.IsSuccessStatusCode)
                    {
                        var content = await response.Content.ReadAsStringAsync();

                        //Console.WriteLine("Region List");
                        CQAPIRegionList regionRes = JsonConvert.DeserializeObject <CQAPIRegionList>(content);


                        //Console.WriteLine("regionRes totalRecord: " + regionRes.totalRecord);
                        //Console.WriteLine("regionRes.data count: " + regionRes.data.Count);
                        //foreach(var item in regionRes.data)
                        //{
                        //    Console.WriteLine(item.form_CodeID + " || " + item.form_CodeDescription);

                        //}


                        ValidateRegion region = new ValidateRegion();
                        region.SearchRegion(regionRes, regionCD);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
                throw ex;
            }
        }
示例#6
0
        public void GetBankTrans(CQAPICountryList countryRes, CQAPIRegionList regionRes)
        {
            //[USP_PCI_BankTrans_Get]
            conn = new SqlConnection(connString);
            SqlCommand cmd = new SqlCommand("USP_PCI_BankTrans_Get", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            conn.Open();

            SqlDataReader rdr = cmd.ExecuteReader();
            DataTable     tbl = new DataTable();

            tbl.Load(rdr);
            conn.Close();

            tbl = IdentifyCQAccount(tbl);
            IdentifyCountryCode(tbl, countryRes, regionRes);
            //UpdateCountryCode(tbl, countryRes);
        }
示例#7
0
        public bool validateRegionName(CQAPIRegionList regRes, string regionCD)
        {
            bool retVal = false;

            try
            {
                var rCode = regRes.data.Where(x => x.form_CodeDescription.TrimEnd().TrimStart().ToUpper() == regionCD.ToUpper()).FirstOrDefault().form_CodeDescription.ToUpper();

                if (rCode != "")
                {
                    retVal = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in validateRegionName: " + ex.Message);
                // throw ex;
            }
            return(retVal);
        }
示例#8
0
        public bool validateRegionCD(CQAPIRegionList regRes, string regionCD)
        {
            bool retVal = false;

            try {
                var cCode = regRes.data.Where(x => x.form_CodeID == regionCD).FirstOrDefault();
                if (cCode != null)
                {
                    if (cCode.form_CodeID != "")
                    {
                        retVal = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in validateRegionCD: " + ex.Message);
                //   throw ex;
            }
            return(retVal);
        }
示例#9
0
        public void IdentifyCountryCode(DataTable tbl, CQAPICountryList countryRes, CQAPIRegionList regionRes)
        {
            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                Console.Write(string.Format("\r Processing item {0} of {1}", i + 1, tbl.Rows.Count));
                string strId = "489B1546-BD17-4E6A-8EDC-69A876548333";
                if (tbl.Rows[i]["Id"].ToString().ToUpper() == strId.ToUpper())
                {
                    string mel = "";
                }


                for (int c = 0; c < tbl.Columns.Count; c++)
                {
                    string strVal = tbl.Rows[i][c].ToString();

                    if (strVal.Length > 4)
                    {
                        if (strVal.Substring(0, 4) == "BIC-" || strVal.Substring(0, 4) == "ABA-")                         // BMO Format to identify Swift code or ABA code
                        {
                            string countryCode = string.Empty;
                            if (strVal.Substring(0, 4) == "BIC-")
                            {
                                countryCode = strVal.Substring(8, 2);                                 // Get Value from Swift Code
                            }
                            else
                            {
                                countryCode = "US";                                  //US Bank account via ABA code
                            }

                            tbl.Rows[i]["CountryCode"] = countryCode;
                            tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                            tbl.Rows[i]["Remarks"]     = string.Format("Identified through " + strVal.Substring(0, 3) + " code format {0}", strVal);
                            Console.Write(string.Format("\n Processing item {0} of {1} - Value {2}", i + 1, tbl.Rows.Count, strVal));
                            if (tbl.Rows[i]["CountryName"].ToString() != "")
                            {
                                break;
                            }
                        }
                    }

                    if (HasSwiftCode(strVal))
                    {
                        string countryCode = strVal.Substring(4, 2);
                        tbl.Rows[i]["CountryCode"] = countryCode;
                        tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                        tbl.Rows[i]["Remarks"]     = string.Format("Identified through Swift Code {0}", strVal);
                        Console.Write(string.Format("\n Processing item {0} of {1} - Value {2}", i + 1, tbl.Rows.Count, strVal));
                        if (tbl.Rows[i]["CountryName"].ToString() != "")
                        {
                            break;
                        }
                    }
                    if (strVal.Length >= 23)
                    {
                        if (strVal.Substring(0, 10) == "ORDER BANK")
                        {
                            string strToMatch = strVal.Substring(12, 11);
                            if (HasSwiftCode(strToMatch))
                            {
                                string countryCode = strToMatch.Substring(4, 2);
                                tbl.Rows[i]["CountryCode"] = countryCode;
                                tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                                tbl.Rows[i]["Remarks"]     = string.Format("Identified from Order Bank Swift Code {0}", strToMatch);
                                Console.Write(string.Format("\n Processing item {0} of {1} - Value {2}", i + 1, tbl.Rows.Count, strToMatch));
                                if (tbl.Rows[i]["CountryName"].ToString() != "")
                                {
                                    break;
                                }
                            }
                        }
                    }

                    if (HasOtherIntlTransferCode(strVal))
                    {
                        string countryCode = strVal.Substring(0, 2);
                        tbl.Rows[i]["CountryCode"] = countryCode;
                        tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                        tbl.Rows[i]["Remarks"]     = string.Format("Identified through IBAN code format {0}", strVal);
                        Console.Write(string.Format("\n Processing item {0} of {1} - Value {2}", i + 1, tbl.Rows.Count, strVal));
                        if (tbl.Rows[i]["CountryName"].ToString() != "")
                        {
                            break;
                        }
                    }

                    if (IsACH(strVal))
                    {
                        string countryCode = "US";
                        tbl.Rows[i]["CountryCode"] = countryCode;
                        tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                        tbl.Rows[i]["Remarks"]     = string.Format("Identified ACH Transfer {0}", strVal);
                        Console.Write(string.Format("\n Processing item {0} of {1} - Value {2}", i + 1, tbl.Rows.Count, strVal));
                        if (tbl.Rows[i]["CountryName"].ToString() != "")
                        {
                            break;
                        }
                    }

                    if (strVal.Length >= 17)                     // SPECIAL
                    {
                        if (strVal.Substring(0, 17) == "ADVANTAGE FUTURES")
                        {
                            string countryCode = "US";
                            tbl.Rows[i]["CountryCode"] = countryCode;
                            tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                            tbl.Rows[i]["Remarks"]     = string.Format("Identified through Payemnt Details - {0}", strVal.Substring(0, 17));
                            Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                        }
                    }
                }

                string fldBEVal = tbl.Rows[i]["BE_Id"].ToString();
                if (fldBEVal == "30865347" || fldBEVal == "30855974" || fldBEVal == "31253713") // Beneficiary is PCI Account 30865347, 30855974
                {
                    if (tbl.Rows[i]["CountryName"].ToString() == "")                            // no value from other validation above
                    {
                        string fldOBIdVal          = tbl.Rows[i]["OB_Id"].ToString();
                        string fldBOIdVal          = tbl.Rows[i]["BO_Id"].ToString();
                        string fldBBIdVal          = tbl.Rows[i]["BB_Id"].ToString();
                        string fldSourceRefVal     = tbl.Rows[i]["SourceRef"].ToString();
                        string fldPaymentDetailVal = tbl.Rows[i]["PaymentDetails"].ToString();
                        if (fldPaymentDetailVal.Length >= 17)
                        {
                            if (fldPaymentDetailVal.Substring(0, 17) == "INTERNAL TRANSFER")
                            {
                                string countryCode = "US";
                                tbl.Rows[i]["CountryCode"] = countryCode;
                                tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                                tbl.Rows[i]["Remarks"]     = string.Format("Identified through Payemnt Details - {0}", fldPaymentDetailVal.Substring(0, 17));
                                Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                            }
                        }

                        if (IsUSBankFormat(fldOBIdVal) && IsUSBankFormat(fldBOIdVal) && tbl.Rows[i]["CountryName"].ToString() == "")
                        {
                            string countryCode = "US";
                            tbl.Rows[i]["CountryCode"] = countryCode;
                            tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                            tbl.Rows[i]["Remarks"]     = string.Format("Identified through US Bank Account format");
                            Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                            //break;
                        }

                        if (fldBOIdVal == fldOBIdVal && tbl.Rows[i]["CountryName"].ToString() == "")
                        {
                            string countryCode = "US";
                            tbl.Rows[i]["CountryCode"] = countryCode;
                            tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                            tbl.Rows[i]["Remarks"]     = string.Format("Identified through US Bank Account format. Ordering Bank and Order By is same account.");
                            Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                            //break;
                        }

                        if ((fldSourceRefVal.Length == 16 || fldSourceRefVal.Length == 15) && fldBOIdVal.Length == 10 && fldOBIdVal.Length == 9 && tbl.Rows[i]["CountryName"].ToString() == "")
                        {
                            string countryCode = "US";
                            tbl.Rows[i]["CountryCode"] = countryCode;
                            tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                            if (fldSourceRefVal.Length == 15)
                            {
                                tbl.Rows[i]["Remarks"] = string.Format("Identified through USAA federal Savings Bank Source Ref and Order By and Order Bank field format with PCI account as beneficiary");
                            }
                            else
                            {
                                tbl.Rows[i]["Remarks"] = string.Format("Identified through US Bank Account format from SoruceRef, Order By and Order Bank field with PCI account as beneficiary");
                            }

                            Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                        }

                        if (fldSourceRefVal.Length == 16 && fldOBIdVal.Length == 9 && tbl.Rows[i]["CountryName"].ToString() == "")
                        {
                            string countryCode = "US";
                            tbl.Rows[i]["CountryCode"] = countryCode;
                            tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                            tbl.Rows[i]["Remarks"]     = string.Format("Identified through US Bank Account format from SourceRef and Order By with PCI account as beneficiary");
                            Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                        }

                        if (fldBOIdVal.Length == 10 && fldOBIdVal.Length == 9 && tbl.Rows[i]["CountryName"].ToString() == "")
                        {
                            string countryCode = "US";
                            tbl.Rows[i]["CountryCode"] = countryCode;
                            tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                            tbl.Rows[i]["Remarks"]     = string.Format("Identified through US Bank Account format from Order By and Order Bank field with PCI account as beneficiary");
                            Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                        }

                        if (fldSourceRefVal.Length >= 3)
                        {
                            if (fldSourceRefVal.Substring(0, 3) == "OPF" && tbl.Rows[i]["CountryName"].ToString() == "")                             // Now Check if from NAVY Federal Credit Union
                            {
                                string countryCode = "US";
                                tbl.Rows[i]["CountryCode"] = countryCode;
                                tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                                tbl.Rows[i]["Remarks"]     = string.Format("Identified through US Bank Source Ref from Navy Federal Credit Union By Order Address");
                                Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                            }
                        }
                        if (fldSourceRefVal.Length == 12)                         // JP Morgan Source Ref format
                        {
                            if (IsJPMorganSourceFormat(fldSourceRefVal))
                            {
                                if (fldSourceRefVal.Substring(10, 2) == "ES")
                                {
                                    string countryCode = "US";
                                    tbl.Rows[i]["CountryCode"] = countryCode;
                                    tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                                    tbl.Rows[i]["Remarks"]     = string.Format("JPMorgan US Bank Source Reference Format - {0}", fldSourceRefVal);
                                    Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                                }
                            }
                        }
                    }
                }
                else                                                 // Not PCI account as Beneficiary
                {
                    if (tbl.Rows[i]["CountryName"].ToString() == "") // no value from other validation above
                    {
                        string fldOBIdVal      = tbl.Rows[i]["OB_Id"].ToString();
                        string fldBOIdVal      = tbl.Rows[i]["BO_Id"].ToString();
                        string fldBBIdVal      = tbl.Rows[i]["BB_Id"].ToString();
                        string fldSourceRefVal = tbl.Rows[i]["SourceRef"].ToString();

                        if (fldBEVal.Length == 9 && fldBBIdVal.Length == 9)
                        {
                            string countryCode = "US";
                            tbl.Rows[i]["CountryCode"] = countryCode;
                            tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                            tbl.Rows[i]["Remarks"]     = string.Format("Identified through US Bank account format from Benificiary and Bank beneficiary field");
                            Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                        }
                        if (fldBBIdVal.Length == 9 && fldBOIdVal == "" && fldOBIdVal == "")
                        {
                            string countryCode = "US";
                            tbl.Rows[i]["CountryCode"] = countryCode;
                            tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, countryCode);
                            tbl.Rows[i]["Remarks"]     = string.Format("Identified through US Bank account format from Bank beneficiary field");
                            Console.Write(string.Format("\n Processing item {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                        }
                    }
                }

                // Check the addresses here

                if (tbl.Rows[i]["CountryName"].ToString() == "")                 // no value from other validation above
                {
                    Console.Write(string.Format("\n identifying address for row {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                    for (int BO = 3; BO >= 0; BO--)
                    {
                        string fieldCnt = BO == 0 ? "" : BO.ToString();
                        string fieldVal = tbl.Rows[i]["BO_NameAdd" + fieldCnt].ToString();
                        if (fieldVal != "")
                        {
                            string retCountryCode = DoSearch(countryRes, fieldVal, regionRes);
                            if (retCountryCode != "")
                            {
                                tbl.Rows[i]["CountryCode"] = retCountryCode;
                                tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, retCountryCode);
                                if (tbl.Rows[i]["CountryName"].ToString() != "")
                                {
                                    tbl.Rows[i]["Remarks"] = string.Format("Identified through By Order Address - {0}", fieldVal);
                                    Console.Write(string.Format(" - {0} identified", retCountryCode));
                                }
                            }

                            if (retCountryCode != "")
                            {
                                BO = 0;
                            }
                        }
                    }
                }

                if (tbl.Rows[i]["CountryName"].ToString() == "")                 // no value from other validation above
                {
                    Console.Write(string.Format("\n identifying address for row {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                    for (int OB = 3; OB >= 0; OB--)
                    {
                        string fieldCnt = OB == 0 ? "" : OB.ToString();
                        string fieldVal = tbl.Rows[i]["OB_NameAdd" + fieldCnt].ToString();
                        if (fieldVal != "")
                        {
                            string retCountryCode = DoSearch(countryRes, fieldVal, regionRes);
                            if (retCountryCode != "")
                            {
                                tbl.Rows[i]["CountryCode"] = retCountryCode;
                                tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, retCountryCode);
                                if (tbl.Rows[i]["CountryName"].ToString() != "")
                                {
                                    tbl.Rows[i]["Remarks"] = string.Format("Identified through Order Bank Address - {0}", fieldVal);
                                    Console.Write(string.Format(" - {0} identified", retCountryCode));
                                }
                            }

                            if (retCountryCode != "")
                            {
                                OB = 0;
                            }
                        }
                    }
                }

                if (tbl.Rows[i]["CountryName"].ToString() == "")                 // no value from other validation above
                {
                    Console.Write(string.Format("\n identifying address for row {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                    for (int BB = 3; BB >= 0; BB--)
                    {
                        string fieldCnt = BB == 0 ? "" : BB.ToString();
                        string fieldVal = tbl.Rows[i]["BB_NameAdd" + fieldCnt].ToString();
                        if (fieldVal != "")
                        {
                            if (fieldVal.Length >= 18)
                            {
                                if (fieldVal.Substring(0, 18) == "POST ALL DEBITS TO")
                                {
                                    break;
                                }
                            }

                            string retCountryCode = DoSearch(countryRes, fieldVal, regionRes);
                            if (retCountryCode != "")
                            {
                                tbl.Rows[i]["CountryCode"] = retCountryCode;
                                tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, retCountryCode);
                                if (tbl.Rows[i]["CountryName"].ToString() != "")
                                {
                                    tbl.Rows[i]["Remarks"] = string.Format("Identified through Benificiary Bank Address - {0}", fieldVal);
                                    Console.Write(string.Format(" - {0} identified", retCountryCode));
                                }
                            }

                            if (retCountryCode != "")
                            {
                                BB = 0;
                            }
                        }
                    }
                }

                if (tbl.Rows[i]["CountryName"].ToString() == "")                 // no value from other validation above
                {
                    Console.Write(string.Format("\n identifying address for row {0} of {1} - ID {2}", i + 1, tbl.Rows.Count, tbl.Rows[i]["Id"].ToString()));
                    for (int BE = 3; BE >= 0; BE--)
                    {
                        string fieldCnt = BE == 0 ? "" : BE.ToString();
                        string fieldVal = tbl.Rows[i]["BE_NameAdd" + fieldCnt].ToString();
                        if (fieldVal != "")
                        {
                            string retCountryCode = DoSearch(countryRes, fieldVal, regionRes);
                            if (retCountryCode != "")
                            {
                                tbl.Rows[i]["CountryCode"] = retCountryCode;
                                tbl.Rows[i]["CountryName"] = GetCountryName(countryRes, retCountryCode);
                                if (tbl.Rows[i]["CountryName"].ToString() != "")
                                {
                                    tbl.Rows[i]["Remarks"] = string.Format("Identified through Benificiary Address - {0}", fieldVal);
                                    Console.Write(string.Format(" - {0} identified", retCountryCode));
                                }
                            }

                            if (retCountryCode != "")
                            {
                                BE = 0;
                            }
                        }
                    }
                }
            }

            conn = new SqlConnection(connString);
            conn.Open();
            SqlCommand cmd = new SqlCommand("USP_PCI_BankTrans_Update", conn);

            //cmd.Parameters.Add(
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@tblBankTransUpdate", tbl);
            cmd.ExecuteNonQuery();
            conn.Close();
        }