Esempio n. 1
0
        private void GetLatestForBet(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            var list = ErnieDataProxy.GetLatest();

            if (list != null && list.Count > 0)
            {
                var model = list[0];
                if ((DateTime.Now >= model.StartTime) && (DateTime.Now < model.EndTime))
                {
                    context.Response.Write("{\"success\": true,\"message\": \"\",\"startTime\": \"" + model.StartTime.ToString("yyyy-MM-dd HH:mm") + "\",\"endTime\": \"" + model.EndTime.ToString("yyyy-MM-dd HH:mm") + "\",\"totalMls\": \"0\",\"status\": \"1\"}");
                    return;
                }
                if (DateTime.Now < model.StartTime)
                {
                    context.Response.Write("{\"success\": true,\"message\": \"\",\"startTime\": \"" + model.StartTime.ToString("yyyy-MM-dd HH:mm") + "\",\"endTime\": \"" + model.EndTime.ToString("yyyy-MM-dd HH:mm") + "\",\"totalMls\": \"" + (model.StartTime - DateTime.Now).TotalMilliseconds + "\",\"status\": \"0\"}");
                    return;
                }
                if (DateTime.Now > model.EndTime)
                {
                    context.Response.Write("{\"success\": true,\"message\": \"\",\"startTime\": \"" + model.StartTime.ToString("yyyy-MM-dd HH:mm") + "\",\"endTime\": \"" + model.EndTime.ToString("yyyy-MM-dd HH:mm") + "\",\"totalMls\": \"0\",\"status\": \"100\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"\",\"startTime\": \"" + model.StartTime.ToString("yyyy-MM-dd HH:mm") + "\",\"endTime\": \"" + model.EndTime.ToString("yyyy-MM-dd HH:mm") + "\",\"totalMls\": \"0\",\"status\": \"100\"}");
                return;
            }
            else
            {
                context.Response.Write("{\"success\": true,\"message\": \"\",\"startTime\": \"\",\"endTime\": \"\",\"totalMls\": \"-1\",\"status\": \"100\"}");
            }
        }
Esempio n. 2
0
        private void Bind()
        {
            var list = ErnieDataProxy.GetLatest();

            if (list == null || list.Count == 0)
            {
                ltrMyData.Text = "<div id=\"myDataAppend\" style=\"display:none;\" startTime=\"\" endTime=\"\" totalMls=\"0\" status=\"100\"></div>";
                return;
            }

            var model = list[0];

            if (!((DateTime.Now >= model.StartTime) && (DateTime.Now < model.EndTime)))
            {
                if (DateTime.Now < model.StartTime)
                {
                    hTotalMls.Value = "" + (model.StartTime - DateTime.Now).TotalMilliseconds + "";
                    ltrMyData.Text  = "<div id=\"myDataAppend\" style=\"display:none;\" startTime=\"" + model.StartTime.ToString("yyyy-MM-dd HH:mm") + "\" endTime=\"" + model.EndTime.ToString("yyyy-MM-dd HH:mm") + "\" totalMls=\"" + (model.StartTime - DateTime.Now).TotalMilliseconds + "\" status=\"0\"></div>";
                    return;
                }
                if (DateTime.Now > model.EndTime)
                {
                    ltrMyData.Text = "<div id=\"myDataAppend\" style=\"display:none;\" startTime=\"" + model.StartTime.ToString("yyyy-MM-dd HH:mm") + "\" endTime=\"" + model.EndTime.ToString("yyyy-MM-dd HH:mm") + "\" totalMls=\"0\" status=\"100\"></div>";
                    return;
                }
            }

            UserErnie ueBll         = new UserErnie();
            var       totalBetCount = ueBll.GetTotalBetCount(WebCommon.GetUserId(), model.ErnieId);
            int       remainTimes   = model.UserBetMaxCount - totalBetCount;

            if (remainTimes < 0)
            {
                remainTimes = 0;
            }

            ltrMyData.Text = "<div id=\"myDataAppend\" style=\"display:none;\" startTime=\"" + model.StartTime.ToString("yyyy-MM-dd HH:mm") + "\" endTime=\"" + model.EndTime.ToString("yyyy-MM-dd HH:mm") + "\" totalMls=\"0\" status=\"1\" remainTimes=\"" + remainTimes + "\"></div>";
        }
Esempio n. 3
0
        private void GetBetResult(HttpContext context)
        {
            var list = ErnieDataProxy.GetLatest();

            if (list == null || list.Count == 0)
            {
                int index = 0;
                while (true)
                {
                    Thread.Sleep(5000);
                    list = ErnieDataProxy.GetLatest();
                    if (list.Count > 0)
                    {
                        break;
                    }
                    index++;
                    if (index > 5)
                    {
                        break;
                    }
                }
            }
            if (list != null && list.Count > 0)
            {
                var ernieModel = list[0];
                if (!((DateTime.Now >= ernieModel.StartTime) && (DateTime.Now <= ernieModel.EndTime)))
                {
                    context.Response.Write("{\"success\": true,\"message\": \"\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\"}");
                    return;
                }

                var userId = WebCommon.GetUserId();
                if (userId.Equals(Guid.Empty))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"请先登录\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\"}");
                    return;
                }

                UserErnie ueBll = new UserErnie();
                Dictionary <string, string> dic = new Dictionary <string, string>();

                var listT = list.ToList();
                var g     = listT.GroupBy(m => m.NumType);
                foreach (var gk in g)
                {
                    var keyList = listT.FindAll(m => m.NumType == gk.Key);
                    var ga      = keyList.GroupBy(m => m.AppearRatio);

                    GLBfb[] arrGLBfb = new GLBfb[ga.Count()];
                    int     i        = 0;
                    foreach (var gak in ga)
                    {
                        arrGLBfb[i]     = new GLBfb();
                        arrGLBfb[i].Bfb = (int)(gak.Key * 100);
                        var currList = keyList.FindAll(m => m.AppearRatio == gak.Key);
                        foreach (var model in currList)
                        {
                            var numArr = model.Num.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (var num in numArr)
                            {
                                arrGLBfb[i].SjsList.Add(num);
                            }
                        }
                        i++;
                    }

                    RandomForWeight rdfw = new RandomForWeight(arrGLBfb);

                    dic.Add(gk.Key, rdfw.GetGLNumber());
                }

                string gold   = "0";
                string silver = "0";
                string times  = "0";
                foreach (KeyValuePair <string, string> kvp in dic)
                {
                    switch (kvp.Key)
                    {
                    case "倍数":
                        times = kvp.Value;
                        break;

                    case "金币":
                        gold = kvp.Value;
                        break;

                    case "元宝":
                        silver = kvp.Value;
                        break;

                    default:
                        break;
                    }
                }

                int remainTimes = 0;
                using (TransactionScope scope = new TransactionScope())
                {
                    var totalBetCount = ueBll.GetTotalBetCount(userId, ernieModel.ErnieId);
                    remainTimes = ernieModel.UserBetMaxCount - totalBetCount;
                    if (remainTimes < 0)
                    {
                        totalBetCount = 0;
                    }
                    if (remainTimes < 1)
                    {
                        context.Response.Write("{\"success\": false,\"message\": \"摇奖机会还剩 " + 0 + " 次\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\",\"remainTimes\":\"0\"}");
                        return;
                    }

                    UserErnieInfo ueModel = new UserErnieInfo();
                    ueModel.UserId          = userId;
                    ueModel.ErnieId         = ernieModel.ErnieId;
                    ueModel.LastUpdatedDate = DateTime.Now;
                    ueModel.WinGold         = int.Parse(gold) * int.Parse(times);
                    ueModel.WinSilver       = int.Parse(silver) * int.Parse(times);

                    ueBll.Insert(ueModel);

                    UserBaseQueueClient ubqClient = new UserBaseQueueClient();
                    TygaSoft.Services.HnztcQueueService.UserLevelInfo userLevelInfo = new TygaSoft.Services.HnztcQueueService.UserLevelInfo();
                    userLevelInfo.UserId        = userId;
                    userLevelInfo.IsReduce      = false;
                    userLevelInfo.TotalGold     = ueModel.WinGold;
                    userLevelInfo.TotalSilver   = ueModel.WinSilver;
                    userLevelInfo.TotalIntegral = 0;
                    ubqClient.SaveUserLevel(userLevelInfo);

                    scope.Complete();

                    remainTimes = remainTimes - 1;
                }

                context.Response.Write("{\"success\": true,\"message\": \"摇奖机会还剩 " + remainTimes + " 次\",\"gold\": \"" + gold + "\",\"silver\": \"" + silver + "\",\"times\": \"" + times + "\",\"remainTimes\":\"" + remainTimes + "\"}");
            }
            else
            {
                context.Response.Write("{\"success\": true,\"message\": \"\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\"}");
            }
        }