Exemplo n.º 1
0
        public ActionResult ChariDraw()
        {
            ViewData[SessionKey.VwCurrentNav] = "game";
            Session.Remove(SessionKey.DonationId);
            Session.Remove(SessionKey.DonationAmt);
            Session.Remove("ChariGame");
            Session.Add("ChariGame", DataEncryption.HashString("chari.game"));
            ChariWinnerViewModel cwvm = new ChariWinnerViewModel();

            if (Request.Headers["Referer"] != null && Request.Headers["Referer"].Contains(ConfigurationManager.AppSettings["UPOPHost"]))
            {
                cwvm.IsFromChinaUnion = true;
                base.RenderTip("完成抽奖前,请先不要关闭本页面,或点击其他链接", 3);
                _log.Info("from china union");
                string oAmt   = Request.Form.Get("orderAmount");
                string oQid   = Request.Form.Get("qid");
                string svar   = "orderAmount=" + oAmt.ToString() + "&orderCurrency=" + Request.Form.Get("orderCurrency") + "&qid=" + oQid;
                string sig_in = Request.Form.Get("signature");
                string sig    = DataEncryption.HashUPOPChariOrder(svar).Replace("-", "").ToLower();
                if (sig_in.Equals(sig))
                {
                    _log.Info("china union sign ok");
                    //signatures equal, writes variables to session
                    Session[SessionKey.ID]          = oQid;
                    Session[SessionKey.DonationAmt] = decimal.Parse(oAmt) / 100;
                    Session[SessionKey.UPOPChari]   = "Verified";
                }
            }
            #region Winner List

            cwvm.WinList = _uow.GetWinnerPrizeList();

            // pad the winner list to at least 5 winners
            for (int i = cwvm.WinList.Count; i < 10; i++)
            {
                switch (i % 5)
                {
                case 0: ViewBag.WinList += "<ul><li>wahaha</il><li>4天前</li><li>HTC 手机</li></ul>";
                    break;

                case 1: ViewBag.WinList += "<ul><li>iamgod</il><li>5天前</li><li>Sony TV</li></ul>";
                    break;

                case 2: ViewBag.WinList += "<ul><li>willywanker</il><li>7天前</li><li>笔记本</li></ul>";
                    break;

                case 3: ViewBag.WinList += "<ul><li>seanc</il><li>10天前</li><li>自行车</li></ul>";
                    break;

                case 4: ViewBag.WinList += "<ul><li>jaschen</il><li>13天前</li><li>iPad</li></ul>";
                    break;
                }
            }
            #endregion

            return(View(cwvm));
        }
Exemplo n.º 2
0
        public ActionResult ChariDraw()
        {
            ViewData[SessionKey.VwCurrentNav] = "game";
            Session.Remove(SessionKey.DonationId);
            Session.Remove(SessionKey.DonationAmt);
            Session.Remove("ChariGame");
            Session.Add("ChariGame", DataEncryption.HashString("chari.game"));
            ChariWinnerViewModel cwvm = new ChariWinnerViewModel();
            if (Request.Headers["Referer"] != null && Request.Headers["Referer"].Contains(ConfigurationManager.AppSettings["UPOPHost"]))
            {
                cwvm.IsFromChinaUnion = true;
                base.RenderTip("完成抽奖前,请先不要关闭本页面,或点击其他链接",3);
                _log.Info("from china union");
                string oAmt = Request.Form.Get("orderAmount");
                string oQid = Request.Form.Get("qid");
                string svar = "orderAmount=" + oAmt.ToString() + "&orderCurrency=" + Request.Form.Get("orderCurrency") + "&qid=" + oQid;
                string sig_in = Request.Form.Get("signature");
                string sig = DataEncryption.HashUPOPChariOrder(svar).Replace("-", "").ToLower();
                if (sig_in.Equals(sig))
                {
                    _log.Info("china union sign ok");
                    //signatures equal, writes variables to session
                    Session[SessionKey.ID] = oQid;
                    Session[SessionKey.DonationAmt] = decimal.Parse(oAmt) / 100;
                    Session[SessionKey.UPOPChari] = "Verified";                    
                }
            }
            #region Winner List
            
            cwvm.WinList = _uow.GetWinnerPrizeList();

            // pad the winner list to at least 5 winners
            for (int i = cwvm.WinList.Count; i < 10; i++)
            {
                switch (i % 5)
                {
                    case 0: ViewBag.WinList += "<ul><li>wahaha</il><li>4天前</li><li>HTC 手机</li></ul>";
                        break;
                    case 1: ViewBag.WinList += "<ul><li>iamgod</il><li>5天前</li><li>Sony TV</li></ul>";
                        break;
                    case 2: ViewBag.WinList += "<ul><li>willywanker</il><li>7天前</li><li>笔记本</li></ul>";
                        break;
                    case 3: ViewBag.WinList += "<ul><li>seanc</il><li>10天前</li><li>自行车</li></ul>";
                        break;
                    case 4: ViewBag.WinList += "<ul><li>jaschen</il><li>13天前</li><li>iPad</li></ul>";
                        break;
                }
            }
            #endregion

            return View(cwvm);
        }