Exemple #1
0
        public EnquiryOutput load(string Target, Int32 Amount, int Counter)
        {
            EnquiryOutput outputObj = new EnquiryOutput();
            Security      secObj    = new Security();

            outputObj.status  = "1";
            outputObj.message = "not ok";

            string sessionid = string.Empty;

            if (SrvProviderSessionManager.GetSessionInstance().IsExistedSession("VinaphoneSession"))
            {
                sessionid = SrvProviderSessionManager.GetSessionInstance().GetSession("VinaphoneSession");
            }
            else
            {
                sessionid = login();
                SrvProviderSessionManager.GetSessionInstance().DelSession("VinaphoneSession");
                SrvProviderSessionManager.GetSessionInstance().AddSession(sessionid, "VinaphoneSession");
            }

            try
            {
                TransactionInput tranObj = new TransactionInput();
                tranObj.username = AppConfiguration.VinaPhoneUserName;
                //tranObj.password = secObj.TripleDES_Encrypt(secObj.Epay_Decrypt(Password, PasswordKey), sessionid);
                tranObj.password     = secObj.TripleDES_Encrypt(AppConfiguration.VinaPhoneAgentMPIN, sessionid); //
                tranObj.agentMsIsdn  = AppConfiguration.VinaPhoneAgentMsIsdl;
                tranObj.targetMsIsdn = Target;
                tranObj.amount       = Amount;
                tranObj.counter      = Counter;

                outputObj = eloadObj.load(tranObj);
                //Thread.Sleep(Timeout);

                return(outputObj);
            }
            catch
            {
                logout(sessionid);
                return(outputObj);
            }

            return(outputObj);
        }
Exemple #2
0
        public mobiEz.buyResponse load(string Recipient, decimal Amount)
        {
            Security secObj = new Security();

            mobiEz.buyResponse buyResponseObj = new buyResponse();
            string             strPassword    = SrvProviderSessionManager.GetSessionInstance().GetSession("Mobifone");

            //Gen password
            strPassword = AppConfiguration.MobifoneUserName.ToLower() + AppConfiguration.MobifonePassword;
            strPassword = secObj.GetSHA1_HEX(strPassword).ToLower();
            strPassword = sessionid + strPassword;
            strPassword = secObj.GetSHA1_HEX(strPassword).ToUpper();

            //Console.Out.Write("pin=" + pin(sessionid, AppConfiguration.MobifoneUserName, strPassword, "0123456").ToString());

            try
            {
                int nCounter = 2;
                while (nCounter > 0)
                {
                    //login
                    if (login(sessionid, AppConfiguration.MobifoneUserName, strPassword))
                    {
                        try
                        {
                            mobiEz.buy            buyObj            = new buy();
                            mobiEz.buyRequestType buyRequestTypeObj = new buyRequestType();

                            buyRequestTypeObj.sessionid = sessionid;
                            buyRequestTypeObj.target    = "airtime";
                            buyRequestTypeObj.type      = 2;
                            buyRequestTypeObj.recipient = Recipient;
                            buyRequestTypeObj.amount    = Amount;
                            buyObj.buyRequest           = buyRequestTypeObj;

                            //invoke buy function
                            buyResponseObj = UMSObj.buy(buyObj);
                            if (buyResponseObj.buyReturn.result == 0)
                            {
                                nCounter = 0;
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                    }
                    else
                    {
                        nCounter--;

                        try
                        {
                            sessionid = createsession();
                            if (SrvProviderSessionManager.GetSessionInstance().IsContainSesssion("MobifoneSession"))
                            {
                                SrvProviderSessionManager.GetSessionInstance().DelSession("MobifoneSession");
                            }
                            SrvProviderSessionManager.GetSessionInstance().AddSession(sessionid, "MobifoneSession");
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(buyResponseObj);
        }