Example #1
0
        public async System.Threading.Tasks.Task <CSGOGame.RootObject> GetCSGOGame(int gameSn)
        {
            CSGOGame.RootObject data = null;
            try {
                //Dota2Model.RootObject dota2 = null;
                string url = "https://api.pandascore.co/csgo/games/" + gameSn + "?token=76QMCPlm65iZx8TgwGFLho-TUadJ7U1UeuogzSwltFzwAeksRqQ";

                JsonSerializerSettings microsoftDateFormatSettings = new JsonSerializerSettings
                {
                    DateFormatHandling   = DateFormatHandling.MicrosoftDateFormat,
                    DateTimeZoneHandling = DateTimeZoneHandling.Local
                };



                using (var client = new HttpClient())
                {
                    HttpResponseMessage response = await client.GetAsync(url).ConfigureAwait(false);

                    if (response.IsSuccessStatusCode)
                    {
                        var jsonResponse = response.Content.ReadAsStringAsync().Result;
                        data = JsonConvert.DeserializeObject <CSGOGame.RootObject>(jsonResponse, microsoftDateFormatSettings);
                    }
                }


                return(data);
            }catch (Exception e)
            {
                Console.WriteLine(e);
                return(data);
            }
        }
        private async System.Threading.Tasks.Task autoCsgoPay()
        {
            var csgo = new GameAutoPayRepository().getCsgoList();
            foreach (var c in csgo)
            {
                CSGOMatches.RootObject getm = await new CSGORepository().GetCSGOMatches((int)c.AutoSn);
                var allgame = new List<CSGOGame.RootObject>();
                foreach (var m in getm.games)
                {

                    CSGOGame.RootObject getg = await new CSGORepository().GetCSGOGame(m.id);
                    allgame.Add(getg);
                }
                await new AutoPayController().CSGOSetAnswer(c.sn, allgame, getm);




            }

        }
        public async System.Threading.Tasks.Task <ActionResult> SetPay()
        {
            var csgo = new GameAutoPayRepository().getCsgoList();



            foreach (var c in csgo)
            {
                try
                {
                    //var game = await new GamesRepository().GetGameDetail(c.GameSn);
                    CSGOMatches.RootObject getm = await new CSGORepository().GetCSGOMatches((int)c.AutoSn);
                    var gbat = (DateTime)getm.begin_at;

                    /*if (getm.end_at == null)
                     * {
                     *  if (gbat.AddHours(3) < DateTime.Now)
                     *      await updateTimeAsync(c);
                     *
                     *  continue;
                     * }*/


                    var game = await new GamesRepository().GetALLAutoGameList();
                    var g    = game.Where(p => p.sn == c.GameSn).FirstOrDefault();

                    if (g.gameStatus == 4 || g.gameStatus == 3)
                    {
                        continue;
                    }

                    var allgame = new List <CSGOGame.RootObject>();
                    foreach (var m in getm.games)
                    {
                        CSGOGame.RootObject getg = await new CSGORepository().GetCSGOGame(m.id);
                        allgame.Add(getg);
                    }
                    if (getm.number_of_games > 2)
                    {
                        if (allgame[0].rounds.Count() == 0 || allgame[1].rounds.Count() == 0 || allgame.Count() == 0 || getm.winner.name == null)
                        {
                            continue;
                        }
                    }
                    else if (getm.number_of_games == 1)
                    {
                        if (allgame[0].rounds.Count() == 0 || getm.winner.name == null || allgame.Count() == 0)
                        {
                            continue;
                        }
                    }
                    else if (getm.number_of_games == 2)
                    {
                        if (allgame[0].rounds.Count() == 0 || allgame[1].rounds.Count() == 0 || allgame.Count() == 0)
                        {
                            continue;
                        }
                    }



                    await CSGOSetAnswer(c.sn, allgame, getm);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            return(View());
        }
Example #4
0
        private async System.Threading.Tasks.Task autoCsgoPay()
        {
            var csgo = new GameAutoPayRepository().getCsgoList();



            foreach (var c in csgo)
            {
                try
                {
                    //var game = await new GamesRepository().GetGameDetail(c.GameSn);
                    CSGOMatches.RootObject getm = await new CSGORepository().GetCSGOMatches((int)c.AutoSn);
                    var gbat   = (DateTime)getm.begin_at;
                    var gedate = (DateTime)c.edate;

                    if (getm.end_at == null)
                    {
                        if (gedate.AddHours(3) < DateTime.Now)
                        {
                            await updateTimeAsync(c);
                        }

                        continue;
                    }
                    else
                    {
                        var getmend = (DateTime)getm.end_at;
                        if (getmend.AddMinutes(10) > DateTime.Now)
                        {
                            continue;
                        }
                    }


                    var game = await new GamesRepository().GetALLAutoGameList();
                    var g    = game.Where(p => p.sn == c.GameSn).FirstOrDefault();

                    if (g.gameStatus == 4 || g.gameStatus == 3)
                    {
                        continue;
                    }

                    var allgame = new List <CSGOGame.RootObject>();
                    foreach (var m in getm.games)
                    {
                        CSGOGame.RootObject getg = await new CSGORepository().GetCSGOGame(m.id);
                        allgame.Add(getg);
                    }
                    if (getm.detailed_stats == true)
                    {
                        if (getm.number_of_games > 2)
                        {
                            if (allgame[0].finished == false || allgame[1].finished == false || allgame.Count() == 0 || getm.winner.name == null || allgame[1].rounds_score == null)
                            {
                                continue;
                            }
                        }
                        else if (getm.number_of_games == 1)
                        {
                            if (allgame[0].rounds.Count() == 0 || getm.winner.name == null || allgame.Count() == 0)
                            {
                                continue;
                            }
                        }
                        else if (getm.number_of_games == 2)
                        {
                            if (allgame[0].rounds.Count() == 0 || allgame[1].rounds.Count() == 0 || allgame.Count() == 0)
                            {
                                continue;
                            }
                        }
                    }
                    else
                    {
                        if (getm.number_of_games > 2)
                        {
                            if (allgame.Count() == 0 || getm.winner.name == null)
                            {
                                continue;
                            }
                        }
                        else if (getm.number_of_games == 1)
                        {
                            if (getm.winner.name == null || allgame.Count() == 0)
                            {
                                continue;
                            }
                        }
                        else if (getm.number_of_games == 2)
                        {
                            if (allgame.Count() == 0)
                            {
                                continue;
                            }
                        }
                    }



                    await new AutoPayController().CSGOSetAnswer(c.sn, allgame, getm);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }