Example #1
0
        public void TemGol(string sUrl)
        {
            string text   = code(sUrl);
            int    num    = text.IndexOf("lista-de-jogos-item");
            int    length = text.Length - num;
            string text2  = text.Substring(num, length);

            num    = text2.IndexOf("lista-de-jogos-item");
            length = text2.IndexOf("aside");
            string text3 = text2.Substring(num, length);

            string[] separator = new string[]
            {
                "lista-de-jogos-item"
            };
            string[] array      = text3.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            string[] separator2 = new string[]
            {
                "content="
            };
            string[] separator3 = new string[]
            {
                "placar-jogo-informacoes-local"
            };
            string[] separator4 = new string[]
            {
                "placar-jogo-equipes-placar-mandante"
            };
            string[] separator5 = new string[]
            {
                "placar-jogo-equipes-placar-visitante"
            };
            string[] separator6 = new string[]
            {
                "placar-jogo-informacoes"
            };
            string[] separator7 = new string[]
            {
                "/span"
            };
            int num2 = 0;

            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text4 = array2[i];
                int    num3  = num2;
                num2 = num3 + 1;
                string[] array3 = text4.Split(separator2, StringSplitOptions.RemoveEmptyEntries);
                length = array3[3].IndexOf(">");
                string text5 = array3[3].Substring(0, length);
                length = array3[4].IndexOf(">");
                string   text6  = array3[4].Substring(0, length);
                string[] array4 = text4.Split(separator3, StringSplitOptions.RemoveEmptyEntries);
                length = array4[1].IndexOf("<");
                string   text7  = array4[1].Substring(1, length);
                string[] array5 = text4.Split(separator4, StringSplitOptions.RemoveEmptyEntries);
                length = array5[1].IndexOf("<");
                string   text8  = array5[1].Substring(1, length);
                string[] array6 = text4.Split(separator5, StringSplitOptions.RemoveEmptyEntries);
                length = array6[1].IndexOf("<");
                string   text9  = array6[1].Substring(1, length);
                string[] array7 = text4.Split(separator6, StringSplitOptions.RemoveEmptyEntries);
                length = array7[1].IndexOf("<");
                string   text10 = array7[1].Substring(1, length);
                string[] array8 = array7[2].Split(separator7, StringSplitOptions.RemoveEmptyEntries);
                length = array8[1].IndexOf("<");
                string text11 = array8[1].Substring(1, length);
                Jogo   jogo   = new Jogo();
                jogo.Idrodada        = 0;
                jogo.IdJogo          = num2;
                jogo.SiglaMandante   = BuscarSigla(text5.Replace(">", "").Replace('"', ' ').Replace("<", ""));
                jogo.SiglaVisitante  = BuscarSigla(text6.Replace(">", "").Replace('"', ' ').Replace("<", ""));
                jogo.PlacarMandante  = text8.Replace(">", "").Replace('"', ' ').Replace("<", "");
                jogo.PlacarVisitante = text9.Replace(">", "").Replace('"', ' ').Replace("<", "");
                bool flag = jogo.PlacarMandante.Trim().Equals("");
                if (flag)
                {
                    jogo.Status         = "A";
                    jogo.PlacarMandante = "0";
                }
                else
                {
                    jogo.Status = "E";
                }
                bool flag2 = jogo.PlacarVisitante.Trim().Equals("");
                if (flag2)
                {
                    jogo.PlacarVisitante = "0";
                }
                jogo.Datahora = text10.Replace(">", "").Replace('"', ' ').Replace("<", "") + "-" + text11.Replace(">", "").Replace('"', ' ').Replace("<", "");
                jogo.Local    = text7.Replace(">", "").Replace('"', ' ').Replace("<", "");
                Jogo jogo2 = new Jogo();
                jogo2.Idrodada        = jogo.Idrodada;
                jogo2.IdJogo          = jogo.IdJogo;
                jogo2.SiglaMandante   = jogo.SiglaMandante;
                jogo2.SiglaVisitante  = jogo.SiglaVisitante;
                jogo2.PlacarVisitante = jogo.PlacarVisitante;
                jogo2.PlacarMandante  = jogo.PlacarMandante;
                jogo2.Local           = jogo.Local;
                jogo2.Datahora        = jogo.Datahora;
                bool flag3 = jogo2.BuscarJogo();
                if (flag3)
                {
                    bool flag4 = !jogo2.PlacarMandante.Equals(jogo.PlacarMandante.ToString());
                    if (flag4)
                    {
                        string mensagem = new Notificacao
                        {
                            Tipo      = "GOL",
                            Descricao = "tem gol",
                            Info      = JsonConvert.SerializeObject(jogo, Formatting.Indented)
                        }.EnviarNotificacaoTodos();
                        Notificacao.EnviarEmail1("*****@*****.**", "Teve Gol BR2016", mensagem);
                        jogo.AtualizarJogo();
                    }
                    else
                    {
                        bool flag5 = !jogo2.PlacarVisitante.Equals(jogo.PlacarVisitante.ToString());
                        if (flag5)
                        {
                            string mensagem = new Notificacao
                            {
                                Tipo      = "GOL",
                                Descricao = "tem gol",
                                Info      = JsonConvert.SerializeObject(jogo, Formatting.Indented)
                            }.EnviarNotificacaoTodos();
                            Notificacao.EnviarEmail1("*****@*****.**", "Teve Gol BR2016", mensagem);
                            jogo.AtualizarJogo();
                        }
                    }
                }
                else
                {
                    jogo.InserirJogo();
                }
            }
        }