예제 #1
0
        public async Task JoinGroup(string roomName, string encryptedID)
        {
            string     encryptedKey = System.Web.Configuration.WebConfigurationManager.AppSettings["encryptedKey"];
            Encryption oEncrypt     = new Encryption();
            string     sGameSn      = oEncrypt.DecryptString(encryptedKey, encryptedID);
            int        gameSn;
            gameDto    gd = new gameDto();

            if (int.TryParse(sGameSn, out gameSn))
            {
                gd = await new GamesRepository().GetGameDetail(gameSn);
            }
            List <TopicSyncViewModel> tvmList = new List <TopicSyncViewModel>();

            foreach (topicDto td in gd.topicList)
            {
                tvmList.Add(new TopicSyncViewModel(td, encryptedKey, gd));
            }

            string returnJson = JsonConvert.SerializeObject(tvmList);

            Clients.Caller.ShowTopic(returnJson);

            await Groups.Add(Context.ConnectionId, roomName);
        }
        public JsonResult _choiceCreate(gameDto model, int?topicIndex, int?index)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            index = index ?? 0;
            int tIndex = topicIndex ?? 0;

            if (model.topicList == null)
            {
                model.topicList = new List <topicDto>();
            }

            var c = new List <choiceDto>();

            for (int j = 0; j <= index; j++)
            {
                c.Add(new choiceDto()
                {
                    valid = 1, choiceString = new List <choiceStrDto>()
                });
            }
            //model.topicList[tIndex].choiceList.Add(new choiceDto() { valid = 1, choiceString = new List<choiceStrDto>() });

            model.topicList[tIndex].choiceList = c;

            /*for (int i = 0; i <= topicIndex; i++)
             * {
             *
             * }*/



            // GamePostViewModel gpvm = new GamePostViewModel { game = model };
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        public async System.Threading.Tasks.Task <bool> PayBackClose(int id, int t, string back)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            try
            {
                gameDto         game   = null;
                GamesRepository _games = new GamesRepository();
                game = await _games.GetGameDetail(id);

                if (1 == 1 || game.userId == User.Identity.GetUserId())
                {
                    StartBetReq sbr = new StartBetReq();
                    sbr.comSn   = 1;
                    sbr.gameSn  = id;
                    sbr.topicSn = t;
                    sbr.back    = back;
                    bool bresult = await _games.deletePayLiveClose(sbr);

                    game = await _games.reLiveGameListAsync(sbr.gameSn);

                    new SignalRHelper().UpdateTopic(game, encryptedKey, game.md5GameSn);
                    return(bresult);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
        public ActionResult _bonusEdit(gameDto model, int?index)
        {
            ViewBag.Index = index;
            GamePostViewModel gpvm = new GamePostViewModel {
                game = model, vedio = new VedioRecord()
            };

            return(View(gpvm));
        }
예제 #5
0
        public TopicSyncViewModel(topicDto td, string encryptedKey, gameDto gd)
        {
            this.sn              = td.sn;
            this.title           = td.title;
            this.bigtitle        = gd.title;
            this.comment         = td.comment;
            this.edate           = td.edate;
            this.canbet          = (td.walk == 1 && gd.gameStatus == 0) ? true : td.canbet;
            this.encryptedKey    = encryptedKey;
            this.poolall         = td.poolall;
            this.promote         = td.promote;
            this.outlay          = td.outlay;
            this.image           = td.image;
            this.hoverImage      = td.hoverImage;
            this.walk            = td.walk;
            this.valid           = td.valid;
            this.choiceList      = new List <ChoiceViewModel>();
            this.betcountlist    = new List <BetCountViewModel>();
            this.betallcountlist = new List <BetAllCountViewModel>();
            this.live            = gd.live;
            this.betmodel        = gd.betModel;

            //龍的傳人才新增
            if (gd.betModel == 5)
            {
                string[] dgon = { "火龍", "地龍", "風龍", "水龍", "大龍" };
                for (var i = 0; i < dgon.Length; i++)
                {
                    this.betcountlist.Add(new BetCountViewModel(dgon[i], i));
                }

                foreach (BetCountViewModel bvl in this.betcountlist)
                {
                    foreach (betCountDto bed in td.betcountList)
                    {
                        if (bvl.dgonname == bed.choiceStr)
                        {
                            int cct = (int)bed.choiceCount;
                            bvl.donly[cct].dgonRate += bed.allcount;
                        }
                    }
                }
            }

            foreach (choiceDto cd in td.choiceList)
            {
                this.choiceList.Add(new ChoiceViewModel(cd, this.encryptedKey));
            }
            foreach (ChoiceViewModel d in this.choiceList)
            {
                if (gd.betModel == 5)
                {
                    d.betball += Math.Round(td.poolall / 150000, 2);
                }
                d.betMoneyRate = Math.Round((d.betMoney * 100 / this.choiceList.Sum(p => p.betMoney)) - 0.005, 2);
            }
        }
 public GamePostViewModel()
 {
     vedio    = new VedioRecord();
     gamepost = new GamePosts();
     game     = new gameDto();
     cfgVedio = new cfgVedio();
     TeamA    = new Teams();
     TeamB    = new Teams();
     PlayGame = new cfgPlayGame();
 }
        public ActionResult _DPchoiceEdit(gameDto model, int topicIndex, int index)
        {
            ViewBag.Index      = index;
            ViewBag.topicIndex = topicIndex;
            GamePostViewModel gpvm = new GamePostViewModel {
                game = model, vedio = new VedioRecord()
            };

            return(View(gpvm));
        }
예제 #8
0
        public async System.Threading.Tasks.Task <gameDto> GetGameDetail(int id)
        {
            gameDto game = null;

            //HttpResponseMessage response = await client.GetAsync("/api/games/" + id);
            //if (response.IsSuccessStatusCode)
            //{
            //    game = await response.Content.ReadAsAsync<gameDto>();
            //}
            game = (await GetGameList()).Where(p => p.sn == id).FirstOrDefault();
            return(game);
        }
        public ActionResult _DPtopicEdit(gameDto model, int index)
        {
            //ViewBag.Index = index;

            //index = index ?? 0;
            ViewBag.Index = index;
            GamePostViewModel gpvm = new GamePostViewModel {
                game = model, vedio = new VedioRecord()
            };

            return(View(gpvm));
        }
예제 #10
0
        public async System.Threading.Tasks.Task <gameDto> Edit(int id, gameDto game)
        {
            game.comSn = 1;
            HttpResponseMessage response = await client.PutAsJsonAsync("api/games/" + id, game);

            response.EnsureSuccessStatusCode();

            await reflashGameListAsync();

            game = await GetGameDetail(game.sn);

            return(game);
        }
예제 #11
0
        public async System.Threading.Tasks.Task <gameDto> Edit(int id)
        {
            gameDto             game     = null;
            HttpResponseMessage response = await client.GetAsync("/api/games/" + id);

            if (response.IsSuccessStatusCode)
            {
                game = await response.Content.ReadAsAsync <gameDto>();
            }
            response.EnsureSuccessStatusCode();

            return(game);
        }
        public GamePostViewModel(int sn, string encryptedKey, gameDto gd)
        {
            GamePosts gamepost = new GamePostsRepository().get(sn);

            this.encryptedKey = encryptedKey;
            this.game         = gd;
            this.gamepost     = gamepost;
            if (gamepost.VedioRecordSn.HasValue)
            {
                this.vedio    = new VedioRecordRepository().get(gamepost.VedioRecordSn.Value);
                this.cfgVedio = new cfgVedioRepository().get(this.vedio.cfgVedioSn);
            }
        }
        public ActionResult _choiceStrEdit(gameDto model, int?index)
        {
            ViewBag.Index = index;
            GamePostViewModel gpvm = new GamePostViewModel {
                game = model, vedio = new VedioRecord()
            };

            // choiceOddsViewModel cov = new choiceOddsViewModel();
            // cov.unitSn = model.topicList[topicIndex].choiceList[choiceIndex].betMoney[index].unitSn;
            //cov.Odds = model.topicList[topicIndex].choiceList[choiceIndex].betMoney[index].Odds;
            //ViewBag.choiceOddsViewModel = cov;

            return(View(gpvm));
        }
예제 #14
0
        /// <summary>
        /// 更新用戶端此選項的下注金額
        /// </summary>
        /// <param name="game">game物件</param>
        /// <param name="encryptedKey">gameSn解密的key</param>
        /// <param name="GroupKey">signalR Group的key,也是game.md5GameSn</param>
        public void UpdateChoiceMoney(gameDto game, string encryptedKey, string GroupKey)
        {
            List <topicDto>           topicList = game.topicList;
            List <TopicSyncViewModel> tvmList   = new List <TopicSyncViewModel>();

            foreach (topicDto t in topicList)
            {
                tvmList.Add(new TopicSyncViewModel(t, encryptedKey, game));
            }
            string returnJson = JsonConvert.SerializeObject(tvmList);
            var    context    = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <SITW.Hubs.TopicHub>();

            context.Clients.Group(GroupKey).updateBetMoney(returnJson);
        }
예제 #15
0
        public async System.Threading.Tasks.Task <gameDto> Create(gameDto game)
        {
            HttpResponseMessage response = await client.PostAsJsonAsync("api/games", game);

            var result = await response.Content.ReadAsStringAsync();

            JavaScriptSerializer json_serializer = new JavaScriptSerializer();

            game = json_serializer.Deserialize <gameDto>(result);
            response.EnsureSuccessStatusCode();

            await reflashGameListAsync();

            return(game);
        }
예제 #16
0
        public async System.Threading.Tasks.Task <gameDto> EditLive(int id, gameDto game)
        {
            game.comSn = 1;
            SetWinnerReq swq = new SetWinnerReq();

            swq.gameSn = id;
            swq.game   = game;
            HttpResponseMessage response = await client.PostAsJsonAsync("api/PutgameLive/", swq);

            await adminreflashGameListAsync();

            game = await reLiveGameListAsync(game.sn);

            return(game);
        }
예제 #17
0
 public GameSyncViewModel(gameDto gd, string encryptedKey)
 {
     this.sn           = gd.sn;
     this.title        = gd.title;
     this.comment      = gd.comment;
     this.edate        = gd.edate;
     this.canbet       = gd.canbet;
     this.encryptedKey = encryptedKey;
     this.gamedate     = gd.gamedate;
     this.gameplace    = gd.gameplace;
     this.topicList    = new List <TopicSyncViewModel>();
     foreach (topicDto td in gd.topicList)
     {
         this.topicList.Add(new TopicSyncViewModel(td, encryptedKey, gd));
     }
 }
        public async System.Threading.Tasks.Task <ActionResult> DPEdit(int id)
        {
            GamePosts gamepost = new GamePostsRepository().get(id);
            gameDto   game     = null;
            string    UserID   = User.Identity.GetUserId();

            game = await new GamesRepository().GetGameDetail(gamepost.GameSn);
            //if (game.userId != UserID)
            //    return View("Details", game);

            GamePostViewModel gpvm = new GamePostViewModel(id, encryptedKey, game);



            return(View(gpvm));
        }
예제 #19
0
        public async System.Threading.Tasks.Task <JsonResult> GetEdit(int id)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            GamePosts gamepost = new GamePostsRepository().get(id);
            gameDto   game     = null;
            string    UserID   = User.Identity.GetUserId();

            game = await new GamesRepository().reLiveGameListAsync(gamepost.GameSn);
            //if (game.userId != UserID)
            //    return View("Details", game);

            GamePostViewModel gpvm = new GamePostViewModel(id, encryptedKey, game);



            return(Json(gpvm, JsonRequestBehavior.AllowGet));
        }
예제 #20
0
        public async System.Threading.Tasks.Task <gameDto> GetGameDetailByTopicSn(int id)
        {
            List <gameDto> gameList = await GetGameList();

            gameDto game = new gameDto();

            foreach (gameDto g in gameList)
            {
                if (g.topicList.Where(p => p.sn == id).Count() >= 1)
                {
                    game = g;
                    break;
                }
            }

            return(game);
        }
예제 #21
0
        /*public async System.Threading.Tasks.Task<gameDto> GetGameLiveDetail(int id)
         * {
         *  gameDto game = null;
         *  HttpResponseMessage response = await client.GetAsync("api/gamesLive/" + id);
         *  if (response.IsSuccessStatusCode)
         *  {
         *      game = await response.Content.ReadAsAsync<gameDto>();
         *  }
         *  //game = (await GetGameList()).Where(p => p.sn == id).FirstOrDefault();
         *  return game;
         * }*/

        public async System.Threading.Tasks.Task <gameDto> GetGamePayDetail(int id)
        {
            gameDto      game = null;
            SetWinnerReq swq  = new SetWinnerReq();

            swq.gameSn = id;
            HttpResponseMessage response = await client.PostAsJsonAsync("api/gamesPay/", swq);

            var result = await response.Content.ReadAsStringAsync();

            JavaScriptSerializer json_serializer = new JavaScriptSerializer();

            game = json_serializer.Deserialize <gameDto>(result);
            response.EnsureSuccessStatusCode();

            //await reflashGameListAsync();

            return(game);
        }
예제 #22
0
 public JsonResult _topicCreate(gameDto model, int?index)
 {
     ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
     index = index ?? 0;
     //ViewBag.Index = index;
     //ViewBag.walk = walk;
     //ViewBag.choice = choice;
     if (model.topicList == null)
     {
         model.topicList = new List <topicDto>();
     }
     for (int i = 0; i <= index; i++)
     {
         model.topicList.Add(new topicDto {
             valid = 1, main = (index == 0), choiceList = new List <choiceDto>()
         });
     }
     ///GamePostViewModel gpvmm = new GamePostViewModel { game = model };
     return(Json(model, JsonRequestBehavior.AllowGet));
 }
        public IHttpActionResult Putgame(int id, gameDto game)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != game.sn)
            {
                return(BadRequest());
            }
            bool isOK = new GameRepository().SetGame(id, game);

            if (!isOK)
            {
                return(NotFound());
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async System.Threading.Tasks.Task <string> pays(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                gameDto         game   = null;
                GamesRepository _games = new GamesRepository();
                game = await _games.GetGameDetail(id);

                if (1 == 1)
                {
                    List <payoutDto> payoutList = new List <payoutDto>();
                    StartBetReq      sbr        = new StartBetReq();
                    sbr.UserID = new AccountRepository().getUserEmail("*****@*****.**").Id;
                    sbr.comSn  = 1;
                    sbr.gameSn = id;
                    ajd        = await _games.pays(sbr, game.betModel);

                    game = await _games.GetGameDetail(sbr.gameSn);

                    rebearpage(id);



                    new SignalRHelper().UpdateTopic(game, encryptedKey, game.md5GameSn);
                }
            }
            catch
            {
                ajd.isTrue    = false;
                ajd.ErrorCode = 500;
            }

            return(JsonConvert.SerializeObject(ajd));
        }
        public game PostgameLive(gameDto gameD)
        {
            /*  if (!ModelState.IsValid)
             * {
             *    return BadRequest(ModelState);
             * }*/
            user u = db.users.Where(p => p.userID == gameD.userId && p.comSn == gameD.comSn).FirstOrDefault();

            if (u == null)
            {
                //return BadRequest("UserID不存在");
            }
            else
            {
                gameD.userSn = u.sn;
            }

            Mapper.Initialize(cfg => {
                cfg.CreateMap <gameDto, game>();
                cfg.CreateMap <topicDto, topic>();
                cfg.CreateMap <choiceDto, choice>();
                cfg.CreateMap <choiceStrDto, choiceStr>();
                cfg.CreateMap <bonusDto, bonu>();
            });
            game game = Mapper.Map <game>(gameD);

            game.gameStatus = 1;      //遊戲建立的時候是關閉狀態
            game.valid      = 1;
            game.live       = 1;

            //game.createDate = DateTime.Now;
            db.games.Add(game);
            db.SaveChanges();

            return(game);
        }
        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");
            }
        }
예제 #27
0
        public async System.Threading.Tasks.Task <ActionResult> EditTopic(GamePostViewModel gpvm)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            //try
            //{
            int       iGamePostSn = gpvm.getGamePostSn(encryptedKey);
            GamePosts gp          = new GamePostsRepository().get(iGamePostSn);

            if (!string.IsNullOrEmpty(gpvm.vedio.vediourl))
            {
                gpvm.vedio.title   = (string.IsNullOrEmpty(gpvm.vedio.title) ? "" : gpvm.vedio.title);
                gpvm.vedio.comment = (string.IsNullOrEmpty(gpvm.vedio.comment) ? "" : gpvm.vedio.comment);
                gpvm.vedio.valid   = 1;
                gpvm.vedio.inpdate = DateTime.Now;
                List <cfgVedio> cvList = new cfgVedioRepository().getAll();
                gpvm.vedio.cfgVedioSn = 4;
                foreach (cfgVedio cv in cvList)
                {
                    Regex defaultRegex = new Regex(cv.RegularStr);
                    if (defaultRegex.Match(gpvm.vedio.vediourl).Success)
                    {
                        gpvm.vedio.cfgVedioSn = cv.sn;
                    }

                    /*
                     * List<string> includestr = cv.includeURL.Split(',').ToList();
                     * foreach (string str in includestr)
                     * {
                     *  if (includestr.Contains(str))
                     *  {
                     *      gpvm.vedio.cfgVedioSn = cv.sn;
                     *  }
                     * }
                     */
                }
            }
            VedioRecordRepository vrr = new VedioRecordRepository();

            if (gp.VedioRecordSn.HasValue)
            {
                VedioRecord vr = new VedioRecordRepository().get(gp.VedioRecordSn.Value);
                vr.cfgVedioSn = gpvm.vedio.cfgVedioSn;
                vr.vediourl   = gpvm.vedio.vediourl;
                vrr.update(vr);
                gpvm.vedio = vr;
            }
            else
            {
                if (!string.IsNullOrEmpty(gpvm.vedio.vediourl))
                {
                    vrr.add(gpvm.vedio);
                }
            }



            gameDto game = gpvm.game;

            var regame = await new GamesRepository().reLiveGameListAsync(gpvm.gamepost.GameSn);

            for (int i = 0; i < regame.topicList.Count; i++)
            {
                game.topicList[i].sdate = regame.topicList[i].sdate;
                game.topicList[i].edate = regame.topicList[i].edate;
            }
            game.comSn      = 1;
            game.sdate      = DateTime.Now;
            game.edate      = DateTime.Now.AddYears(100);
            game.gamedate   = DateTime.Now.AddYears(100);
            game.gameStatus = 0;
            game            = await new GamesRepository().EditLive(game.sn, game);


            if (gpvm.vedio != null && gpvm.vedio.sn != 0)
            {
                gp.VedioRecordSn = gpvm.vedio.sn;
            }

            gp.TeamASn    = gpvm.gamepost.TeamASn;
            gp.TeamBSn    = gpvm.gamepost.TeamBSn;
            gp.sdate      = DateTime.Now;
            gp.edate      = DateTime.Now.AddYears(100);
            gp.PlayGameSn = gpvm.gamepost.PlayGameSn;
            new GamePostsRepository().update(gp);

            gpvm.game = game;

            ///把新的topic推播到前端
            new SignalRHelper().UpdateTopic(game, encryptedKey, gpvm.md5GameSn);
            return(Json(gpvm, JsonRequestBehavior.AllowGet));
            //}
            //catch (Exception ex)
            //{
            //    return View(gpvm);
            //}
        }
예제 #28
0
        public async System.Threading.Tasks.Task <JsonResult> Edit(GamePostViewModel gpvm)
        {
            //try
            //{
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            int       iGamePostSn = gpvm.getGamePostSn(encryptedKey);
            GamePosts gp          = new GamePostsRepository().get(iGamePostSn);
            var       vedio       = new VedioRecord();

            if (gpvm.vedio == null)
            {
                gpvm.vedio = vedio;
            }

            if (gpvm.livename == "1")
            {
                gpvm.vedio.vediourl   = "https://www.twitch.tv/" + gpvm.live;
                gpvm.vedio.cfgVedioSn = 4;
            }
            else if (gpvm.livename == "2")
            {
                gpvm.vedio.vediourl   = gpvm.live;
                gpvm.vedio.cfgVedioSn = 5;
            }
            else
            {
                gpvm.vedio = vedio;
            }
            if (gpvm.vedio != null)
            {
                gpvm.vedio.title   = (string.IsNullOrEmpty(gpvm.vedio.title) ? "" : gpvm.vedio.title);
                gpvm.vedio.comment = (string.IsNullOrEmpty(gpvm.vedio.comment) ? "" : gpvm.vedio.comment);
                gpvm.vedio.valid   = 1;
                gpvm.vedio.inpdate = DateTime.Now;
            }
            VedioRecordRepository vrr = new VedioRecordRepository();

            if (gp.VedioRecordSn.HasValue)
            {
                VedioRecord vr = new VedioRecordRepository().get(gp.VedioRecordSn.Value);
                vr.cfgVedioSn = gpvm.vedio.cfgVedioSn;
                vr.vediourl   = gpvm.vedio.vediourl;
                vr.live       = gpvm.live;
                vrr.update(vr);
                gpvm.vedio = vr;
            }
            else
            {
                if (gpvm.vedio != null)
                {
                    vrr.add(gpvm.vedio);
                }
            }



            gameDto game   = gpvm.game;
            var     regame = await new GamesRepository().reLiveGameListAsync(gpvm.gamepost.GameSn);

            for (int i = 0; i < regame.topicList.Count; i++)
            {
                game.topicList[i].sdate = regame.topicList[i].sdate;
                game.topicList[i].edate = regame.topicList[i].edate;
            }
            game.comSn    = 1;
            game.sdate    = DateTime.Now;
            game.edate    = DateTime.Now.AddYears(100);
            game.gamedate = DateTime.Now.AddYears(100);
            game          = await new GamesRepository().EditLive(game.sn, game);


            if (gpvm.vedio != null && gpvm.vedio.sn != 0)
            {
                gp.VedioRecordSn = gpvm.vedio.sn;
            }

            gp.TeamASn = gpvm.gamepost.TeamASn;
            gp.TeamBSn = gpvm.gamepost.TeamBSn;
            gp.sdate   = DateTime.Now;
            gp.edate   = DateTime.Now.AddYears(100);
            var  cfpgame = new cfgPlayGameRepository().getAllLive();
            bool cf      = false;

            foreach (var cg in cfpgame)
            {
                if (cg.shortName == gpvm.PlayGame.shortName)
                {
                    cf            = true;
                    gp.PlayGameSn = cg.sn;
                }
            }

            if (!cf)
            {
                cfgPlayGame cfpg = new cfgPlayGame();

                cfpg.shortName = gpvm.PlayGame.shortName;
                cfpg.cName     = gpvm.PlayGame.shortName;
                cfpg.eName     = gpvm.PlayGame.shortName;
                cfpg.valid     = 2;
                gp.PlayGameSn  = new cfgPlayGameRepository().Create(cfpg);
            }

            new GamePostsRepository().update(gp);
            gpvm.gamepost = gp;
            gpvm.game     = game;

            ///把新的topic推播到前端
            new SignalRHelper().UpdateTopic(game, encryptedKey, gpvm.md5GameSn);
            return(Json(gpvm, JsonRequestBehavior.AllowGet));
            // return RedirectToAction(game.betDetails, new { id = gpvm.gamepost.sn });
            //}
            //catch (Exception ex)
            //{
            //    return View(gpvm);
            //}
        }
예제 #29
0
        public async System.Threading.Tasks.Task <JsonResult> SetWinnerPay(GamePostViewModel gp, int topicSn)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            aJaxDto ajd = new aJaxDto();

            try
            {
                gameDto         gd     = null;
                GamesRepository _games = new GamesRepository();

                gameDto game = null;
                gd = await _games.GetGameDetail(gp.game.sn);

                gp.gamepost.edate   = gd.edate;
                gp.gamepost.sdate   = DateTime.Now;
                gp.gamepost.inpdate = DateTime.Now;
                gp.game.sdate       = DateTime.Now;
                gp.game.edate       = gd.gamedate;
                gp.game.gamedate    = gd.gamedate;

                for (int i = 0; i < gd.topicList.Count; i++)
                {
                    gp.game.topicList[i].sdate = gd.topicList[i].sdate;
                    gp.game.topicList[i].edate = gd.topicList[i].edate;
                }



                List <choiceDto> choice = new List <choiceDto>();
                foreach (topicDto t in gp.game.topicList)
                {
                    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;
                 *
                 * }*/

                SetWinnerReq swq = new SetWinnerReq();
                swq.UserID     = gp.game.userId;
                swq.comSn      = 1;
                swq.choiceList = choice;
                swq.gameSn     = gp.game.sn;
                swq.topicSn    = topicSn;
                //ajd = await _games.pays(sbr, game.betModel);
                ajd = await _games.setWinnerPay(swq);

                new SignalRHelper().UpdateTopic(gp.game, encryptedKey, gp.game.md5GameSn);

                // Return the URI of the created resource.
            }
            catch
            {
                ajd.isTrue    = false;
                ajd.ErrorCode = 500;
            }

            return(Json(ajd, JsonRequestBehavior.AllowGet));
        }
예제 #30
0
        public async System.Threading.Tasks.Task <JsonResult> LivePayData(int id)
        {
            ControllerContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            GamePosts gamepost = new GamePostsRepository().get(id);
            gameDto   game     = null;

            game = await new GamesRepository().GetGamePayDetail(gamepost.GameSn);

            List <VedioRecord> vrlist = new List <VedioRecord>();

            vrlist = new VedioRecordRepository().getAll();


            GamePostViewModel gpvm = new GamePostViewModel(id, encryptedKey, game);

            gpvm.gamepost = gamepost;
            List <Teams> teamlist = new TeamsRepository().getAll();

            gpvm.TeamA = teamlist.Where(p => p.sn == gamepost.TeamASn).FirstOrDefault();
            gpvm.TeamB = teamlist.Where(p => p.sn == gamepost.TeamBSn).FirstOrDefault();
            if (gpvm.gamepost.PlayGameSn.HasValue)
            {
                gpvm.PlayGame = new cfgPlayGameRepository().get(gpvm.gamepost.PlayGameSn.Value);
            }
            gpvm.vedio = vrlist.Where(p => p.sn == gpvm.gamepost.VedioRecordSn).FirstOrDefault();


            //VedioRecord movieclass_twitch_string = new VedioRecordRepository().getnew(gp.VedioRecordSn);
            //var movieclass_twitch = gpvm.vedio.vediourl.Substring(0, 21);
            //string movieclass_youtube = gpvm.vedio.vediourl.Substring(0, 23);
            if (gpvm.vedio == null)
            {
                gpvm.vedio_url = "";
            }
            else
            {
                string movieclass_twitch  = "";
                string movieclass_youtube = "";
                string movieclass_huya    = "";
                if (gpvm.vedio.vediourl.Length >= 22)
                {
                    movieclass_twitch = gpvm.vedio.vediourl.Substring(0, 22);
                }
                if (gpvm.vedio.vediourl.Length >= 24)
                {
                    movieclass_youtube = gpvm.vedio.vediourl.Substring(0, 24);
                }
                if (gpvm.vedio.vediourl.Length >= 21)
                {
                    movieclass_huya = gpvm.vedio.vediourl.Substring(0, 21);
                }

                if (movieclass_twitch == "https://www.twitch.tv/")
                {
                    gpvm.vedio_url = Regex.Replace(gpvm.vedio.vediourl, movieclass_twitch, String.Empty);
                    gpvm.vedio_url = "https://player.twitch.tv/?channel=" + gpvm.vedio_url;
                }
                else if (movieclass_youtube == "https://www.youtube.com/")
                {
                    int    vediolength   = gpvm.vedio.vediourl.Length - 32;
                    string regex_youtube = gpvm.vedio.vediourl.Substring(32, vediolength);
                    //regex_youtube = Regex.Replace(gpvm.vedio.vediourl, regex_youtube, String.Empty);
                    gpvm.vedio_url = "https://www.youtube.com/embed/" + regex_youtube;
                }
                else if (movieclass_huya == "https://www.huya.com/")
                {
                    gpvm.vedio_url = Regex.Replace(gpvm.vedio.vediourl, movieclass_huya, String.Empty);
                    gpvm.vedio_url = "http://liveshare.huya.com/iframe/" + gpvm.vedio_url;
                }
                else if (gpvm.vedio.cfgVedioSn == 5)
                {
                    gpvm.vedio_url = gpvm.vedio_url;
                }
                else
                {
                    gpvm.vedio_url = "";
                }
            }

            gpvm.recommend    = new UserRepository().getRecommendValid(gpvm.game.userId);
            gpvm.recommendstr = new UserRepository().getRecommendStartV((int)gpvm.recommend.ReId);

            return(Json(gpvm, JsonRequestBehavior.AllowGet));
        }