Beispiel #1
0
        private async System.Threading.Tasks.Task CsgoPay()
        {
            var csgo = new GameAutoPayRepository().getCsgoList();

            foreach (var c in csgo)
            {
                try
                {
                    CSGOMatches.RootObject getm = await new CSGORepository().GetCSGOMatches((int)c.AutoSn);
                    var gt = (DateTime)getm.end_at;
                    if (getm.end_at == null && gt.AddMinutes(15) > DateTime.Now)
                    {
                        continue;
                    }

                    var game = await new GamesRepository().GetALLAutoGameList();
                    //var game = await new GamesRepository().GetGameDetail(c.GameSn);
                    var g = game.Where(p => p.sn == c.GameSn).FirstOrDefault();
                    if (g.gameStatus != 4)
                    {
                        continue;
                    }

                    await new AutoPayController().pays(c.GameSn);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                try
                {
                    //發送至gti
                    string         url     = "http://funbet.games/Account/BearAutoPayLoginByURL";
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    request.Method      = "POST";
                    request.ContentType = "application/x-www-form-urlencoded";
                    string result = null;


                    string param = "par=vnTy73o73S6DInB9blni0jLxdfSZO%2BxbU9/dyY4VcUr9rCNcS9ErKMzWjixZlA6CPATa9f8aKtLqASTHeb7xKnoqPOrCD34odGD2w1jmr2NaMycREjIlJe0bUdfD8qcx&bearid=" + c.sn.ToString();
                    byte[] bs    = Encoding.ASCII.GetBytes(param);

                    using (Stream reqStream = request.GetRequestStream())
                    {
                        reqStream.Write(bs, 0, bs.Length);
                    }

                    using (WebResponse response = request.GetResponse())
                    {
                        StreamReader sr = new StreamReader(response.GetResponseStream());
                        result = sr.ReadToEnd();
                        sr.Close();
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #2
0
        private async System.Threading.Tasks.Task updateTimeAsync(GamePosts gp)
        {
            try
            {
                //var game = await new GamesRepository().GetGameDetail(c.GameSn);
                CSGOMatches.RootObject getm = await new CSGORepository().GetCSGOMatches((int)gp.AutoSn);


                //更新時間日期


                if (gp.edate != getm.begin_at)
                {
                    var gpm = await new gameController().AutoEdit(gp.sn);
                    gpm.gamepost.edate = getm.begin_at;
                    gpm.game.edate     = getm.begin_at;
                    gpm.game.gamedate  = getm.begin_at;
                    foreach (var t in gpm.game.topicList)
                    {
                        t.edate = getm.begin_at;
                    }
                    await new gameController().AutoEdit(gpm);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        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> TimeUpdate()
        {
            var csgo = new GameAutoPayRepository().getCsgoNoTimeList();



            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 gpm = await new gameController().AutoEdit(c.sn);

                    if (gpm.gamepost.edate != getm.begin_at)
                    {
                        gpm.gamepost.edate = getm.begin_at;
                        gpm.game.edate     = getm.begin_at;
                        gpm.game.gamedate  = getm.begin_at;
                        foreach (var t in gpm.game.topicList)
                        {
                            t.edate = getm.begin_at;
                        }
                        await new gameController().AutoEdit(gpm);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            return(View());
        }
        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());
        }
        public async System.Threading.Tasks.Task <string> CSGOSetAnswer(int gpid, List <CSGOGame.RootObject> cslist, CSGOMatches.RootObject csgetm)
        {
            try
            {
                GamePosts gamepost = new GamePostsRepository().get(gpid);
                gameDto   game     = null;
                game = await new GamesRepository().GetGameDetail(gamepost.GameSn);

                GamePostViewModel gpvm = new GamePostViewModel(gpid, encryptedKey, game);
                gpvm.gamepost = gamepost;

                // game = await new GamesRepository().GetGameDetail(gamepost.GameSn);


                gameDto         gd     = null;
                GamesRepository _games = new GamesRepository();
                gd = await _games.GetGameDetail(gpvm.game.sn);



                if (1 == 1)
                {
                    List <choiceDto> choice = new List <choiceDto>();
                    foreach (topicDto t in gpvm.game.topicList)
                    {
                        foreach (var c in t.choiceList)
                        {
                            //1:哪隊會獲得勝利 2:總地圖數奇/偶 3:第一個地圖勝利隊伍 4:第二個地圖勝利隊伍 5:總地圖數會高於還是低於x.5 6:第一個地圖總回合數奇/偶 7:第二個地圖總回合數奇/偶
                            switch (t.autotype)
                            {
                            case 1:
                                if (csgetm.winner == null)
                                {
                                    if (c.cNumberType == 3)
                                    {
                                        c.isTrue = 1;
                                    }
                                    else
                                    {
                                        c.isTrue = 0;
                                    }
                                }
                                else
                                {
                                    if (csgetm.winner.name == c.choiceStr)
                                    {
                                        c.isTrue = 1;
                                    }
                                    else
                                    {
                                        c.isTrue = 0;
                                    }
                                }


                                break;

                            case 2:
                                if (cslist.Count() % 2 == 0 && c.cNumberType == 1)
                                {
                                    c.isTrue = 1;
                                }
                                else if (cslist.Count() % 2 != 0 && c.cNumberType == 0)
                                {
                                    c.isTrue = 1;
                                }
                                else
                                {
                                    c.isTrue = 0;
                                }
                                break;

                            case 3:
                                CSGOTeam.RootObject wteam = await new CSGORepository().GetCSGOTeam((int)csgetm.games[0].winner.id);
                                if (wteam.name == c.choiceStr)
                                {
                                    c.isTrue = 1;
                                }
                                else
                                {
                                    c.isTrue = 0;
                                }
                                break;

                            case 4:
                                wteam = await new CSGORepository().GetCSGOTeam((int)csgetm.games[1].winner.id);
                                if (wteam.name == c.choiceStr)
                                {
                                    c.isTrue = 1;
                                }
                                else
                                {
                                    c.isTrue = 0;
                                }
                                break;

                            case 5:
                                if (cslist.Count() < t.numberType && c.cNumberType == 1)
                                {
                                    c.isTrue = 1;
                                }
                                else if (cslist.Count() > t.numberType && c.cNumberType == 0)
                                {
                                    c.isTrue = 1;
                                }
                                else
                                {
                                    c.isTrue = 0;
                                }
                                break;

                            case 6:
                                if (cslist[0].rounds.Count() % 2 == 0 && c.cNumberType == 1)
                                {
                                    c.isTrue = 1;
                                }
                                else if (cslist[0].rounds.Count() % 2 != 0 && c.cNumberType == 0)
                                {
                                    c.isTrue = 1;
                                }
                                else
                                {
                                    c.isTrue = 0;
                                }
                                break;

                            case 7:
                                if (cslist[1].rounds.Count() % 2 == 0 && c.cNumberType == 1)
                                {
                                    c.isTrue = 1;
                                }
                                else if (cslist[1].rounds.Count() % 2 != 0 && c.cNumberType == 0)
                                {
                                    c.isTrue = 1;
                                }
                                else
                                {
                                    c.isTrue = 0;
                                }
                                break;

                            default:
                                Console.WriteLine("error");
                                break;
                            }
                        }

                        if (t.choiceList.Where(x => x.isTrue == 1).Count() == 0)
                        {
                            gpvm.game.gameStatus = 2;
                            gpvm.gamepost.pay    = 5;
                            await new gameController().AutoEdit(gpvm);
                            rebearpage(gpvm.game.sn);
                            throw new Exception("error");
                        }
                        else
                        {
                            choice.AddRange(t.choiceList);
                        }
                    }



                    bool haveTrue  = false;
                    bool allReturn = true;
                    foreach (choiceDto cho in choice)
                    {
                        if (cho.isTrue.HasValue && cho.isTrue == 1)
                        {
                            haveTrue = true;
                        }
                        if (cho.isTrue != 2)
                        {
                            allReturn = false;
                        }
                    }
                    if (haveTrue || allReturn)
                    {
                        SetWinnerReq swq = new SetWinnerReq();
                        swq.UserID     = new AccountRepository().getUserEmail("*****@*****.**").Id;
                        swq.comSn      = 1;
                        swq.choiceList = choice;
                        swq.gameSn     = gpvm.game.sn;
                        bool issuccess = await _games.setWinner(swq);

                        if (!issuccess)
                        {
                            return("系統設定出錯");
                        }
                        new SignalRHelper().UpdateTopic(gpvm.game, encryptedKey, gpvm.game.md5GameSn);

                        rebearpage(gpvm.game.sn);
                    }
                    else
                    {
                        return("未設定設定結果");
                    }
                }
                // Return the URI of the created resource.


                return("1");
            }
            catch
            {
                return("0");
            }
        }
Beispiel #7
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);
                }
            }
        }
        /* public async System.Threading.Tasks.Task<ActionResult> pyatest()
         * {
         *   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 this.CSGOSetAnswer(c.sn, allgame, getm);
         *
         *
         *
         *
         *   }
         *
         *   return View();
         * }*/


        public async System.Threading.Tasks.Task <string> CSGOSetAnswer(int gpid, List <CSGOGame.RootObject> cslist, CSGOMatches.RootObject csgetm)
        {
            try
            {
                GamePosts gamepost = new GamePostsRepository().get(gpid);
                gameDto   game     = null;
                game = await new GamesRepository().GetGameDetail(gamepost.GameSn);

                GamePostViewModel gpvm = new GamePostViewModel(gpid, encryptedKey, game);
                gpvm.gamepost = gamepost;

                // game = await new GamesRepository().GetGameDetail(gamepost.GameSn);


                gameDto         gd     = null;
                GamesRepository _games = new GamesRepository();
                gd = await _games.GetGameDetail(gpvm.game.sn);



                if (1 == 1)
                {
                    List <choiceDto> choice = new List <choiceDto>();
                    foreach (topicDto t in gpvm.game.topicList)
                    {
                        /* foreach(var c in t.choiceList)
                         * {
                         *   //1:哪隊會獲得勝利 2:總地圖數奇/偶 3:第一個地圖勝利隊伍 4:第二個地圖勝利隊伍 5:總地圖數會高於還是低於x.5 6:第一個地圖總回合數奇/偶 7:第二個地圖總回合數奇/偶
                         *   switch (t.autotype)
                         *   {
                         *       case 1:
                         *           if (csgetm.winner.name == c.choiceStr)
                         *           {
                         *               c.isTrue = 1;
                         *           }
                         *           else
                         *           {
                         *               c.isTrue = 0;
                         *           }
                         *           break;
                         *       case 2:
                         *           if (cslist.Count() / 2 == 0 && c.cNumberType == 1)
                         *           {
                         *               c.isTrue = 1;
                         *           }
                         *           else if (cslist.Count() / 2 != 0 && c.cNumberType == 0)
                         *           {
                         *
                         *               c.isTrue = 1;
                         *           }
                         *           else
                         *           {
                         *               c.isTrue = 0;
                         *           }
                         *           break;
                         *       case 3:
                         *           CSGOTeam.RootObject wteam = await new CSGORepository().GetCSGOTeam(csgetm.games[0].winner.id);
                         *           if (wteam.name == c.choiceStr)
                         *           {
                         *               c.isTrue = 1;
                         *           }
                         *           else
                         *           {
                         *               c.isTrue = 0;
                         *           }
                         *           break;
                         *       case 4:
                         *           wteam = await new CSGORepository().GetCSGOTeam(csgetm.games[1].winner.id);
                         *           if (wteam.name == c.choiceStr)
                         *           {
                         *               c.isTrue = 1;
                         *           }
                         *           else
                         *           {
                         *               c.isTrue = 0;
                         *           }
                         *           break;
                         *       case 5:
                         *           if (cslist.Count() < t.numberType && c.cNumberType == 1)
                         *           {
                         *               c.isTrue = 1;
                         *           }
                         *           else if (cslist.Count() > t.numberType && c.cNumberType == 0)
                         *           {
                         *               c.isTrue = 1;
                         *           }
                         *           else
                         *           {
                         *               c.isTrue = 0;
                         *           }
                         *           break;
                         *       case 6:
                         *           if (cslist[0].rounds.Count() / 2 == 0 && c.cNumberType == 1)
                         *           {
                         *               c.isTrue = 1;
                         *           }
                         *           else if (cslist.Count() / 2 != 0 && c.cNumberType == 0)
                         *           {
                         *
                         *               c.isTrue = 1;
                         *           }
                         *           else
                         *           {
                         *               c.isTrue = 0;
                         *           }
                         *           break;
                         *       case 7:
                         *           if (cslist[1].rounds.Count() / 2 == 0 && c.cNumberType == 1)
                         *           {
                         *               c.isTrue = 1;
                         *           }
                         *           else if (cslist.Count() / 2 != 0 && c.cNumberType == 0)
                         *           {
                         *
                         *               c.isTrue = 1;
                         *           }
                         *           else
                         *           {
                         *               c.isTrue = 0;
                         *           }
                         *           break;
                         *       default:
                         *           Console.WriteLine("error");
                         *           break;
                         *
                         *
                         *
                         *
                         *   }
                         *
                         *
                         * }*/

                        choice.AddRange(t.choiceList);
                    }

                    bool haveTrue  = false;
                    bool allReturn = true;
                    foreach (choiceDto cho in choice)
                    {
                        if (cho.isTrue.HasValue && cho.isTrue == 1)
                        {
                            haveTrue = true;
                        }
                        if (cho.isTrue != 2)
                        {
                            allReturn = false;
                        }
                    }
                    if (haveTrue || allReturn)
                    {
                        SetWinnerReq swq = new SetWinnerReq();
                        swq.UserID     = UserManager.FindByEmail("*****@*****.**").Id;
                        swq.comSn      = 1;
                        swq.choiceList = choice;
                        swq.gameSn     = gpvm.game.sn;
                        bool issuccess = await _games.setWinner(swq);

                        if (!issuccess)
                        {
                            return("系統設定出錯");
                        }
                        new SignalRHelper().UpdateTopic(gpvm.game, encryptedKey, gpvm.game.md5GameSn);
                    }
                    else
                    {
                        return("未設定設定結果");
                    }
                }
                // Return the URI of the created resource.


                return("1");
            }
            catch
            {
                return("0");
            }
        }