Exemple #1
0
    // Use this for initialization
    void Start()
    {
        item.gameObject.SetActive(false);
        metaData = LotteryData.GetData();
        foreach (int key in metaData.Keys)
        {
            keys.Add(key);
        }
        for (int i = 0; i < keys.Count; i++)
        {
            LotteryData ldata = LotteryData.GetData(keys[i]);
            lotDatas.Add(ldata);
        }
        for (int j = 0; j < lotDatas.Count; j++)
        {
            //ItemData ida = ItemData.GetData(lotDatas[j].Rewarditem_);
            //itemdata.Add(ida);
        }
        UIManager.SetButtonEventHandler(CloseBtn.gameObject, EnumButtonEvent.OnClick, OnClickClose, 0, 0);
        UIManager.SetButtonEventHandler(ExchangeBtn.gameObject, EnumButtonEvent.OnClick, OnClickExchange, 0, 0);
        AddItems(lotDatas);

        for (int k = 0; k < BagSystem.instance.BagItems.Length; k++)
        {
            if (BagSystem.instance.BagItems[k] == null)
            {
                continue;
            }
            ItemData idata = ItemData.GetData((int)BagSystem.instance.BagItems[k].itemId_);
            itdata.Add(idata);
        }
    }
        protected override List <LotteryData> CrawNewDatas()
        {
            WebClient client = new WebClient();

            client.Encoding = Encoding.UTF8;
            string jsonString = client.DownloadString(_dataSite.Url);

            var jObject  = JObject.Parse(jsonString);
            var dataList = new List <LotteryData>();

            if (Convert.ToBoolean(jObject["success"]))
            {
                var dataItems = (JArray)jObject["rows"];
                foreach (var row in dataItems)
                {
                    var itemId = Convert.ToInt32(row["termNum"]);
                    if (itemId <= _latestDataId)
                    {
                        continue;
                    }
                    var lotteryData = new LotteryData();
                    lotteryData.Period          = itemId;
                    lotteryData.Data            = GetCpDataByCpJObject("n", 10, (JObject)row);
                    lotteryData.LotteryType     = _lotteryName;
                    lotteryData.LotteryDateTime = Convert.ToDateTime(row["lotteryTime"]);
                    dataList.Add(lotteryData);
                }
            }
            return(dataList);
        }
        protected override List <LotteryData> CrawNewDatas()
        {
            WebClient client = new WebClient();

            client.Encoding = Encoding.UTF8;
            string jsonString = client.DownloadString((string)_dataSite.Url);

            var dataItems = JArray.Parse(jsonString);
            var dataList  = new List <LotteryData>();

            foreach (var jToken in dataItems)
            {
                var dataItem = (JObject)jToken;

                var itemId = Convert.ToInt32(dataItem["pissue"]);

                if (itemId <= _latestDataId)
                {
                    continue;
                }
                var item = new LotteryData();
                item.Period          = itemId;
                item.Data            = GetCpDataByCpJObject("pn", 10, dataItem);
                item.LotteryType     = _lotteryName;
                item.LotteryDateTime = Utils.UnixTimestampToDateTime(Convert.ToInt32(dataItem["pintime"].ToString()));
                dataList.Add(item);
            }
            return(dataList);
        }
Exemple #4
0
    void OnClickZGBtn(ButtonScript obj, object args, int param1, int param2)
    {
        if (!IsBagSystemContainsLottery())
        {
            PopText.Instance.Show(LanguageManager.instance.GetValue("meiyouguaguaka"));
            return;
        }
        EffectAPI.PlayUIEffect((EFFECT_ID)GlobalValue.EFFECT_Guaguaka, gameObject.transform);
        for (int k = 0; k < BagSystem.instance.BagItems.Length; k++)
        {
            if (BagSystem.instance.BagItems[k] == null)
            {
                continue;
            }
            ItemData idata = ItemData.GetData((int)BagSystem.instance.BagItems[k].itemId_);

            if (idata.subType_ == ItemSubType.IST_Lottery)
            {
                COM_Item citem = BagSystem.instance.GetItemByItemId((uint)idata.id_);
                NetConnection.Instance.useItem((uint)citem.slot_, 0, 1);
                isZGBtn = true;
            }
        }
        LotteryData ldata = LotteryData.GetData(ranking);

        BonusContent.text = ldata.Win_symbol;
        //tishiLabel.text = LanguageManager.instance.GetValue ("guagua").Replace("{n}",ldata.RewardName_);
    }
Exemple #5
0
        protected override List <LotteryData> CrawNewDatas()
        {
            WebClient client = new WebClient();

            client.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36");
            client.Encoding = Encoding.GetEncoding("UTF-8");
            var    dataUrl     = string.Format(_dataSite.Url, DateTime.Now.ToString("yyyy-MM-dd"));
            string documentStr = client.DownloadString(dataUrl);

            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(documentStr);
            ////*[@id="content"]/div[1]/div[1]/div[4]/div/div[2]/table/tbody/tr[5]
            var cpNodeListWrap = htmlDocument.DocumentNode.SelectNodes("//*[@id=\"drawing_tableDetail\"]//*/tr[*]").Skip(1);
            var dataList       = new List <LotteryData>();

            foreach (var cp in cpNodeListWrap)
            {
                var item = new LotteryData();
                item.Period = Convert.ToInt32(cp.SelectSingleNode("./td[1]").InnerText);
                if (item.Period <= _latestDataId)
                {
                    continue;
                }
                item.Data            = cp.SelectNodes("./td[2]/div/ul/li").Select(p => int.Parse(p.InnerText)).ToList().ToSplitString(',');
                item.LotteryType     = _lotteryName;
                item.LotteryDateTime = DateTime.Now;
                dataList.Add(item);
            }
            return(dataList);
        }
Exemple #6
0
 public PlayerExtension()
 {
     Lottery = new LotteryData();
     Counter = new CounterData {
         Number = 0
     };
 }
 public async Task Execute(IJobExecutionContext context)
 {
     try
     {
         HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Interface);
         request.Method      = "GET";
         request.ContentType = "text/html;charset=UTF-8";
         HttpWebResponse     response         = (HttpWebResponse)request.GetResponse();
         Stream              myResponseStream = response.GetResponseStream();
         StreamReader        myStreamReader   = new StreamReader(myResponseStream, Encoding.UTF8);
         string              retString        = myStreamReader.ReadToEnd();
         JObject             json             = (JObject)JsonConvert.DeserializeObject(retString);
         LotteryData         lottery          = new LotteryData();
         List <NumeralGroup> numberlgroup     = DbContext.NumeralGroups.OrderBy(n => n.Ranking).ToList();
         JObject             data             = (JObject)JsonConvert.DeserializeObject(json["data"].ToString());
         JObject             newest           = (JObject)JsonConvert.DeserializeObject(data["newest"].ToString());
         DateTime            datetime         = Convert.ToDateTime(newest["time"]);
         lottery.IssueId = Convert.ToInt32(newest["issue"]);
         var array = newest["array"].ToArray();
         lottery.Champion = Convert.ToInt32(array[0]);
         lottery.RunnerUp = Convert.ToInt32(array[1]);
         lottery.Third    = Convert.ToInt32(array[2]);
         lottery.Fourth   = Convert.ToInt32(array[3]);
         lottery.Fifth    = Convert.ToInt32(array[4]);
         lottery.Sixth    = Convert.ToInt32(array[5]);
         lottery.Seventh  = Convert.ToInt32(array[6]);
         lottery.Eighth   = Convert.ToInt32(array[7]);
         lottery.Ninth    = Convert.ToInt32(array[8]);
         lottery.Tenth    = Convert.ToInt32(array[9]);
         lottery.Date     = Convert.ToDateTime(datetime.ToString("d"));
         lottery.Time     = datetime.ToString("T");
         var lott = DbContext.LotteryDatas.Where(l => l.IssueId == lottery.IssueId).ToList().Count();
         if (lott < 1)
         {
             foreach (var item in numberlgroup)
             {
                 string[] intArray = item.Group.Split(',');
                 int      Champion = Array.IndexOf(intArray, lottery.Champion.ToString());
                 int      RunnerUp = Array.IndexOf(intArray, lottery.RunnerUp.ToString());
                 int      Third    = Array.IndexOf(intArray, lottery.Third.ToString());
                 int      Fourth   = Array.IndexOf(intArray, lottery.Fourth.ToString());
                 int      Fifth    = Array.IndexOf(intArray, lottery.Fifth.ToString());
                 int      Sixth    = Array.IndexOf(intArray, lottery.Sixth.ToString());
                 int      Seventh  = Array.IndexOf(intArray, lottery.Seventh.ToString());
                 int      Eighth   = Array.IndexOf(intArray, lottery.Eighth.ToString());
                 int      Ninth    = Array.IndexOf(intArray, lottery.Ninth.ToString());
                 int      Tenth    = Array.IndexOf(intArray, lottery.Tenth.ToString());
             }
             DbContext.LotteryDatas.Add(lottery);
             DbContext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemple #8
0
 public void InitData(LotteryPop p, LotteryData d, int i)
 {
     pop   = p;
     data  = d;
     index = i;
     SetInfoAfter();
     SetInfo();
     isBuyLayer = false;
     time.text  = Comm.DateDiff(data.refresh_time, DateTime.Now);
     timer      = new PassiveTimer(1);
 }
Exemple #9
0
    public void LotteryListCallback(List <LotteryData> list)
    {
        LotteryData d = list[0];

        d.id         = 1;
        d.name       = "抽取1次";
        d.money      = 100;
        d.type       = LotteryData.MoneyType.Friend;
        d.money_icon = GetIconByType(d.type);
        d.desc       = "友情抽奖";
        d.icon       = "宝箱";
        d.btnnor     = "购买一个1";
        d.btndis     = "购买一个2";
        d.num_name   = "抽取一次";
        d.num        = "宝箱数1";
        d.kechou     = "今日友情抽奖可抽次数\n";
        d.isScale    = false;
        LotteryData b = list[1];

        b.id         = 2;
        b.name       = "抽取1次";
        b.money      = 240;
        b.type       = LotteryData.MoneyType.Diamond;
        b.money_icon = GetIconByType(b.type);
        b.desc       = "5次后逼出金色拳击手";
        b.icon       = "宝箱";
        b.btnnor     = "购买一个1";
        b.btndis     = "购买一个2";
        b.kechou     = "今日免费次数";
        b.num_name   = "抽取一次";
        b.num        = "宝箱数1";
        b.isScale    = false;
        LotteryData c = new LotteryData();

        c.id         = 3;
        c.name       = "抽取10次";
        c.money      = 2400;
        c.type       = LotteryData.MoneyType.Diamond;
        c.money_icon = GetIconByType(c.type);
        c.desc       = "10次后逼出金色拳击手";
        c.icon       = "宝箱";
        c.btnnor     = "购买十个1";
        c.btndis     = "购买十个2";
        c.num_name   = "抽取十次";
        c.num        = "宝箱数10";
        c.isScale    = true;
        //c.money =(int)(c.money * 0.9f);
        list.Add(c);
        pop.SetList(list);
    }
        /// <summary>
        /// 下注
        /// </summary>
        /// <param name="periodNo">期号</param>
        /// <param name="rule">玩法枚举</param>
        /// <param name="number">下注号码</param>
        /// <param name="money">单个号码金额</param>
        public void Bet(long periodNo, Pk10Rule rule, string number, decimal money)
        {
            LotteryData lotteryData = GetLotteryData();

            PrintLog($"{Environment.NewLine}即将下注,账户余额:¥ [{lotteryData.Balance}], 玩法: [{rule.GetAttributeValue()}],号码: [{number}], 下注金额: {money}.");

            string url = $"bet/bet.do?_t={DateTime.UtcNow.Ticks}";

            // 构建表单参数
            var betParam = new BetParam(periodNo, rule, number, money);

            var postBodyBuilder = new StringBuilder();

            postBodyBuilder.Append($"gameId={betParam.GameId}&turnNum={betParam.TurnNum}&totalNums={betParam.TotalNums}");
            postBodyBuilder.Append($"&totalMoney={betParam.TotalMoney}&betSrc={betParam.BetSrc}");

            for (int idx = 0; idx < betParam.BetBeanList.Count; idx++)
            {
                var bean = betParam.BetBeanList[idx];
                postBodyBuilder.Append($"&betBean[{idx}].playId={bean.PlayId}&betBean[{idx}].money={bean.Money}");
            }

            // 提交投注
            try
            {
                BetResult result = _restHelper.Post <BetResult>(url, postBodyBuilder.ToString());

                if (!result.Success)
                {
                    if (result.Msg.Contains("该账号在异地登陆"))
                    {
                        LoginTimeout = true;
                        throw new ArgumentException("该账号在异地登陆, 请重试!");
                    }
                    else
                    {
                        throw new ArgumentException($"{result.Msg}, 状态码: {result.Code}.");
                    }
                }
                else
                {
                    PrintLog($"下注成功, 当前账户余额: {lotteryData.Balance}");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #11
0
    public LotteryData parseLotteryData(string str)
    {
        LotteryData data = new LotteryData();

        string[] strs = str.Split('#');
        data.selectNumEndTime = StringKit.toInt(strs[0]);
        data.awardNumEndTime  = StringKit.toInt(strs[1]);
        data.openTime         = parseTime(strs[2]);
        data.sid      = StringKit.toInt(strs[3]);
        data.limitLv  = StringKit.toInt(strs[4]);
        data.costGold = StringKit.toLong(strs[5]);
        data.costRmb  = StringKit.toInt(strs[6]);
        data.updateLotteryMoneyTime = StringKit.toInt(strs[7]);
        data.sendAwardEndTime       = StringKit.toInt(strs[8]);
        return(data);
    }
Exemple #12
0
    //抽奖
    public Hashtable QueryLotteryTable()
    {
        InitDB();
        SqliteDataReader sqReader = db.ReadFullTable("lottery");
        Hashtable        table    = new Hashtable();

        while (sqReader.Read())
        {
            LotteryData item = new LotteryData();
            item.id    = sqReader.GetInt32(sqReader.GetOrdinal("id"));
            item.type  = (LotteryData.MoneyType)sqReader.GetInt32(sqReader.GetOrdinal("type"));
            item.money = sqReader.GetInt32(sqReader.GetOrdinal("money"));
            item.cd    = sqReader.GetInt32(sqReader.GetOrdinal("cd"));
            table.Add(item.id, item);
        }
        return(table);
    }
        /// <summary>
        /// 获取账户余额等数据
        /// </summary>
        /// <returns></returns>
        public LotteryData GetLotteryData()
        {
            string url = $"game/getLotteryData.do?_t={DateTime.UtcNow.Ticks}&gameId=50";

            LotteryData result = null;

            try
            {
                result = _restHelper.Get <LotteryData>(url);
            }
            catch (Exception ex)
            {
                result = new LotteryData();
                Console.WriteLine($">>> 获取账号余额失败,详情: {ex.Message}");
            }
            return(result);
        }
 public bool Add(LotteryData entity)
 {
     using (var cn = LotteryDbConnection)
     {
         var sqlStr = "INSERT dbo.LotteryDatas(Id,Period,LotteryType,Data,InsertTime,LotteryDateTime)" +
                      "VALUES(@Id,@Period,@LotteryType,@Data,GETDATE(),@LotteryDateTime)";
         return(cn.Execute(sqlStr, new
         {
             entity.Id,
             entity.Period,
             entity.Data,
             entity.InsertTime,
             entity.LotteryDateTime,
             entity.LotteryType,
         }) > 0);
     }
 }
Exemple #15
0
//	void OnClickRewardExplain(ButtonScript obj, object args, int param1, int param2)
//	{
//		RewardInfoObj.SetActive (true);
//	}
    void OnClickScratchReward(ButtonScript obj, object args, int param1, int param2)
    {
        EffectAPI.PlayUIEffect((EFFECT_ID)GlobalValue.EFFECT_Guaguaka, gameObject.transform);


        ScratchRewardBtn.gameObject.SetActive(false);
        ZGBtn.gameObject.SetActive(true);
        CloseBtn.gameObject.SetActive(true);
        Masksp.gameObject.SetActive(false);
        LotteryData ldata = LotteryData.GetData(ranking);

        BonusContent.text = ldata.Win_symbol;
        isZGBtn           = false;
        //tishiLabel.text = LanguageManager.instance.GetValue ("guagua").Replace("{n}",ldata.RewardName_);
        string str = LanguageManager.instance.GetValue("guagua") + itemnamestr + LanguageManager.instance.GetValue("guaguaend");

        PopText.Instance.Show(str);
        itemnamestr = "";
    }
Exemple #16
0
        public bool AddLottery(LotteryData lottery)
        {
            var lotteryfirst = DbContext.LotteryDatas.Where(o => o.IssueId == lottery.IssueId).FirstOrDefault();

            try
            {
                if (lotteryfirst == null)
                {
                    DbContext.LotteryDatas.Add(lottery);
                    Omission();
                    GunsUpdate();
                    DbContext.SaveChanges();
                }
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemple #17
0
    void Start()
    {
        item.gameObject.SetActive(false);
        UIManager.SetButtonEventHandler(CloseBtn.gameObject, EnumButtonEvent.OnClick, OnClickClose, 0, 0);
        metaData = LotteryData.GetData();

        foreach (int key in metaData.Keys)
        {
            keys.Add(key);
        }


        for (int i = 0; i < keys.Count; i++)
        {
            LotteryData ldata = LotteryData.GetData(keys[i]);
            lotDatas.Add(ldata);
        }


        AddItems(lotDatas);
    }
        public LotteryData Insert(LotteryData newData)
        {
            var redisKey = AppUtils.GetLotteryRedisKey(newData.LotteryType, LsConstant.LotteryDataCacheKey);

            try
            {
                CacheHelper.AddCacheListItem(redisKey, newData);
                if (CacheHelper.GetCache <IList <LotteryData> >(redisKey).Count >= LsConstant.LOAD_HISTORY_LOTTERYDATA)
                {
                    //var mostOldLottery = RedisHelper.GetAll<LotteryData>(redisKey).Last();
                    //RedisHelper.RemoveList(redisKey, mostOldLottery);
                }
            }
            catch (Exception ex)
            {
                LogDbHelper.LogError(ex, GetType() + "UpdateLotteryDataCache");
                throw ex;
            }

            var lotteryDataId = _lotteryDapperService.Add(newData);

            return(CacheHelper.GetCache <IList <LotteryData> >(redisKey).First(p => p.Id == newData.Id));
        }
Exemple #19
0
    public static void ParseData(string content, string fileName)
    {
        metaData = new Dictionary <int, LotteryData> ();

        CSVParser parser = new CSVParser();

        if (!parser.Parse(content))
        {
            ClientLog.Instance.LogError("TalkData" + ConfigLoader.Instance.csvext + "解析错误");
            return;
        }

        int         recordCounter = parser.GetRecordCounter();
        LotteryData data          = null;

        for (int i = 0; i < recordCounter; ++i)
        {
            data            = new LotteryData();
            data.id_        = parser.GetInt(i, "ID");
            data.LotteryID_ = parser.GetInt(i, "LotteryID");
            data.RewardLv_  = parser.GetInt(i, "RewardLv");
            data.Win_symbol = parser.GetString(i, "Win_symbol");
//			data.CouponID_ = parser.GetInt (i, "CouponID");
//			data.Rewarditem_ = parser.GetInt (i, "Rewarditem");
//			data.Rewarditem_Num_ = parser.GetInt (i, "Rewarditem_Num");
            data.RewardName_ = parser.GetString(i, "RewardName");
            data.RewardRate_ = parser.GetInt(i, "RewardRate");
            if (metaData.ContainsKey(data.id_))
            {
                ClientLog.Instance.LogError("TalkData" + ConfigLoader.Instance.csvext + "ID重复");
                return;
            }
            metaData[data.id_] = data;
        }
        parser.Dispose();
        parser = null;
    }
 public override void parseConfig(string str)
 {
     string[] strs = str.Split('|');
     // str[0] 配置文件说明
     if (str.StartsWith("1^"))
     {
         missionSid = StringKit.toInt(strs[1]);
     }
     //if(str.StartsWith("2^"))rushNum=StringKit.toInt(strs[1]);
     if (str.StartsWith("3^"))
     {
         ParseMininngSearchConsume(strs[1]);
     }
     if (str.StartsWith("4^"))
     {
         parsePrice(strs[1]);
     }
     if (str.StartsWith("5^"))
     {
         parsePropForMagicStreng(strs[1]);
     }
     if (str.StartsWith("6^"))
     {
         prisePropForMagicPhase(strs[1]);
     }
     if (str.StartsWith("7^"))
     {
         priseScrptSid(strs[1]);
     }
     if (str.StartsWith("8^"))
     {
         priseTowerNum(strs[1]);
     }
     if (str.StartsWith("9^"))
     {
         priseTowerCost(strs[1]);
     }
     if (str.StartsWith("10^"))
     {
         priseTowerLotteyMissionSid(strs[1]);
         priseTowerLotterPrizes(strs[2]);
     }
     if (str.StartsWith("11^"))
     {
         priseCombatMagic(strs[1]);
         numTempForMagic = float.Parse(strs[2]);
     }
     if (str.StartsWith("12^"))
     {
         parseNvShenMoney(strs[1]);
     }
     if (str.StartsWith("13^"))
     {
         parseNeedMoney(strs[1]);
     }
     if (str.StartsWith("14^"))
     {
         pariseBoxDec(strs[1]);
     }
     if (str.StartsWith("15^"))
     {
         towerLimitLevel = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("16^"))
     {
         parseTowerPassDec(strs[1]);
     }
     if (str.StartsWith("17^"))
     {
         parseVipBoxNum(strs[1]);
     }
     if (str.StartsWith("18^"))
     {
         parseVipBuyBoxNum(strs[1]);
     }
     if (str.StartsWith("19^"))
     {
         parseGetBoxAwardSid(strs[1]);
     }
     if (str.StartsWith("20^"))
     {
         parseNvShenShop(strs[1]);
     }
     if (str.StartsWith("21^"))
     {
         isUseBattleBugFix = StringKit.toInt(strs[1]) == 1;
     }
     if (str.StartsWith("22^"))
     {
         magicLimitLevel = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("23^"))
     {
         limitLevel = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("24^"))
     {
         parseFujiao(strs[1]);
     }
     if (str.StartsWith("26^"))
     {
         parseGodsTimes(strs[1]);
     }
     if (str.StartsWith("27^"))
     {
         parseEvoCost(strs[1]);
     }
     if (str.StartsWith("28^"))
     {
         parseSignCost(strs[1]);
     }
     if (str.StartsWith("29^"))
     {
         parseOneOnOneBossInfo(strs[1]);
     }
     if (str.StartsWith("30^"))
     {
         parseBossAward(strs[1]);
     }
     if (str.StartsWith("31^"))
     {
         parseRefineProp(strs[1]);
     }
     if (str.StartsWith("32^"))
     {
         maxPvePoint = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("33^"))
     {
         lastBattleData = LastBattleManagement.Instance.parseLastBattleData(strs[1]);
     }
     if (str.StartsWith("34^"))
     {
         parseDoubleSid(strs[1]);
     }
     if (str.StartsWith("35^"))
     {
         parseShenGe(strs[1]);
     }
     if (str.StartsWith("36^"))
     {
         parseShenGeExtraInfo(strs[1]);
     }
     if (str.StartsWith("37^"))
     {
         parseShenGePowerInfo(strs[1]);
         shenGeGongMingString = strs[2];
     }
     if (str.StartsWith("38^"))
     {
         meritLimit = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("39^"))
     {
         maxTimesOfJingJi = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("40^"))
     {
         yaoQingButtonFlag = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("41^"))
     {
         nvShenTextureType = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("42^"))
     {
         getMoneySpeed = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("43^"))
     {
         taoFaAwardMaxCount = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("44^"))
     {
         lastBattle_hpDownTime = StringKit.toFloat(strs[1]);
     }
     if (str.StartsWith("45^"))
     {
         string[] strArr = strs[1].Split(',');
         lastBattle_xDistance = StringKit.toFloat(strArr[0]);
         lastBattle_yDistance = StringKit.toFloat(strArr[1]);
     }
     if (str.StartsWith("46^"))
     {
         lotteryData = LotteryManagement.Instance.parseLotteryData(strs[1]);
     }
     if (str.StartsWith("47^"))
     {
         parseBossBuyTimeByVip(strs[1]);
     }
     if (str.StartsWith("48"))
     {
         MoneyMaxNum = StringKit.toLong(strs[1]);
     }
     if (str.StartsWith("49"))
     {
         kuaFuSoulHuntID = StringKit.toInt(strs[1]);
     }
     if (str.StartsWith("50"))
     {
         benDiSoulHuntID = StringKit.toInt(strs[1]);
     }
 }
        public void LoadDuplaSenaLotteryData()
        {
            var expectedResult = new LotteryData
            {
                LotteryName        = "DuplaSena",
                AverageWinnersData = new List <AverageData>
                {
                    new AverageData
                    {
                        TypeOfAward       = "Average3NumbersRound1",
                        TotalPeopleWhoWon = 0,
                        AwardAverage      = 0m
                    },
                    new AverageData
                    {
                        TypeOfAward       = "Average4NumbersRound1",
                        TotalPeopleWhoWon = 0,
                        AwardAverage      = 0m
                    },
                    new AverageData
                    {
                        TypeOfAward       = "Average5NumbersRound1",
                        TotalPeopleWhoWon = 0,
                        AwardAverage      = 0m
                    },
                    new AverageData
                    {
                        TypeOfAward       = "Average6NumbersRound1",
                        TotalPeopleWhoWon = 0,
                        AwardAverage      = 0m
                    }
                },
                AwardData = new ArwardsData
                {
                    TotalAward     = 0m,
                    TotalLotteries = 2
                },
                DozenByQuantity = new List <DozenData>
                {
                    new DozenData
                    {
                        Dozen = 4,
                        SumOf = 1
                    },
                    new DozenData
                    {
                        Dozen = 7,
                        SumOf = 1
                    },
                    new DozenData
                    {
                        Dozen = 9,
                        SumOf = 1
                    },
                    new DozenData
                    {
                        Dozen = 15,
                        SumOf = 2
                    },
                    new DozenData
                    {
                        Dozen = 24,
                        SumOf = 1
                    },
                    new DozenData
                    {
                        Dozen = 32,
                        SumOf = 1
                    },
                    new DozenData
                    {
                        Dozen = 38,
                        SumOf = 1
                    },
                    new DozenData
                    {
                        Dozen = 41,
                        SumOf = 1
                    },
                    new DozenData
                    {
                        Dozen = 42,
                        SumOf = 1
                    },
                    new DozenData
                    {
                        Dozen = 48,
                        SumOf = 1
                    },
                    new DozenData
                    {
                        Dozen = 50,
                        SumOf = 1
                    }
                }
            };

            _mockServiceRepo.SetReturnsDefault <IEnumerable <DuplaSena> >(_listToLoad);
            var         duplaSenaService = new DuplaSenaService(_mockServiceRepo.Object);
            LotteryData actualResult     = duplaSenaService.LoadResultsFor();

            Assert.AreEqual(expectedResult.ToString(), actualResult.ToString());
        }
Exemple #22
0
        public async Task Execute(IJobExecutionContext context)
        {
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Interface);
                request.Method      = "GET";
                request.ContentType = "text/html;charset=UTF-8";
                HttpWebResponse     response         = (HttpWebResponse)request.GetResponse();
                Stream              myResponseStream = response.GetResponseStream();
                StreamReader        myStreamReader   = new StreamReader(myResponseStream, Encoding.UTF8);
                string              retString        = myStreamReader.ReadToEnd();
                JObject             json             = (JObject)JsonConvert.DeserializeObject(retString);
                LotteryData         lottery          = new LotteryData();
                List <NumeralGroup> numberlgroup     = DbContext.NumeralGroups.OrderBy(n => n.Ranking).ToList();
                JObject             data             = (JObject)JsonConvert.DeserializeObject(json["data"].ToString());
                JObject             newest           = (JObject)JsonConvert.DeserializeObject(data["newest"].ToString());
                DateTime            datetime         = Convert.ToDateTime(newest["time"]);
                lottery.IssueId = Convert.ToInt32(newest["issue"]);
                var array = newest["array"].ToArray();

                var lott = DbContext.LotteryDatas.Where(l => l.IssueId == lottery.IssueId).ToList().Count();
                if (lott < 1)
                {
                    lottery.Champion = Convert.ToInt32(array[0]);
                    lottery.RunnerUp = Convert.ToInt32(array[1]);
                    lottery.Third    = Convert.ToInt32(array[2]);
                    lottery.Fourth   = Convert.ToInt32(array[3]);
                    lottery.Fifth    = Convert.ToInt32(array[4]);
                    lottery.Sixth    = Convert.ToInt32(array[5]);
                    lottery.Seventh  = Convert.ToInt32(array[6]);
                    lottery.Eighth   = Convert.ToInt32(array[7]);
                    lottery.Ninth    = Convert.ToInt32(array[8]);
                    lottery.Tenth    = Convert.ToInt32(array[9]);
                    lottery.Date     = Convert.ToDateTime(datetime.ToString("d"));
                    lottery.Time     = datetime.ToString("T");
                    DbContext.LotteryDatas.Add(lottery);
                    DbContext.SaveChanges();
                    for (int i = 1; i <= 10; i++)
                    {
                        Omissions omission = DbContext.Omissions.Where(o => o.Ranking == i).First();
                        switch (Convert.ToInt32(array[i - 1]))
                        {
                        case 1:
                            omission.One = 0;
                            omission.Two++;
                            omission.Three++;
                            omission.Four++;
                            omission.Five++;
                            omission.Six++;
                            omission.Seven++;
                            omission.Eight++;
                            omission.Nine++;
                            omission.Ten++;
                            DbContext.SaveChanges();
                            break;

                        case 2:
                            omission.One++;
                            omission.Two = 0;
                            omission.Three++;
                            omission.Four++;
                            omission.Five++;
                            omission.Six++;
                            omission.Seven++;
                            omission.Eight++;
                            omission.Nine++;
                            omission.Ten++;
                            DbContext.SaveChanges();
                            break;

                        case 3:
                            omission.One++;
                            omission.Two++;
                            omission.Three = 0;
                            omission.Four++;
                            omission.Five++;
                            omission.Six++;
                            omission.Seven++;
                            omission.Eight++;
                            omission.Nine++;
                            omission.Ten++;
                            DbContext.SaveChanges();
                            break;

                        case 4:
                            omission.One++;
                            omission.Two++;
                            omission.Three++;
                            omission.Four = 0;
                            omission.Five++;
                            omission.Six++;
                            omission.Seven++;
                            omission.Eight++;
                            omission.Nine++;
                            omission.Ten++;
                            DbContext.SaveChanges();
                            break;

                        case 5:
                            omission.One++;
                            omission.Two++;
                            omission.Three++;
                            omission.Four++;
                            omission.Five = 0;
                            omission.Six++;
                            omission.Seven++;
                            omission.Eight++;
                            omission.Nine++;
                            omission.Ten++;
                            DbContext.SaveChanges();
                            break;

                        case 6:
                            omission.One++;
                            omission.Two++;
                            omission.Three++;
                            omission.Four++;
                            omission.Five++;
                            omission.Six = 0;
                            omission.Seven++;
                            omission.Eight++;
                            omission.Nine++;
                            omission.Ten++;
                            DbContext.SaveChanges();
                            break;

                        case 7:
                            omission.One++;
                            omission.Two++;
                            omission.Three++;
                            omission.Four++;
                            omission.Five++;
                            omission.Six++;
                            omission.Seven = 0;
                            omission.Eight++;
                            omission.Nine++;
                            omission.Ten++;
                            DbContext.SaveChanges();
                            break;

                        case 8:
                            omission.One++;
                            omission.Two++;
                            omission.Three++;
                            omission.Four++;
                            omission.Five++;
                            omission.Six++;
                            omission.Seven++;
                            omission.Eight = 0;
                            omission.Nine++;
                            omission.Ten++;
                            DbContext.SaveChanges();
                            break;

                        case 9:
                            omission.One++;
                            omission.Two++;
                            omission.Three++;
                            omission.Four++;
                            omission.Five++;
                            omission.Six++;
                            omission.Seven++;
                            omission.Eight++;
                            omission.Nine = 0;
                            omission.Ten++;
                            DbContext.SaveChanges();
                            break;

                        case 10:
                            omission.One++;
                            omission.Two++;
                            omission.Three++;
                            omission.Four++;
                            omission.Five++;
                            omission.Six++;
                            omission.Seven++;
                            omission.Eight++;
                            omission.Nine++;
                            omission.Ten = 0;
                            DbContext.SaveChanges();
                            break;
                        }
                        List <NumeralGroup> numberlist = DbContext.NumeralGroups.Where(n => n.Ranking == i).ToList <NumeralGroup>();
                        foreach (var item in numberlist)
                        {
                            string[]         intArray = item.Group.Split(',');
                            ContinuityNumber prize    = DbContext.ContinuityNumbers.Where(c => c.NGId == item.Id).FirstOrDefault <ContinuityNumber>();
                            if (prize == null)
                            {
                                prize                  = new ContinuityNumber();
                                prize.NGId             = item.Id;
                                prize.RankingId        = item.Ranking;
                                prize.TenNumber        = 0;
                                prize.MonthNumber      = 0;
                                prize.ThreeMonthNumber = 0;
                                prize.HalfYearNumber   = 0;
                                prize.YearNumber       = 0;
                                DbContext.ContinuityNumbers.Add(prize);
                                DbContext.SaveChanges();
                            }
                            int contain = Array.IndexOf(intArray, array[i - 1].ToString());
                            if (contain < 0)
                            {
                                prize.TenNumber++;
                                if (prize.TenNumber >= 5)
                                {
                                    StatisticsTen statis = DbContext.StatisticsTens.Where(s => s.Frequency == prize.TenNumber && s.RankingId == i && s.NGId == item.Id).FirstOrDefault <StatisticsTen>();
                                    if (statis == null)
                                    {
                                        StatisticsTen statisnew = new StatisticsTen();
                                        statisnew.RankingId = i;
                                        statisnew.Frequency = prize.TenNumber;
                                        statisnew.Number    = 1;
                                        statisnew.NGId      = item.Id;
                                        DbContext.StatisticsTens.Add(statisnew);
                                        DbContext.SaveChanges();
                                    }
                                    else
                                    {
                                        statis.Number++;
                                    }
                                    StatisticsMonth statimon = DbContext.StatisticsMonths.Where(s => s.Frequency == prize.TenNumber && s.RankingId == i && s.NGId == item.Id).FirstOrDefault <StatisticsMonth>();
                                    if (statimon == null)
                                    {
                                        StatisticsMonth statisnew = new StatisticsMonth();
                                        statisnew.RankingId = i;
                                        statisnew.Frequency = prize.TenNumber;
                                        statisnew.Number    = 1;
                                        statisnew.NGId      = item.Id;
                                        DbContext.StatisticsMonths.Add(statisnew);
                                        DbContext.SaveChanges();
                                    }
                                    else
                                    {
                                        statimon.Number++;
                                    }
                                    StatisticsThreeMonth statithrmon = DbContext.StatisticsThreeMonths.Where(s => s.Frequency == prize.TenNumber && s.RankingId == i && s.NGId == item.Id).FirstOrDefault <StatisticsThreeMonth>();
                                    if (statithrmon == null)
                                    {
                                        StatisticsThreeMonth statisnew = new StatisticsThreeMonth();
                                        statisnew.RankingId = i;
                                        statisnew.Frequency = prize.TenNumber;
                                        statisnew.Number    = 1;
                                        statisnew.NGId      = item.Id;
                                        DbContext.StatisticsThreeMonths.Add(statisnew);
                                        DbContext.SaveChanges();
                                    }
                                    else
                                    {
                                        statithrmon.Number++;
                                    }
                                    StatisticsHalfYear statihaye = DbContext.StatisticsHalfYears.Where(s => s.Frequency == prize.TenNumber && s.RankingId == i && s.NGId == item.Id).FirstOrDefault <StatisticsHalfYear>();
                                    if (statihaye == null)
                                    {
                                        StatisticsHalfYear statisnew = new StatisticsHalfYear();
                                        statisnew.RankingId = i;
                                        statisnew.Frequency = prize.TenNumber;
                                        statisnew.Number    = 1;
                                        statisnew.NGId      = item.Id;
                                        DbContext.StatisticsHalfYears.Add(statisnew);
                                        DbContext.SaveChanges();
                                    }
                                    else
                                    {
                                        statihaye.Number++;
                                    }
                                    StatisticsYear statiyear = DbContext.StatisticsYears.Where(s => s.Frequency == prize.TenNumber && s.RankingId == i && s.NGId == item.Id).FirstOrDefault <StatisticsYear>();
                                    if (statiyear == null)
                                    {
                                        StatisticsYear statisnew = new StatisticsYear();
                                        statisnew.RankingId = i;
                                        statisnew.Frequency = prize.TenNumber;
                                        statisnew.Number    = 1;
                                        statisnew.NGId      = item.Id;
                                        DbContext.StatisticsYears.Add(statisnew);
                                        DbContext.SaveChanges();
                                    }
                                    else
                                    {
                                        statiyear.Number++;
                                    }
                                }
                            }
                            else
                            {
                                prize.TenNumber = 0;
                            }
                        }
                    }

                    DbContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }