private void BindNextJogo() { Business.Campeonatos.Support.Jogo jogo = new Business.Campeonatos.Support.Jogo(UserBasePage.CurrentUserName); int result = jogo.NextJogo(CampeonatoUserBasePage.CurrentCampeonato); this.lblDias.Text = result.ToString(); }
private void BindGrid() { IList <Framework.DataServices.Model.EntityBaseData> list = new List <Framework.DataServices.Model.EntityBaseData>(); //Criando a classe de business Business.Campeonatos.Support.Jogo business = new Business.Campeonatos.Support.Jogo(base.UserName); Model.DadosBasicos.Time time = new Model.DadosBasicos.Time(this.cboTime.Text); list = business.SelectJogosByTime(CurrentCampeonato, time, null, null); this.grdJogos.DataSource = list; this.grdJogos.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { this.JogoDetail.JogoMode = WebSite.Controls.JogoDetail.Mode.Result; if (!IsPostBack) { Business.Campeonatos.Support.Jogo business = new Business.Campeonatos.Support.Jogo(base.UserName); business.Campeonato = CurrentCampeonato; //Se encontrou valor para o ID do jogo if (Request.QueryString["IDJogo"] != null) { //this.JogoDetail.LoadJogo(Convert.ToInt64 (Request.QueryString["IDJogo"])); business.IDJogo = Convert.ToInt64(Request.QueryString["IDJogo"].ToString()); }//endif encointrou o id do jogo business.Load(); this.JogoDetail.Jogo = business; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Business.Campeonatos.Support.Jogo jogo = null; //Se estiver passando o id do jogo if (Request.QueryString["IDJogo"] != null) { long idJogo = Convert.ToInt64(Request.QueryString["IDJogo"].ToString()); jogo = new BolaoNet.Business.Campeonatos.Support.Jogo(base.UserName); jogo.Campeonato = CurrentCampeonato; jogo.IDJogo = idJogo; jogo.Load(); this.ctlJogoDetail.Jogo = jogo; if (jogo.PartidaValida) { Model.Boloes.JogoUsuario social = new Business.Boloes.Support.JogoUsuario(base.UserName).LoadSocialNetwork(base.BaseCurrentBolao, base.UserName, jogo); if (social.DataFacebook == DateTime.MinValue) { this.ctlMenuTools.FaceVisible = true; } } }//endif passando id do jogo //Adicionando os dados do facebook if (Request["code"] != null) { Model.Boloes.JogoUsuario jogoUsuario = new Model.Boloes.JogoUsuario(); jogoUsuario.Copy(jogo); jogoUsuario.Bolao = base.BaseCurrentBolao; jogoUsuario.UserName = base.UserName; IList <Framework.DataServices.Model.EntityBaseData> res = new Business.Boloes.Support.JogoUsuario(base.UserName, jogoUsuario).SelectAll("JogosUsuarios.IdJogo='" + jogo.IDJogo + "' and JogosUsuarios.UserName='******'"); jogoUsuario = (Model.Boloes.JogoUsuario)res[0]; string message = ""; string caption = "Resultado: " + jogo.Time1.Nome + " " + jogo.GolsTime1.ToString() + " x " + jogo.GolsTime2.ToString() + " " + jogo.Time2.Nome; string description = "Minha Aposta: " + jogo.Time1.Nome + " " + jogoUsuario.ApostaTime1.ToString() + " x " + jogoUsuario.ApostaTime2.ToString() + " " + jogo.Time2.Nome + " - Pontos: " + jogoUsuario.Pontos; string imagePontos = ""; message = ConfigurationManager.AppSettings["Facebook_Pontos_" + jogoUsuario.Pontos.ToString()]; imagePontos = ConfigurationManager.AppSettings["Facebook_images"] + "pontos" + jogoUsuario.Pontos + ".gif"; if (jogoUsuario.Pontos == 10 && (string.Compare(jogo.Time1.Nome, "Brasil", true) == 0 || string.Compare(jogo.Time2.Nome, "Brasil", true) == 0)) { message = ConfigurationManager.AppSettings["Facebook_Pontos_10_Brasil"]; imagePontos = ConfigurationManager.AppSettings["Facebook_images"] + "pontos" + jogoUsuario.Pontos + "_Brasil.gif"; } if (string.IsNullOrEmpty(message)) { switch (jogoUsuario.Pontos) { case 0: message = "Não tive sorte neste jogo, que zebra, não acertei nada!"; break; case 1: message = "Consegui acertar pelo menos o gol de uma das duas seleções."; break; case 2: message = "Que chance eu perdi...pelo menos acertei o gol de uma das duas seleções"; break; case 3: message = "Acertei o ganhador do jogo!"; break; case 4: message = "Quase, acertei a vitória de uma das seleções e o gol de uma delas!"; break; case 5: message = "Resultado difícil, mas acertei o empate!"; break; case 6: message = "Já que é jogo do Brasil, consegui acertar a vitória da seleção."; break; case 8: message = "Quase em cheio! Acertei a vitória da seleção e quantidade de gols de uma delas! Mas como é jogo do Brasil, perdi uma chance boa!"; break; case 10: if (string.Compare(jogo.Time1.Nome, "Brasil") == 0 || string.Compare(jogo.Time2.Nome, "Brasil") == 0) { message = "Jogo do Brasil é sempre difícil, ainda mais quando ocorre empate."; } else { message = "Na mosca! Muito fácil ... rs"; } break; case 20: message = "No jogo do Brasil é melhor ainda, consegui acertar em cheio!!!"; break; } } Dictionary <string, string> tokens = new Dictionary <string, string>(); string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}", _applicationKey, Request.Url.AbsoluteUri, _scope, Request["code"].ToString(), _applicationSecret); HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(response.GetResponseStream()); string vals = reader.ReadToEnd(); foreach (string token in vals.Split('&')) { //meh.aspx?token1=steve&token2=jake&... tokens.Add(token.Substring(0, token.IndexOf("=")), token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1)); } } string access_token = tokens["access_token"]; var client = new FacebookClient(access_token); string originalQuery = "/Boloes/ApostasJogos.aspx?IdJogo=" + Request.QueryString["IDJogo"].ToString(); var postParams = new { name = "BolãoNET", caption = caption, description = description, message = message, link = Request.Url.Host + originalQuery, picture = imagePontos, }; object resultFacebook = client.Post("/me/feed", postParams); bool result = new Business.Boloes.Support.JogoUsuario(base.UserName).UpdateFacebook(base.BaseCurrentBolao, base.UserName, jogo); Response.Redirect("~" + originalQuery); } //endif code (Facebook) } //end if IsPostBack BindGrid(); }
public void Run(string nomeBolao) { string currentUserName = "******"; //Criando os dados do excel na memória excel.CreateWorksheet("Estatistica"); //Criando as instâncias dos BO Business.Boloes.Support.Bolao bolao = new Business.Boloes.Support.Bolao(currentUserName, nomeBolao); Business.Campeonatos.Support.Jogo boJogo = new Business.Campeonatos.Support.Jogo(currentUserName); Business.Boloes.Support.JogoUsuario boJogosUsuarios = new Business.Boloes.Support.JogoUsuario(currentUserName); Business.Boloes.Support.ApostaExtraUsuario boApostaExtra = new Business.Boloes.Support.ApostaExtraUsuario(currentUserName); boApostaExtra.Bolao = bolao; //Carregando os dados principais do bolão bolao.Load(); //Indicando qual campeonato é o jogo boJogo.Campeonato = bolao.Campeonato; boJogosUsuarios.Bolao = bolao; //Carregando a classificação IList <BolaoNet.Model.Boloes.BolaoMembros> membros = bolao.LoadClassificacao(0); //Buscando o jogo de disputa de 3 e 4 IList <Framework.DataServices.Model.EntityBaseData> jogosFound = boJogo.SelectAll("NomeFase = 'Final' AND PendenteTime1Ganhador = 0"); //Identificando o jogo do 3 e 4 lugar Model.Campeonatos.Jogo jogoFimPerdedor = (Model.Campeonatos.Jogo)jogosFound[0]; //Buscando o 1 e 2 lugar jogosFound = boJogo.SelectAll("NomeFase = 'Final' AND PendenteTime1Ganhador = 1"); //Atribuindo o 1 e 2 lugar Model.Campeonatos.Jogo jogoFimCampeao = (Model.Campeonatos.Jogo)jogosFound[0]; //Buscando as apostas do usuário de disputa de 3 e 4 lugar IList <Framework.DataServices.Model.EntityBaseData> listJogos = boJogosUsuarios.LoadApostasByJogo(bolao, jogoFimPerdedor, null); //Buscando as apostas extras dos usuários IList <Framework.DataServices.Model.EntityBaseData> listApostasExtras = boApostaExtra.SelectAll(null); excel.SetValue(PosLineStart - 1, 0, "Gols Time 1"); excel.SetValue(PosLineStart - 1, 1, "Gols Time 2"); excel.SetValue(PosLineStart - 1, 2, "Desempate, 0 = Time 1"); for (int c = 0; c < membros.Count; c++) { excel.SetValue(PosLineStart - 1, PosStartName + (c * 4), membros[c].UserName); excel.SetNumber(PosLineStart - 1, PosStartName + 1 + (c * 4), membros[c].TotalPontos); //excel.SetNumber(PosLineStart - 1, PosStartName + 2 + (c * 3), 0); } int currentLine = PosLineStart; ApplyLine(currentLine++, _golsTime1, _golsTime2, _ganhador, 3, 4, ref membros, listJogos, listApostasExtras, false); currentLine += 2; listJogos = boJogosUsuarios.LoadApostasByJogo(bolao, jogoFimCampeao, null); //Empate ApplyLine(currentLine++, 0, 0, 1, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 0, 0, 2, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 1, 1, 1, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 1, 1, 2, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 2, 2, 1, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 2, 2, 2, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 3, 3, 1, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 3, 3, 2, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 4, 4, 1, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 4, 4, 2, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 5, 5, 1, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 5, 5, 2, 1, 2, ref membros, listJogos, listApostasExtras, true); //Ganhador 2 ApplyLine(currentLine++, 0, 1, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 0, 2, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 0, 3, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 0, 4, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 0, 5, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 1, 2, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 1, 3, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 1, 4, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 1, 5, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 2, 3, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 2, 4, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 2, 5, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 3, 4, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 3, 5, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 4, 5, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); //Ganhador 1 ApplyLine(currentLine++, 1, 0, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 2, 0, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 3, 0, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 4, 0, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 5, 0, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 2, 1, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 3, 1, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 4, 1, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 5, 1, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 3, 2, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 4, 2, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 5, 2, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 4, 3, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 5, 3, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); ApplyLine(currentLine++, 5, 4, 0, 1, 2, ref membros, listJogos, listApostasExtras, true); if (System.IO.File.Exists(".\\Excel.xls")) { System.IO.File.Delete(".\\Excel.xls"); } excel.SaveFile(".\\Excel.xls"); }