Пример #1
0
        private void SetInfo(HttpContext context)
        {
            string vouchers = context.Request["vouchers"];

            if (string.IsNullOrEmpty(vouchers))
            {
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 5, "Hãy nhập gói cước"));
                return;
            }

            var oUser = (CustomerGateInfo)context.Session[Config.GetSessionUser];

            if (oUser == null)
            {
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 6, "Hết phiên làm việc, hãy thực hiện lại"));
                return;
            }

            if (!Utility.isOnlyNumber(vouchers))
            {
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 7, "Gói cước không phù hợp"));
                return;
            }

            List <voucher> list     = oUser.vouchers;
            voucher        oVoucher = null;

            foreach (voucher item in list)
            {
                if (vouchers == item.vouchervalue)
                {
                    oVoucher = item;
                    break;
                }
            }

            if (oVoucher == null)
            {
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 8, "Gói cước không phù hợp"));
                return;
            }

            SmartlinkRedirectUrlInfo oRedirectUrlInfo = new SmartlinkRedirectUrlInfo()
            {
                CreateDate = DateTime.Now
            };

            try
            {
                string sUrl = SmartLinkHelper.getRedirectUrl(vouchers, ref oRedirectUrlInfo);

                //save cached
                CacheInfo oCacheInfo = new CacheInfo()
                {
                    Voucher   = oVoucher,
                    sTrans_Id = oRedirectUrlInfo.vpc_MerchTxnRef,
                    User      = oUser
                };

                CacheProvider.AddWithTimeOut(string.Format(KeyCache.KeyUserSmartlink, oRedirectUrlInfo.vpc_MerchTxnRef), oCacheInfo, 720);
                //
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 0, sUrl));
            }
            catch (Exception ex)
            {
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", ex.GetHashCode().ToString(), ex.Message));
            }
            finally
            {
                SmartlinkRedirectUrlData.instance.Add(oRedirectUrlInfo);
            }
        }
Пример #2
0
 public static void GetListNews(int oType, int iCurent, string oData)
 {
     CacheProvider.AddWithTimeOut(string.Format("ListNew-{0}-{1}", oType, iCurent), oData, 600);
 }
Пример #3
0
 public static void GetListNewsColumn(int oType, string oData)
 {
     CacheProvider.AddWithTimeOut(string.Format("ListNewColumn1-{0}", oType), oData, 600);
 }
Пример #4
0
 public static void GetListSupport(string oData)
 {
     CacheProvider.AddWithTimeOut("GetListSupport", oData, 600);
 }
Пример #5
0
 public static void GetNews(int id, string oData)
 {
     CacheProvider.AddWithTimeOut(string.Format("News-{0}", id), oData, 600);
 }
Пример #6
0
 public static void GetListHoTro(string oData)
 {
     CacheProvider.AddWithTimeOut("GetListhoTro", oData, 600);
 }
Пример #7
0
 public static void GetListProductType(string oData)
 {
     CacheProvider.AddWithTimeOut(string.Format("ProductType"), oData, 600);
 }
Пример #8
0
 public static void GetListProduct(int oType, int iPage, string oData)
 {
     CacheProvider.AddWithTimeOut(string.Format("Product-{0}-{1}", oType, iPage), oData, 600);
 }
Пример #9
0
 public static void GetListTronGoi(int oType, string oData)
 {
     CacheProvider.AddWithTimeOut(string.Format("ListTronGoi-{0}", oType), oData, 600);
 }
Пример #10
0
        private void SetInfo(HttpContext context)
        {
            string vouchers = context.Request["vouchers"];

            if (string.IsNullOrEmpty(vouchers))
            {
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 5, "Hãy nhập gói cước"));
                return;
            }

            var oUser = (CustomerGateInfo)context.Session[Config.GetSessionUser];

            if (oUser == null)
            {
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 6, "Hết phiên làm việc, hãy thực hiện lại"));
                return;
            }

            if (!Utility.isOnlyNumber(vouchers))
            {
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 7, "Gói cước không phù hợp"));
                return;
            }

            List <voucher> list     = oUser.vouchers;
            voucher        oVoucher = null;

            foreach (voucher item in list)
            {
                if (vouchers == item.vouchervalue)
                {
                    oVoucher = item;
                    break;
                }
            }

            if (oVoucher == null)
            {
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 8, "Gói cước không phù hợp"));
                return;
            }

            string Good_Code = string.Format("{0:yyMMddHHmmssfff}", DateTime.Now) + oVoucher.duration;

            Good_Code = Security.GetMD5Hash(Good_Code);
            Good_Code = "THAV-" + Good_Code.Substring(0, 15).ToUpper();

            string sSuccess = context.Request.Url.Scheme + "://" + context.Request.Url.Authority + "/Banknet/success.aspx?code=" + Good_Code;
            string sFail    = context.Request.Url.Scheme + "://" + context.Request.Url.Authority + "/Banknet/fail.aspx?code=" + Good_Code;

            SendGoodInfo sendInfo = new SendGoodInfo()
            {
                UserId          = oUser.subnum,
                vouchers        = oVoucher.vouchervalue + " - " + oVoucher.vouchername + " - " + oVoucher.duration + " " + oVoucher.durationuomaltcode,
                Good_code       = Good_Code,
                Xml_description = Config.Desc,
                Url_success     = sSuccess,
                Url_fail        = sFail,
                CreateDate      = DateTime.Now
            };

            try
            {
                string s = BanknetHelper.Send_GoodInfo(Good_Code, Config.Desc, vouchers, "0", "0", sSuccess, sFail, ref sendInfo);

                if (BanknetHelper.getCodeResult(s) != "010")
                {
                    context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 9, "Kết nối với cổng thanh toán Banknet gặp sự cố"));
                    return;
                }

                string sUrl      = "";
                string sTrans_Id = "";
                int    iResult   = BanknetHelper.GetUrlRedirection(s, out sUrl);
                if (iResult != 0)
                {
                    context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 10, "Kết nối với cổng thanh toán Banknet gặp sự cố"));
                    return;
                }
                sTrans_Id         = BanknetHelper.getTransIdFromUrl(sUrl);
                sendInfo.Trans_Id = sTrans_Id;
                //save cached
                CacheInfo oCacheInfo = new CacheInfo()
                {
                    Voucher           = oVoucher,
                    sTrans_Id         = sTrans_Id,
                    Good_Code         = Good_Code,
                    User              = oUser,
                    Merchant_trans_id = sendInfo.Merchant_trans_id
                };

                CacheProvider.AddWithTimeOut(string.Format(KeyCache.KeyUserBanknet, Good_Code), oCacheInfo, 720);
                //
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 0, sUrl));
                return;
            }
            catch (Exception ex)
            {
                sendInfo.ResultId  = ex.GetHashCode().ToString();
                sendInfo.OutString = ex.Message;
                context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", sendInfo.ResultId, sendInfo.OutString));
            }
            finally
            {
                SendGoodData.instance.Add(sendInfo);
            }
        }