private void BindGrid() { Business.Boloes.Support.JogoUsuario jogoUsuario = new Business.Boloes.Support.JogoUsuario(base.UserName); Business.Campeonatos.Support.Campeonato campeonato = new BolaoNet.Business.Campeonatos.Support.Campeonato(base.UserName, CurrentCampeonato); //Se existir grupo e fases cadastrados para o campeonato if (this.cboFase.Text.Length > 0 && this.cboGrupo.Text.Length > 0) { List <Model.Campeonatos.CampeonatoClassificacao> list = (List <Model.Campeonatos.CampeonatoClassificacao>)jogoUsuario.LoadClassificacao( CurrentBolao, new BolaoNet.Model.Campeonatos.Fase(this.cboFase.Text), new BolaoNet.Model.Campeonatos.Grupo(this.cboGrupo.Text), new Framework.Security.Model.UserData(this.cboUsuarios.Text)); IList <Framework.DataServices.Model.EntityBaseData> listPosicoes = campeonato.SelectPosicoes( new BolaoNet.Model.Campeonatos.Fase(this.cboFase.Text), new BolaoNet.Model.Campeonatos.Grupo(this.cboGrupo.Text)); ViewState["listPosicoes"] = listPosicoes; ViewState["list"] = list; //Atribuindo os dados para a grid this.grdClassificacao.DataSource = list; this.grdClassificacao.DataBind(); } }
private void BindProximosJogos() { Business.Boloes.Support.JogoUsuario bo = new Business.Boloes.Support.JogoUsuario(base.UserName); IList <Framework.DataServices.Model.EntityBaseData> list = bo.LoadProximasApostas(base.UserName); this.grdJogos.DataSource = list; this.grdJogos.DataBind(); }
private void BindGrid() { Business.Boloes.IBusinessJogoUsuario business = new Business.Boloes.Support.JogoUsuario(base.UserName); IList <Framework.DataServices.Model.EntityBaseData> list = business.LoadSemAcertos(CurrentBolao); this.grdJogos.DataSource = list; this.grdJogos.DataBind(); ViewState["JogosSource"] = list; }
private void CreateUser(NPOI.SS.UserModel.Workbook wb, string user, Business.Boloes.Support.Bolao bolao) { NPOI.SS.UserModel.Sheet newSheet = wb.CloneSheet(0); Business.Boloes.Support.JogoUsuario jogo = new Business.Boloes.Support.JogoUsuario(_currentLogin); jogo.Bolao = bolao; IList <Framework.DataServices.Model.EntityBaseData> jogos = jogo.SelectAllByPeriod(bolao, user, 0, DateTime.MinValue, DateTime.MinValue, null, null, null, null); foreach (Model.Boloes.JogoUsuario jogoUser in jogos) { } }
private void BindGrid() { string max = ConfigurationManager.AppSettings["MaxAcertosDificeis"]; int total = 2; if (!string.IsNullOrEmpty(max)) { total = int.Parse(max); } Business.Boloes.IBusinessJogoUsuario business = new Business.Boloes.Support.JogoUsuario(base.UserName); IList <Framework.DataServices.Model.EntityBaseData> list = business.LoadAcertosDificeis(CurrentBolao, 2); this.grdJogos.DataSource = list; this.grdJogos.DataBind(); ViewState["JogosSource"] = list; }
private void livJogos_SelectedIndexChanged(object sender, EventArgs e) { this.lblJogo.Text = ""; if (this.livJogos.SelectedIndices.Count == 0) { return; } Business.Boloes.Support.JogoUsuario jogoUsuario = new Business.Boloes.Support.JogoUsuario(""); jogoUsuario.Bolao = new Model.Boloes.Bolao(this.cboBoloes.Text); int pos = this.livJogos.SelectedIndices[0]; IList <Framework.DataServices.Model.EntityBaseData> list = jogoUsuario.SelectAll("jogos.idjogo='" + this.livJogos.Items[pos].Text + "'"); this.lblJogo.Text = this.livJogos.Items[pos].SubItems[1].Text + " - " + this.livJogos.Items[pos].SubItems[2].Text + " " + this.livJogos.Items[pos].SubItems[3].Text + " " + " x " + this.livJogos.Items[pos].SubItems[4].Text + " " + this.livJogos.Items[pos].SubItems[5].Text; this.livJogosUsuarios.Items.Clear(); Model.Campeonatos.Jogo jogoMain = (Model.Campeonatos.Jogo) this.livJogos.Items[pos].Tag; foreach (Model.Boloes.JogoUsuario jogo in list) { ListViewItem jogoItem = new ListViewItem(jogo.IDJogo.ToString()); jogoItem.SubItems.Add(jogo.UserName); jogoItem.SubItems.Add(jogo.Time1.Nome); jogoItem.SubItems.Add(jogo.ApostaTime1.ToString()); jogoItem.SubItems.Add(jogo.ApostaTime2.ToString()); jogoItem.SubItems.Add(jogo.Time2.Nome); jogoItem.SubItems.Add(jogo.Pontos.ToString()); this.livJogosUsuarios.Items.Add(jogoItem); int atual = 0; int expected = 0; Log logTemp = CheckJogo(jogoMain, jogo, out atual, out expected); switch (logTemp) { case Log.Error: jogoItem.BackColor = Color.Red; break; case Log.Warning: jogoItem.BackColor = Color.Yellow; break; case Log.Info: jogoItem.BackColor = Color.LightGreen; break; } } }
private void btnStart_Click(object sender, EventArgs e) { this.livLog.Items.Clear(); this.livClassificacao.Items.Clear(); this.livJogos.Items.Clear(); this.livJogosUsuarios.Items.Clear(); IList <ClassificacaoUsuario> compareList = new List <ClassificacaoUsuario>(); BolaoNet.Business.Boloes.Support.Bolao bolao = new Business.Boloes.Support.Bolao(""); bolao.Nome = this.cboBoloes.Text; bolao.Load(); Business.Campeonatos.Support.Campeonato campeonato = new Business.Campeonatos.Support.Campeonato("", bolao.Campeonato); Business.Boloes.Support.JogoUsuario jogosUsuario = new Business.Boloes.Support.JogoUsuario(""); jogosUsuario.Bolao = bolao; IList <Framework.DataServices.Model.EntityBaseData> jogos = campeonato.LoadJogos(0, null, null, DateTime.MinValue, DateTime.MinValue, null); IList <Model.Boloes.Reports.UserPontosData> pontuacao = new List <Model.Boloes.Reports.UserPontosData>(); _jogoUsuario.Clear(); this.pgbPartial.Value = 0; this.pgbPartial.Maximum = jogos.Count; foreach (Model.Campeonatos.Jogo jogo in jogos) { ListViewItem jogoItem = new ListViewItem(jogo.IDJogo.ToString()); jogoItem.SubItems.Add(jogo.DataJogo.ToString("dd/MM")); jogoItem.SubItems.Add(jogo.Time1.Nome); jogoItem.SubItems.Add(jogo.GolsTime1.ToString()); jogoItem.SubItems.Add(jogo.GolsTime1.ToString()); jogoItem.SubItems.Add(jogo.Time2.Nome); jogoItem.SubItems.Add(jogo.PartidaValida.ToString()); jogoItem.Tag = jogo; this.livJogos.Items.Add(jogoItem); IList <Framework.DataServices.Model.EntityBaseData> jogosUsu = jogosUsuario.LoadApostasByJogo(bolao, jogo, ""); Log logJogo = Log.Info; foreach (Model.Boloes.JogoUsuario jogoUsuario in jogosUsu) { int atual = 0; int expected = 0; Log logTemp = CheckJogo(jogo, jogoUsuario, out atual, out expected); switch (logTemp) { case Log.Error: logJogo = Log.Error; ListViewItem log = new ListViewItem(jogo.IDJogo.ToString()); log.SubItems.Add(jogo.Time1.Nome + " x " + jogo.Time2.Nome); log.SubItems.Add(jogoUsuario.UserName); log.SubItems.Add(atual.ToString()); log.SubItems.Add(expected.ToString()); this.livLog.Items.Add(log); break; case Log.Warning: if (logJogo == Log.Info) { logJogo = Log.Warning; } break; } int posCompare = -1; for (int c = 0; c < compareList.Count; c++) { if (string.Compare(compareList[c].Usuario, jogoUsuario.UserName, true) == 0) { posCompare = c; break; } } if (posCompare == -1) { compareList.Add(new ClassificacaoUsuario()); compareList[compareList.Count - 1].Usuario = jogoUsuario.UserName; posCompare = compareList.Count - 1; } compareList[posCompare].Pontos += jogoUsuario.Pontos; } switch (logJogo) { case Log.Error: this.livJogos.Items[this.livJogos.Items.Count - 1].BackColor = Color.Red; break; case Log.Warning: this.livJogos.Items[this.livJogos.Items.Count - 1].BackColor = Color.Yellow; break; case Log.Info: this.livJogos.Items[this.livJogos.Items.Count - 1].BackColor = Color.LightGreen; break; } this.pgbPartial.Value++; this.pgbPartial.Show(); } IList <Model.Boloes.BolaoMembros> classificacao = bolao.LoadClassificacao(0); IList <Framework.DataServices.Model.EntityBaseData> listPosicoes = bolao.SelectPremios(); foreach (Model.Boloes.BolaoMembros pont in classificacao) { ListViewItem pontos = new ListViewItem(pont.Posicao.ToString()); pontos.SubItems.Add(pont.UserName); pontos.SubItems.Add(pont.TotalPontos.ToString()); foreach (Model.Boloes.BolaoPremio premio in listPosicoes) { if (premio.Posicao == pont.Posicao) { pontos.BackColor = premio.BackColor; pontos.ForeColor = premio.ForeColor; } } int total = 0; for (int c = 0; c < compareList.Count; c++) { if (string.Compare(compareList[c].Usuario, pont.UserName, true) == 0) { total = pont.TotalPontos - compareList[c].Pontos; break; } } pontos.SubItems.Add(total.ToString()); this.livClassificacao.Items.Add(pontos); } }
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"); }