Esempio n. 1
0
        public string GetAnsweredFaq(string id, string dealerUserName, string dealerPassword, string mtid)
        {
            ClsDealer dl        = new ClsDealer();
            string    bottonMsg = dl.GetBottomMsg();

            if (RequestIsValid(dealerUserName, dealerPassword))
            {
                ClsPayment cp = new ClsPayment();
                DataTable  dt = cp.GetAnsweredFaq(id);

                string qid = "", question = "", answer = "";

                foreach (DataRow row in dt.Rows)
                {
                    qid      = row["id"].ToString();
                    question = row["question"].ToString();
                    answer   = row["answer"].ToString();

                    return("1|qid_question_answer|" + qid + "|" + question + "|" + answer);
                }

                //log the mobile request
                //ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetReceipt", "0|No receipt");

                return("0|Not yet Answered");
            }
            else
            {
                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetAnsweredFaq", "0|Invalid_Request");

                return("0|Invalid_Request");
            }
        }
Esempio n. 2
0
        public string GetMsgs(string dealerUserName, string dealerPassword, string mtid)
        {
            ClsDealer dl = new ClsDealer();

            string reqParams = "dealerUserName:"******"|REQ", "GetMsgs", reqParams);

            mtid += "|RESP";

            if (RequestIsValid(dealerUserName, dealerPassword))
            {
                string jsonString = "";

                string results = "";

                ClsPayment cp = new ClsPayment();
                DataTable  dr = cp.GetMsgs();

                if (dr.Rows.Count > 0)
                {
                    foreach (DataRow row in dr.Rows)
                    {
                        results += ($"|{row["id"].ToString()}^{row["title"].ToString()}^{row["date"].ToString()}");
                    }

                    jsonString = "1" + results;
                }
                else
                {
                    jsonString = "0|No question available";
                }

                //log the mobile resp
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetMsgs", jsonString);


                return(jsonString);
            }
            else
            {
                //log the mobile resp
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetMsgs", "0|Invalid_Request");

                return("0|Invalid_Request");
            }
        }
Esempio n. 3
0
        public string ResetPassword(string dealerUserName, string dealerEmail, string mtid)
        {
            string returnString = "0|Wrong details supplied";

            ClsDealer dl = new ClsDealer();

            string reqParams = $"dealerUserName:{dealerUserName}|dealerEmail:{dealerEmail}";

            //log the mobile request
            ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid + "|REQ", "ResetPassword", reqParams);

            //the algorithm seems ideal but kinda slow
            //List<char> l = mtid.ToList<char>();
            //l = l.OrderBy(o => Guid.NewGuid().ToString()).ToList();

            //StringBuilder newPassword = new StringBuilder();

            //foreach (char c in l)
            //    newPassword.Append(c.ToString());

            string newPassword = mtid.Substring(2, 6);

            if (dl.DealerEmailIsCorrect(dealerUserName, dealerEmail))
            {
                dl.ChangeDealerPassword(dealerUserName, MD5Crypt.MDee5(newPassword));

                PortalMailer mailer = new PortalMailer();

                mailer.subject = "Pawakad Password Reset Notification.";
                mailer.emailTo = dealerEmail;
                mailer.body    = "Dear " + dealerUserName + ",<br><br>"
                                 + "You initiated a password reset from your mobile device<br>"
                                 + $"You new password is {newPassword}<br>"
                                 + $"We advice you logon to the web and change t to something different and suitable for you<br>"
                                 + "<br><br> Thank You.";

                mailer.SendMail();
                returnString = $"1|newPassword|{newPassword}";
            }

            mtid += "|RESP";
            //log the mobile response
            ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "ResetPassword", returnString);

            return(returnString);
        }
Esempio n. 4
0
        public string GetFaq(string dealerUserName, string dealerPassword, string mtid)
        {
            if (RequestIsValid(dealerUserName, dealerPassword))
            {
                string jsonString = "";

                string results = "";

                ClsPayment cp = new ClsPayment();
                DataTable  dr = cp.GetFaq();

                if (dr.Rows.Count > 0)
                {
                    foreach (DataRow row in dr.Rows)
                    {
                        results += ("|" + row["id"].ToString() + "^" + row["question"].ToString());
                    }

                    //ClsDealer dl = new ClsDealer();
                    ////log the mobile request
                    //ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetPaymentLog", "1" + results);
                    jsonString = "1" + results;
                }
                else
                {
                    //ClsDealer dl = new ClsDealer();
                    ////log the mobile request
                    //ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetPaymentLog", "0|The account number has never been used on our platform");
                    jsonString = "0|No question available";
                }



                return(jsonString);
            }
            else
            {
                ClsDealer dl = new ClsDealer();
                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetFaq", "0|Invalid_Request");

                return("0|Invalid_Request");
            }
        }
Esempio n. 5
0
        public string GetMsg(string id, string dealerUserName, string dealerPassword, string mtid)
        {
            ClsDealer dl = new ClsDealer();

            string reqParams = $"id:{id}|dealerUserName:{dealerUserName}";

            //log the mobile request
            ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid + "|REQ", "GetMsg", reqParams);

            mtid += "|RESP";

            string jsonString = "";

            if (RequestIsValid(dealerUserName, dealerPassword))
            {
                ClsPayment cp = new ClsPayment();
                DataTable  dt = cp.GetMsg(id);

                string title = "", message = "", date = "";

                foreach (DataRow row in dt.Rows)
                {
                    title   = row["title"].ToString();
                    message = row["message"].ToString();
                    date    = row["date"].ToString();

                    return("1|title_message_date|" + title + "|" + message + "|" + date);
                }

                jsonString = "0|Invalid Msg Id";
            }
            else
            {
                jsonString = "0|Invalid_Request";
            }

            //log the mobile request
            ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetMsg", jsonString);

            return(jsonString);
        }
Esempio n. 6
0
        public static string PerformPayment(string meterNo, string amt, string dealerName, string custName, string custAddress, string crCode, string fixedCharge2,
                                            string conlogTID, string password, string mtid, string channelRefNo, string phoneNo, string collectionType = "NRG",
                                            string accountType = "", string orgName = "", string orgNo = "", string invoiceNo = "", string businessUnit = "")
        {
            string    errorMsg = "";
            ClsLog    cl       = new ClsLog();
            ClsDealer dl       = new ClsDealer();


            string reqParams = "meterNo:" + meterNo + "|" +
                               "amt:" + amt + "|" +
                               "dealerName:" + dealerName + "|" +
                               "custName:" + custName + "|" +
                               "custAddress:" + custAddress + "|" +
                               "crCode:" + crCode + "|" +
                               "fixedCharge2:" + fixedCharge2 + "|" +
                               "conlogTID:" + conlogTID + "|" +
                               "channelRefNo:" + channelRefNo + "|" +
                               "collectionType:" + collectionType + "|" +
                               "invoiceNo:" + invoiceNo + "|" +
                               "phoneNo:" + phoneNo + "|" +
                               "businessUnit:" + businessUnit
            ;

            //log the mobile request
            int rowCount = ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid + "|REQ", "SubmitPayment", reqParams, channelRefNo);

            if (rowCount != 1)
            {
                return($"0|The MTID {mtid} cannot be used again");
            }

            mtid += "|RESP";

            custName    = custName.Replace("$$$", " ");
            custAddress = custAddress.Replace("$$$", " ");

            custName    = custName.Replace("___", "&");
            custAddress = custAddress.Replace("___", "&");

            string[]      arrCrCodesForToken = { "MT", "PT", "NT", "CT" };
            List <string> lstCrCodesForToken = arrCrCodesForToken.ToList();

            string[]      arrCrCodesForBill = { "MB", "PB", "NB", "CB" };
            List <string> lstCrCodesForBill = arrCrCodesForBill.ToList();

            string[]      arrCrCodesForLocal = { "MB", "MT" };
            List <string> lstCrCodesForLocal = arrCrCodesForLocal.ToList();


            ClsDealer cd = new ClsDealer();

            string dCode = cd.GetDealerCode(dealerName).ToString();

            ClsCards cls = new ClsCards();

            if (channelRefNo == "" || channelRefNo == null)
            {
                Guid guid = Guid.NewGuid();

                string tDate = DateTime.Today.ToString("yyMMdd").Replace("/", "");
                channelRefNo = crCode + tDate + dCode + "_" + guid.ToString();// +"_" + mtid;

                //log progress -- channelRefNo

                //cls.RunNonQuery("insert into LogPaymentAction(channelRefNo) values('" + channelRefNo + "')");
            }

            if (!Misc.AlreadyTransacted(mtid, dCode))
            {
                if (lstCrCodesForToken.Contains(crCode) && meterNo.Length == 11 || lstCrCodesForBill.Contains(crCode) && (meterNo.Length == 12 || meterNo.Length == 10))
                {
                    if (int.Parse(amt) > 0)
                    {
                        string  returnString      = "";
                        decimal initialAC         = -1;
                        bool    reverseNotAllowed = false;

                        try
                        {
                            if (cd.CheckDealerCredit(dealerName, int.Parse(amt)) == 1)
                            {
                                string getVars = (lstCrCodesForToken.Contains(crCode) ? "vendAmount=" + amt.Replace(",", "") + "&meterNo=" + meterNo : "meterNumber=" + meterNo + "&amntToPay=" + amt.Replace(",", ""));

                                WSCall wsc = new WSCall();

                                //SqlDataReader dr = dl.GetDealerDetails(dealerName);

                                string bottonMsg = dl.GetBottomMsg();
                                //get initial AC
                                initialAC = cd.GetAvailableDealerCredit(dealerName);

                                //log progress -- initialAC
                                //cls.RunNonQuery("update LogPaymentAction set initialAC='" + initialAC + "' where channelRefNo='" + channelRefNo + "'");
                                cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','INITIAL-BALANCE','SUCCESS')");

                                if (collectionType.Equals("NRG"))
                                {
                                    string sgc = "", tariff = "", receiptNo = "", token = "", acctNo = "", rate = "0", units = "0", balance = "0", accountDescription = "", uniqueTID = "";
                                    string /*accountType = "", */ dtName = "", dtNumber = "" /*, orgName = "", orgNo = ""*/;

                                    decimal cou = 0, vat = 0, fixedCharge = 0;

                                    string[] tokens = null;
                                    bool     acNotDeducted = true, conlogNotCalled = true, aggNotLogged = true;

                                    try
                                    {
                                        if (acNotDeducted)
                                        {
                                            //deduct dealer's credit
                                            cd.DeductDealerAvailableCredit(dealerName, Convert.ToInt32(amt));
                                            acNotDeducted = false;
                                            returnString  = "DEALER_JUST_DEBITED";

                                            //log progress -- acDeducted
                                            //cls.RunNonQuery("update LogPaymentAction set acDeducted='YES' where channelRefNo='" + channelRefNo + "'");
                                            cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','ACCOUNT-DEDUCTED','SUCCESS')");
                                        }

                                        if (conlogNotCalled)
                                        {
                                            //call conlog
                                            //startTest
                                            //returnString = "1|TransactionId_CustomerName_CustomerPhoneNumber_CustomerAddress_ReceiptNumber_VendAmount_Token_AccountNumber_TransactionDateTime_SGC_units_Tarrif_Rate_tx|20170511020548~1000033|PAWAKAD1, TS|||PH062/2429|100.00|01234567890123456789|04040406714|5/11/2017 2:04:56 PM|399999|25.42|NEW TARIFF 10|1.00|4.58";
                                            //endTest

                                            returnString = wsc.GetJSON(String.Format(lstCrCodesForToken.Contains(crCode) ? "/creditvend{0}" : "/accountpayment{0}", "?" + Misc.GetClientId + "&" + getVars + "&paymentChannel=" + (lstCrCodesForLocal.Contains(crCode) ? "LOCAL" : "THIRD") + "_" + dCode + "&channelRefNo=" + channelRefNo));

                                            if (returnString == null)
                                            {
                                                returnString = "";
                                            }

                                            conlogNotCalled   = false;
                                            reverseNotAllowed = returnString.StartsWith("1") ? true : false;
                                            tokens            = returnString != null?returnString.Split('|') : null;

                                            //log progress -- conlogCalled
                                            //cls.RunNonQuery("update LogPaymentAction set conlogCalled='YES', conlogResp='" + returnString.Replace("'", "''") + "' where channelRefNo='" + channelRefNo + "'");
                                            cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','CONLOG-CALLED','" + returnString.Replace("'", "''") + "')");
                                        }

                                        if (returnString != null && !returnString.StartsWith("0") && tokens[0] == "1")
                                        {
                                            int    retrials = 0; bool retry = true;
                                            string returnString2 = "";
                                            //retry:

                                            while (retry)
                                            {
                                                DateTime transactionDate = DateTime.Now;

                                                returnString2 = "";
                                                try
                                                {
                                                    if (lstCrCodesForToken.Contains(crCode))
                                                    {
                                                        uniqueTID = tokens[2].Replace("~", "");
                                                        sgc       = tokens[11];
                                                        tariff    = tokens[13];
                                                        receiptNo = tokens[6];
                                                        token     = tokens[8].ToString().Replace("&", "\n");
                                                        acctNo    = tokens[9].Replace("/", "").Replace("-", "");

                                                        rate  = (tokens[14] != "") ? Math.Round(decimal.Parse(tokens[14]), 2).ToString() : "0";
                                                        units = (tokens[12] != "") ? Math.Round(decimal.Parse(tokens[12]), 2).ToString() : "0";

                                                        //new params begin
                                                        accountType = tokens[16];
                                                        dtName      = tokens[17];
                                                        dtNumber    = tokens[18];
                                                        orgName     = tokens[19];
                                                        orgNo       = tokens[20];
                                                        //new params end

                                                        cou = Math.Round(decimal.Parse(tokens[14] != "" ? tokens[14] : "0") * decimal.Parse(tokens[12] != "" ? tokens[12] : "0"), 2);

                                                        vat         = Math.Round(decimal.Parse(tokens[15] != "" ? tokens[15] : "0"), 2);
                                                        fixedCharge = Math.Round(decimal.Parse(amt) - cou - vat, 2);

                                                        if (fixedCharge < 1 && fixedCharge > 0)
                                                        {
                                                            fixedCharge -= fixedCharge;
                                                            cou         += fixedCharge;
                                                        }
                                                        else if (fixedCharge < 0)
                                                        {
                                                            fixedCharge = 0;
                                                        }

                                                        //int sd = 0;
                                                        //int az = 1 / sd;
                                                        //log progress -- aboutToLogPayment
                                                        //cls.RunNonQuery("update LogPaymentAction set aboutToLogPayment='YES' where channelRefNo='" + channelRefNo + "'");
                                                        cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','ABOUT-TO-LOG-PAYMENT','SUCCESS')");

                                                        cd.ApplyPayment2(accountType, dtName, dtNumber, orgName, orgNo, phoneNo, "", acctNo, meterNo, int.Parse(amt), channelRefNo, DateTime.Now, token, sgc, tariff, custName, custAddress, cou, fixedCharge, vat, decimal.Parse(units), decimal.Parse(rate), 0, receiptNo, uniqueTID);

                                                        //log progress -- paymentLogged
                                                        //cls.RunNonQuery("update LogPaymentAction set paymentLogged='YES' where channelRefNo='" + channelRefNo + "'");
                                                        cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','PAYMENT-LOGGED','SUCCESS')");

                                                        int creditBalance = (int)cd.GetAvailableDealerCredit(dealerName);

                                                        returnString2 = "1|time_receiptNo_reprint_cdu_sgc_tariff_meterNo_custName_acctNo_address_transactionAmt_amtTendered_costOfUnit_fixedCharge_vat_unit_purchaseAs_tokens_creditBalance_bottomMsg_AccountType_DtName_DtNumber_OrgName_OrgNo|"
                                                                        + transactionDate + "|" + receiptNo + "|T589 / 8080990|Operator Pawakad|" + sgc + "|" + tariff + "|" + meterNo
                                                                        + "|" + custName + "|" + acctNo + "|" + custAddress + "|" + amt + "|" + amt + "|" + cou.ToString() + "|" + fixedCharge.ToString()
                                                                        + "|" + vat.ToString() + "|" + units + "|" + units + "KWh at N" + rate + " per KWh|" + token + "|" + creditBalance + "|" + bottonMsg + "|"
                                                                        + $"{accountType}|{dtName}|{dtNumber}|{orgName}|{orgNo}|";


                                                        //log the mobile request
                                                        ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", returnString2, channelRefNo);
                                                    }
                                                    else
                                                    {
                                                        uniqueTID          = tokens[2].Replace("~", "");
                                                        receiptNo          = tokens[7];
                                                        balance            = tokens[6];
                                                        accountDescription = tokens[4];

                                                        //new params begin
                                                        accountType = tokens[8];
                                                        dtName      = tokens[9];
                                                        dtNumber    = tokens[10];
                                                        orgName     = tokens[11];
                                                        orgNo       = tokens[12];
                                                        //new params end

                                                        //log progress -- aboutToLogPayment
                                                        //cls.RunNonQuery("update LogPaymentAction set aboutToLogPayment='YES' where channelRefNo='" + channelRefNo + "'");
                                                        cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','ABOUT-TO-LOG-PAYMENT','SUCCESS')");

                                                        cd.ApplyPayment2(accountType, dtName, dtNumber, orgName, orgNo, phoneNo, "", meterNo, "", int.Parse(amt), channelRefNo, DateTime.Now, "", "", "", custName, custAddress, 0,
                                                                         0, 0, 0, 0, decimal.Parse(balance), receiptNo, uniqueTID, collectionType);

                                                        //log progress -- paymentLogged
                                                        //cls.RunNonQuery("update LogPaymentAction set paymentLogged='YES' where channelRefNo='" + channelRefNo + "'");
                                                        cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','PAYMENT-LOGGED','SUCCESS')");

                                                        //get the new availableCredit
                                                        int creditBalance = (int)cd.GetAvailableDealerCredit(dealerName);

                                                        //int sd = 0;
                                                        //int az = 1 / sd;
                                                        returnString2 = "1|time_receiptNo_reprint_cdu_sgc_tariff_meterNo_custName_acctNo_address_transactionAmt_amtTendered_costOfUnit_fixedCharge_vat_unit_purchaseAs_tokens_availableCredit_balance_bottomMsg_AccountType_DtName_DtNumber_OrgName_OrgNo|"
                                                                        + transactionDate + "|" + receiptNo + "|T589 / 8080990|Operator Pawakad|" + sgc + "|" + tariff + "|" + meterNo
                                                                        + "|" + custName + "|" + meterNo + "|" + custAddress + "|" + amt + "|" + amt + "|" + cou + "|" + fixedCharge2
                                                                        + "|" + vat + "|" + units + "|" + "|" + token + "|" + creditBalance + "||" + bottonMsg
                                                                        + $"|{accountType}|{dtName}|{dtNumber}|{orgName}|{orgNo}";;

                                                        //log the mobile request
                                                        ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", returnString2, channelRefNo);
                                                    }
                                                    retry = false;
                                                }
                                                catch (Exception e)
                                                {
                                                    //log progress -- errorMsg
                                                    //cls.RunNonQuery("update LogPaymentAction set errorMsg='" + e.Message + "\n\n\n" + e.Source + "' where channelRefNo='" + channelRefNo + "'");
                                                    cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','EXCEPTION','" + e.Message + "\n\n\n" + e.Source + "')");

                                                    if (retrials < 4)
                                                    {
                                                        retrials++;

                                                        //log progress -- retrials
                                                        //cls.RunNonQuery("update LogPaymentAction set retrials='" + retrials + "' where channelRefNo='" + channelRefNo + "'");
                                                        cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','RETRIALS','" + retrials + "')");

                                                        //goto retry;
                                                    }
                                                    else
                                                    {
                                                        returnString2 = "0|YOUR TRANSACTION IS SUCCESSFUL BUT THE RECEIPT IS NOT READY FOR DISPLAY, PLEASE CHECK BACK IN AN HOUR TIME.";

                                                        string insertQuery =
                                                            "<br/>Meter Number: " + meterNo +
                                                            "<br/>Amount: " + amt +
                                                            "<br/>Address: " + custAddress +
                                                            "<br/>UniqueTID: " + uniqueTID +
                                                            "<br/>Dealer Name: " + dealerName +
                                                            "<br/>CR Code: " + crCode;;

                                                        PortalMailer mailer = new PortalMailer();

                                                        mailer.subject = "Un-generated Receipt.";
                                                        mailer.emailTo = "*****@*****.**";
                                                        mailer.body    = "Details for un-generated receipt<br/><br/>" + insertQuery;

                                                        mailer.SendMail();


                                                        cd.RegeneratePayment(acctNo, meterNo, int.Parse(amt), channelRefNo + "_MG", token, sgc, tariff, custName, custAddress, cou,
                                                                             fixedCharge, vat, decimal.Parse(units), decimal.Parse(rate), decimal.Parse(balance), receiptNo, uniqueTID, collectionType);

                                                        retry = false;
                                                    }
                                                }
                                            }
                                            return(returnString2);
                                        }
                                        else
                                        {
                                            //cd.ReverseTransaction(dealerName, Convert.ToInt32(amt), meterNo, tokens[1], initialAC, tokens[1].Split('~')[1]);
                                            cd.ReverseTransaction(dealerName, Convert.ToInt32(amt), meterNo, tokens[1].Split('^')[0], initialAC, tokens[1].Split('^')[1]);
                                            reverseNotAllowed = true;

                                            cl.LogPaymentError(meterNo, channelRefNo, int.Parse(amt), tokens[1], "PAYMENT", DateTime.Now /*, dCode, DateTime.Now, false*/);

                                            if (tokens[1].ToLower().Contains("block"))
                                            {
                                                errorMsg = "0|This account number is blocked, pls contact Ikeja Electric Customer Care on <br/>0800 022 5543 or 01 448 3900 or 0700 022 5543";
                                                //log the mobile request
                                                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", errorMsg, channelRefNo);

                                                return(errorMsg);
                                            }
                                            else if (tokens[1].ToLower().Contains("arrears to be paid"))
                                            {
                                                errorMsg = "0|The amount you are trying to pay is too low, pls pay above " + fixedCharge2;
                                                //log the mobile request
                                                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", errorMsg, channelRefNo);

                                                return(errorMsg);
                                            }
                                            else if (tokens[1].ToLower().Contains("meter not found"))
                                            {
                                                errorMsg = "0|This account number is invalid ";
                                                //log the mobile request
                                                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", errorMsg, channelRefNo);

                                                return(errorMsg);
                                            }
                                            else if (tokens[1].ToLower().Contains("any instance"))
                                            {
                                                errorMsg = "0|This account number cannot be processed for payment, pls contact Ikeja Electric Customer Care on <br/>0800 022 5543 or 01 448 3900 or 0700 022 5543";

                                                //log the mobile request
                                                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", errorMsg, channelRefNo);

                                                return(errorMsg);
                                            }
                                            else if (tokens[1].ToLower().Contains("no open account match"))
                                            {
                                                errorMsg = "0|This account number is invalid";

                                                //log the mobile request
                                                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", errorMsg, channelRefNo);

                                                return(errorMsg);
                                            }
                                            else
                                            {
                                                errorMsg = "0|" + tokens[1];

                                                //log the mobile request
                                                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", errorMsg, channelRefNo);

                                                return(errorMsg);
                                            }
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        if (!reverseNotAllowed)
                                        {
                                            cd.ReverseTransaction(dealerName, Convert.ToInt32(amt), meterNo, tokens[1].Split('^')[0], initialAC, tokens[1].Split('^')[1]);
                                            reverseNotAllowed = true;
                                        }
                                        return("0|" + e.Message);
                                    }
                                }
                                else
                                {
                                    //rework the receipt to avoid issues where the agent enters an existing receipt no
                                    invoiceNo += ("-" + conlogTID.Replace("~", ""));

                                    //Boolean retry = true;
                                    //while (retry)
                                    //{
                                    try
                                    {
                                        //if LOR2, just write to LogTable
                                        if (meterNo.Equals("0000000000"))
                                        {
                                            string query = "insert into logTable(clientId, uniqueTransactionId, logMsgType, inRequestMsg, outResponseMsg, responseDateTime, paymentChannel, channelRefNo) " +
                                                           "values('" +
                                                           "Pawakad" + "','" +
                                                           conlogTID.Replace("~", "") + "','" +
                                                           "CONFIRM-CUSTOMER" + "','" +
                                                           (meterNo.Length == 12 ? "PP" : "") + meterNo + "|Pawakad" + "','" +
                                                           "" + "','" +
                                                           DateTime.Now + "','" +
                                                           "NER_LOCAL_" + dCode + "','" +
                                                           channelRefNo +
                                                           "')";

                                            cls.RunNonQuery(query);
                                        }
                                        else
                                        {
                                            new pawakadApp.ClsCard.ClsCards().RunNonQuery("update LogTable set PaymentChannel='NER_" + (lstCrCodesForLocal.Contains(crCode) ? "LOCAL" : "THIRD") + "_" + dCode + "' where UniqueTransactionId='" + conlogTID.Replace("~", "") + "'");
                                        }

                                        //deduct dealer balance
                                        cd.DeductDealerAvailableCredit(dealerName, Convert.ToInt32(amt));

                                        //int sd = 0;
                                        //int az = 1 / sd;
                                        //log progress -- acDeducted
                                        //cls.RunNonQuery("update LogPaymentAction set acDeducted='YES',amount=" + int.Parse(amt) + " where channelRefNo='" + channelRefNo + "'");
                                        cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','ACCOUNT-DEDUCTED','SUCCESS')");

                                        //get the new availableCredit
                                        int creditBalance = (int)cd.GetAvailableDealerCredit(dealerName);

                                        //log progress -- aboutToLogPayment
                                        //cls.RunNonQuery("update LogPaymentAction set aboutToLogPayment='YES' where channelRefNo='" + channelRefNo + "'");
                                        cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','ABOUT-TO-LOG-PAYMENT','SUCCESS')");

                                        cd.ApplyPayment2(accountType, "", "", orgName, orgNo, phoneNo, "", meterNo, "", int.Parse(amt), channelRefNo, DateTime.Now, "", "", "", custName, custAddress, 0,
                                                         0, 0, 0, 0, 0, invoiceNo, conlogTID.Replace("~", ""), collectionType);

                                        //set this value to avoid accidental reversal after logging to paymentLog
                                        reverseNotAllowed = true;

                                        //log progress -- paymentLogged
                                        //cls.RunNonQuery("update LogPaymentAction set paymentLogged='YES' where channelRefNo='" + channelRefNo + "'");
                                        cls.RunNonQuery("insert into LogPaymentActionNew (ChannelRefNo,DCode,Channel,InitialAC,Amount,ActionName,ActionDetails) values ('" + channelRefNo + "','" + dCode + "','MOBILE','" + initialAC + "','" + amt + "','PAYMENT-LOGGED','SUCCESS')");

                                        string returnString2 = "1|time_receiptNo_reprint_cdu_sgc_tariff_meterNo_custName_acctNo_address_transactionAmt_amtTendered_costOfUnit_fixedCharge_vat_unit_purchaseAs_tokens_availableCredit_" + (meterNo.Length == 11 ? "" : "balance_") + "bottomMsg_AccountType_DtName_DtNumber_OrgName_OrgNo|"
                                                               + DateTime.Now + "|" + invoiceNo + "|T589 / 8080990|Operator Pawakad|" + "" + "|" + "" + "|" + meterNo
                                                               + "|" + custName + "|" + meterNo + "|" + custAddress + "|" + amt + "|" + amt + "|" + "" + "|" + ""
                                                               + "|" + "" + "|" + "" + "|" + "|" + "" + "|" + creditBalance + "|" + (meterNo.Length == 11 ? "" : "|") + bottonMsg + $"|{accountType}|||{orgName}|{orgNo}|";

                                        //log the mobile request
                                        ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", returnString2, channelRefNo);

                                        //retry = false;

                                        return(returnString2);
                                    }
                                    catch (Exception e)
                                    {
                                        if (!reverseNotAllowed)
                                        {
                                            cd.ReverseTransaction(dealerName, Convert.ToInt32(amt), meterNo, e.Message, initialAC, collectionType + "_" + conlogTID);
                                            reverseNotAllowed = true;
                                        }
                                        return("0|" + e.Message);
                                    }
                                    //}
                                }
                            }
                            else
                            {
                                errorMsg = "0|Insufficient Available Credit";
                                cl.LogPaymentError(meterNo, channelRefNo, int.Parse(amt), errorMsg, "PAYMENT", DateTime.Now /*, dCode, DateTime.Now, false*/);
                                //log the mobile request
                                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", errorMsg, channelRefNo);

                                //dl.AddLoginLocation(dealerName, longitude, latitude, address, mtid);
                                return(errorMsg);
                            }
                        }
                        catch (Exception ex)
                        {
                            if (returnString.Equals("DEALER_JUST_DEBITED"))
                            {
                                cd.ReverseTransaction(dealerName, Convert.ToInt32(amt), meterNo, ex.Message, initialAC, "-1" + DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(1000000, 9999999).ToString());
                                reverseNotAllowed = true;
                            }

                            return("0|Error - ENSURE to confirm availability of receipt from the Payment History BEFORE retrying");
                        }
                    }
                    else
                    {
                        errorMsg = "0|Amount must be greater than ZER0";
                        cl.LogPaymentError(meterNo, channelRefNo, int.Parse(amt), errorMsg, "PAYMENT", DateTime.Now /*, dCode, DateTime.Now, false*/);
                        //log the mobile request
                        ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", errorMsg, channelRefNo);

                        //dl.AddLoginLocation(dealerName, longitude, latitude, address, mtid);
                        return(errorMsg);
                    }
                }
                else
                {
                    errorMsg = "0|Wrong CRCode was specified.";
                    //log the mobile request
                    ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", errorMsg, channelRefNo);

                    //dl.AddLoginLocation(dealerName, longitude, latitude, address, mtid);
                    return(errorMsg);
                }
            }
            else
            {
                errorMsg = "0|Wrong channel ref code";
                cl.LogPaymentError(meterNo, channelRefNo, int.Parse(amt), errorMsg, "PAYMENT", DateTime.Now /*, dCode, DateTime.Now, false*/);

                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "SubmitPayment", errorMsg, channelRefNo);

                //dl.AddLoginLocation(dealerName, longitude, latitude, address, mtid);
                return(errorMsg);
            }
        }
Esempio n. 7
0
        public string ValidateCustomerAndEPIN(string acctNoOrMeterNo, string amt, string dealerName, string password, string mtid, string businessUnit = "")
        {
            ClsDealer dl   = new ClsDealer();
            Guid      guid = Guid.NewGuid();

            string tDate        = DateTime.Today.ToString("yyMMdd").Replace("/", "");
            string paymentType  = new PaymentType().GetPaymentType(acctNoOrMeterNo);
            string channelRefNo = (paymentType == "PREPAID" ? "MT" : "MB") + tDate + dl.GetDealerCode(dealerName).ToString() + "_" + guid.ToString();

            if (RequestIsValid(dealerName, password))
            {
                string reqParams = "acctNoOrMeterNo:" + acctNoOrMeterNo + "|" +
                                   "amt:" + amt + "|" +
                                   "dealerName:" + dealerName + "|" +
                                   "businessUnit:" + businessUnit
                ;


                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid + "|REQ", "ValidateCustomerAndEPIN", reqParams, channelRefNo);

                mtid += "|RESP";

                string customerName = "", address = "", fixedCharge = "";

                string dcode = new ClsDealer().GetDealerCode(dealerName).ToString();

                //log progress -- channelRefNo
                ClsCards cls = new ClsCards();
                //cls.RunNonQuery("insert into LogPaymentAction(channelRefNo) values('" + channelRefNo + "')");

                string getVars = acctNoOrMeterNo.Length == 11
                ? "vendAmount=" + amt + "&meterNo=" + acctNoOrMeterNo + "&paymentChannel=" + dcode
                : "meterNumber=" + (acctNoOrMeterNo.Length == 12 ? "PP" : "") + acctNoOrMeterNo + "&paymentChannel=" + dcode;

                WSCall wsc = new WSCall();

                //RealImplementation
                string returnString = "";

                if (acctNoOrMeterNo != "0000000000")
                {
                    returnString = wsc.GetJSON(String.Format(acctNoOrMeterNo.Length == 11 ? "/TrialCreditVend{0}" : "/confirmcustomer{0}", "?" + Misc.GetClientId + "&" + getVars + "&channelRefNo=" + channelRefNo));
                }
                else
                {
                    //returnString = "1|||||||";

                    string returnString33 = "1|customerName_address_fixedCharge_conlogTID_warningNsg_flag" + (mtid.IndexOf("|") != -1 ? "_channelRefNo" : "") + "||||||0|" + (mtid.IndexOf("|") != -1 ? "|" + channelRefNo : "");
                    //log the mobile request
                    ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "ValidateCustomerAndEPIN", returnString33 + "|" + amt, channelRefNo);

                    return(returnString33);
                }
                //string returnString = wsc.GetJSON(String.Format("/confirmcustomer{0}", getVars)/*, new ClsDealer().GetDealerCode(dealerName).ToString()*/);

                //startTest
                //string returnString = "1|TransactionId_CustomerName_CustomerAddress_CustomerphoneNumber_CustomerAccountNumer_MinimunVendingAmount_Units|20170511115559~1000011|PAWAKAD1, TS|||04040406714|70.00|25.5";
                //endTest

                string warning = "", flag = "0";
                if (acctNoOrMeterNo != "")
                {
                    string[] lastPayment = dl.GetLastPayment(acctNoOrMeterNo, new ClsDealer().GetDealerCode(dealerName).ToString()).Split('_');

                    if (!lastPayment[0].ToString().Equals("") && !lastPayment[1].ToString().Equals("")) // lastPayment returnString ""
                    {
                        warning = "You have made a payment of N" + lastPayment[1] + " for this customer today at " + lastPayment[0].Substring(0, 8) + ".######Are you sure you want to proceed?###### Request for reversal may not be honoured.###";
                        flag    = "1";
                    }
                }

                //this IF is necessary for new meter nums that fails on first vend by returning 'Amount is insufficient' error
                //when a value lesser than the required amount is paid, or null when the required amount or more is paid
                if (returnString == null || returnString == "")
                {
                    returnString = wsc.GetJSON(String.Format("/confirmcustomer{0}", "?" + Misc.GetClientId + "&" + "meterNumber=" + acctNoOrMeterNo + "&paymentChannel=" + dcode + "&channelRefNo=" + channelRefNo));
                }

                if (returnString == null || returnString == "")
                {
                    returnString = "0|Unable to get customer details";
                    //log the mobile request
                    ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "ValidateCustomerAndEPIN", returnString + "|" + amt, channelRefNo);

                    return(returnString);
                }

                string[] tokens = returnString.Split('|');

                if (tokens[0] == "1")
                {
                    customerName = tokens[3];
                    address      = tokens[4];
                    fixedCharge  = tokens[7];
                }
                else
                {
                    string returnString2 = "0|" + tokens[1];
                    //log the mobile request
                    ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "ValidateCustomerAndEPIN", returnString2 + "|" + amt, channelRefNo);

                    return(returnString2);
                }

                string returnString3 = "1|customerName_address_fixedCharge_conlogTID_warningNsg_flag" + (mtid.IndexOf("|") != -1 ? "_channelRefNo" : "") + "|" + customerName + "|" + address + "|" + fixedCharge + "|" + tokens[2] + "|" + warning + "|" + flag + (mtid.IndexOf("|") != -1 ? "|" + channelRefNo : "");
                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "ValidateCustomerAndEPIN", returnString3 + "|" + amt, channelRefNo);

                return(returnString3);
            }
            else
            {
                string returnString = "0|Invalid Request";
                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerName).ToString(), DateTime.Now, mtid, "ValidateCustomerAndEPIN", returnString + "|" + amt, channelRefNo);

                return(returnString);
            }
        }
Esempio n. 8
0
        public string GetReceipt(string channelRefNo, string dealerUserName, string dealerPassword, string mtid)
        {
            ClsDealer dl        = new ClsDealer();
            string    bottonMsg = dl.GetBottomMsg();

            if (RequestIsValid(dealerUserName, dealerPassword))
            {
                string reqParams = "channelRefNo:" + channelRefNo + "|" +
                                   "dealerUserName:"******"|REQ", "GetReceipt", reqParams);

                mtid += "|RESP";

                ClsPayment cp = new ClsPayment();
                DataTable  dt = cp.GetPaymentLog2(channelRefNo);

                string acctNo = "", meterNo = "", address = "", sgc = "", tariff = "", purchasedAs = "", token = "", customer = "", time = "", colectionType = "", invoiceNo = "", bu = "", agent = "";

                foreach (DataRow dr in dt.Rows)
                {
                    string receiptNo = dr["receiptNo"].ToString();

                    if (channelRefNo.StartsWith("WT") || channelRefNo.StartsWith("MT") || channelRefNo.StartsWith("PT") || channelRefNo.StartsWith("NT"))
                    {
                        acctNo      = dr["accountNumber"].ToString();
                        meterNo     = dr["meterNumber"].ToString();
                        address     = dr["address"].ToString();
                        sgc         = dr["sgc"].ToString();
                        tariff      = dr["tariff"].ToString();
                        purchasedAs = dr["units"].ToString() + "KWH at N" + dr["rate"].ToString() + " per KWH";
                        token       = dr["token"].ToString();
                        customer    = dr["customerName"].ToString();
                        time        = dr["transactionDate"].ToString();

                        decimal txnAmt      = decimal.Parse(dr["amount"].ToString());
                        decimal fixedCharge = dr["fixedCharge"].ToString() != "" ? decimal.Parse(dr["fixedCharge"].ToString()) : 0;

                        string rate  = dr["rate"].ToString();
                        string units = dr["units"].ToString();
                        string cou   = dr["costOfUnits"].ToString();

                        string vat = dr["vat"].ToString();
                        colectionType = dr["collectionType"].ToString();
                        invoiceNo     = dr["receiptNo"].ToString();
                        bu            = dr["businessUnit"].ToString();
                        agent         = dr["dealerName"].ToString();

                        string returnString = "1|time_receiptNo_reprint_cdu_sgc_tariff_meterNo_custName_acctNo_address_transactionAmt_amtTendered_costOfUnit_fixedCharge_vat_unit_purchaseAs_tokens_bottomMsg_collectionType_invoiceNo_bu_agent|"
                                              + time + "|" + receiptNo + "|" + dr["reprint"].ToString() + "|Operator Pawakad|" + sgc + "|" + tariff + "|" + meterNo + "|" + customer + "|" + acctNo + "|" + address + "|" + txnAmt + "|" + txnAmt + "|" + cou + "|" + fixedCharge + "|" + vat + "|" + dr["units"].ToString() + "|" + purchasedAs + "|" + token + "|" + bottonMsg + "|" + colectionType + "|" + invoiceNo + "|" + bu + "|" + agent + "|";// +creditBalance;

                        //log the mobile request
                        ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetReceipt", returnString);

                        return(returnString);
                    }
                    else if (channelRefNo.StartsWith("WB") || channelRefNo.StartsWith("MB") || channelRefNo.StartsWith("PB") || channelRefNo.StartsWith("NB"))
                    {
                        string txnAmt = "", balance = "";
                        acctNo  = dr["accountNumber"].ToString();
                        address = dr["address"].ToString();

                        txnAmt = string.Format("{0:#,###}", dr["amount"].ToString());

                        customer = dr["customerName"].ToString();
                        time     = dr["transactionDate"].ToString();
                        balance  = "N" + string.Format("{0:#,###}", dr["balance"].ToString());

                        colectionType = dr["collectionType"].ToString();
                        invoiceNo     = dr["receiptNo"].ToString();
                        bu            = dr["businessUnit"].ToString();
                        agent         = dr["dealerName"].ToString();

                        string returnString = "1|time_receiptNo_reprint_cdu_sgc_tariff_meterNo_custName_acctNo_address_transactionAmt_amtTendered_costOfUnit_fixedCharge_vat_unit_purchaseAs_tokens_balance_bottomMsg_collectionType_invoiceNo_bu_agent|"
                                              + time + "|" + receiptNo + "|" + dr["reprint"].ToString() + "|Operator Pawakad|" + sgc + "|" + tariff + "|" + meterNo + "|" + customer + "|" + acctNo + "|" + address + "|" + txnAmt.ToString().Substring(0, txnAmt.ToString().IndexOf('.') + 3) + "|" + txnAmt.ToString().Substring(0, txnAmt.ToString().IndexOf('.') + 3) + "|||||||" + balance + "|" + bottonMsg + "|" + colectionType + "|" + invoiceNo + "|" + bu + "|" + agent + "|";

                        //log the mobile request
                        ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetReceipt", returnString);


                        return(returnString);
                    }
                }

                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetReceipt", "0|No receipt");

                return("0|No receipt");
            }
            else
            {
                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetReceipt", "0|Invalid_Request");

                return("0|Invalid_Request");
            }
        }
Esempio n. 9
0
        public string GetPaymentLog(string acctNo, string dealerUserName, string dealerPassword, string mtid)
        {
            if (RequestIsValid(dealerUserName, dealerPassword))
            {
                //first things first, get any UGR for the dealer on that account number

                ClsPayment.RegenAnyUGR(acctNo, dealerUserName, DateTime.Now);

                //

                ClsDealer dl = new ClsDealer();

                string reqParams = "acctNo:" + acctNo + "|" +
                                   "dealerUserName:"******"|REQ", "GetPaymentLog", reqParams);

                mtid += "|RESP";

                string jsonString = "";

                if (acctNo.Length > 0)
                {
                    string results = "";

                    ClsPayment    cp = new ClsPayment();
                    SqlDataReader dr = cp.GetPaymentLog(acctNo, "", DateTime.Now.AddDays(-365).ToString(), DateTime.Now.ToString());

                    if (dr.HasRows)
                    {
                        //dr = cp.GetPaymentLog(acctNo, "", DateTime.Now.AddDays(-365).ToString(), DateTime.Now.ToString());

                        while (dr.Read())
                        {
                            results += ("|" + dr["amount"].ToString() + "^" + dr["transactionDate"].ToString() + "^" + dr["channelRefNo"].ToString());
                        }

                        //log the mobile request
                        ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetPaymentLog", "1" + results);
                        jsonString = "1" + results;
                    }
                    else
                    {
                        //log the mobile request
                        ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetPaymentLog", "0|The account number has never been used on our platform");
                        jsonString = "0|The account number has never been used on our platform";
                    }
                }


                return(jsonString);
            }
            else
            {
                ClsDealer dl = new ClsDealer();
                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "GetPaymentLog", "0|Invalid_Request");

                return("0|Invalid_Request");
            }
        }
Esempio n. 10
0
        public string Login(string dealerUserName, string dealerPassword, string mtid)
        {
            string userName = dealerUserName;
            // MAKE THE PASSWORD MD5 ENCRYPTION
            string    passWord = MD5Crypt.MDee5(dealerPassword);
            ClsDealer dl       = new ClsDealer();

            string reqParams = "dealerUserName:"******"|REQ", "Login", reqParams);

            mtid += "|RESP";

            //FIRST CHECK THAT USER IS NOT LOGGED IN ELSWHERE
            //if logged in elsewhere then inform user and  terminate login proces
            int isDuplicateLogin = 0;// dl.CheckMultiLogin(userName);

            if (isDuplicateLogin == 1)
            {
                string errorMsg = "0|You Have Loged in elsewhere and cannot login at this terminal. Please log out from the other terminal.";
                //log the mobile request
                ClsPayment.LogMobileRequest2(dl.GetDealerCode(userName).ToString(), DateTime.Now, mtid, "Login", errorMsg);

                return(errorMsg);
            }
            else
            {
                int isLoginValid = dl.IsDealerLoginValid(userName, passWord);

                if (isLoginValid == 1)
                {
                    SqlDataReader dr = dl.GetDealerDetails(userName);
                    string        fullName = "", availableCredit = "", dealerEmail = "";

                    while (dr.Read())
                    {
                        fullName        = dr["fullName"].ToString();
                        availableCredit = dr["availableCredit"].ToString();
                        dealerEmail     = dr["dealerEmail"].ToString();
                    }

                    string verNum = dl.GetLatestMobileVersion().ToString();

                    dl.AddMultiLogin(userName);
                    //dl.AddLoginLocation(userName, longitude, latitude, address, mtid);

                    string format = "username_fullname_availableCredit_versionNum_apkLink_brandMsg|"; //vernum = @vernum + | + apkLink

                    string returnString = "1|" + format + userName + "|" + fullName + "|" + availableCredit + "|" + verNum + "|" + dl.GetPushMsg() + "|";

                    //log the mobile request
                    ClsPayment.LogMobileRequest2(dl.GetDealerCode(userName).ToString(), DateTime.Now, mtid, "Login", returnString);

                    return(returnString);
                }
                else
                {
                    string errorMsg = "0|Your Login Is not VALID  ";
                    //log the mobile request
                    ClsPayment.LogMobileRequest2(dl.GetDealerCode(userName).ToString(), DateTime.Now, mtid, "Login", errorMsg);

                    return(errorMsg);
                }
            }
        }