Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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");
        }