示例#1
0
        private Video LocalizaVideo()
        {
            Loga("LocalizaVideo");
            Video Esse  = new Video();
            int   posDI = ConteudoPagCanal.IndexOf("Duração:") + 9;

            if (posDI == -1)
            {
                // Não há mais vídeos neste canal
                // Passar para o próximo
                int x = 0;
            }
            else
            {
                // Passar para SÓ "visualizações"
                int posPostI = ConteudoPagCanal.IndexOf("visualizações");
                // int posPostI = ConteudoPagCanal.IndexOf("visualizações</li><li>");

                if (posPostI > 0)
                {
                    // VERIFICAR AQUI
                    // EXEMPLO CORRETO: "9 horas atrás"
                    int    postPosF = ConteudoPagCanal.IndexOf("</li></ul>", posPostI);
                    string PedPost  = ConteudoPagCanal.Substring(posPostI + 22, postPosF - posPostI - 22);
                    Esse.setPostado(PedPost);
                    Loga("Video postado em " + Esse.Postado.ToShortDateString() + " " + Esse.Postado.ToShortTimeString());

                    int    posDF  = ConteudoPagCanal.IndexOf(".", posDI);
                    string PedDur = ConteudoPagCanal.Substring(posDI, posDF - posDI);
                    Esse.setsDuracao(PedDur);

                    int posEndI = ConteudoPagCanal.IndexOf("data-context-item-id=");
                    int posEndF = ConteudoPagCanal.IndexOf("data-visibility-tracking", posEndI);
                    Esse.EnderVideo = ConteudoPagCanal.Substring(posEndI + 22, posEndF - posEndI - 30);

                    ConteudoPagCanal = ConteudoPagCanal.Substring(postPosF + 10);
                }
                else
                {
                    Loga("PASSAR PARA O PRÓXIMO CANAL");
                    // ACABOU O CANAL
                    // PASSAR PARA O PRÓXIMO
                    Status         = tStatus.ProxCanal;
                    timer1.Enabled = false;
                    AuxTempo       = 0;
                    IndiceCanal++;
                    IndiceVideo = 0;
                    MostrarCanal();
                    Esse.Duracao = -1;
                }
            }
            return(Esse);
        }
示例#2
0
        private void TocaVideo(Video Esse)
        {
            PagAtual = "https://www.youtube.com/watch?v=" + Esse.EnderVideo;

            /* if (PagAtual== "https://www.youtube.com/watch?v=7IU222pEcnE")
             * {
             *  int x = 0;
             * } */

            Loga("Carregando vídeo " + PagAtual);
            webBrowser1.Navigate(PagAtual);
            Status = tStatus.CarregandoVideo;

            Loga("Tempo do vídeo em segundos: " + Esse.Duracao.ToString());
            TmpVideo = Esse.Duracao;
        }
示例#3
0
        private void MostrarCanal()
        {
            Loga("MostrarCanal");
            string Canal = dsResultado.Tables[0].Rows[IndiceCanal][colEndereco].ToString();
            string sData = dsResultado.Tables[0].Rows[IndiceCanal][colData].ToString();

            if (sData == "")
            {
                UltVis = new DateTime(2000, 1, 1);
            }
            else
            {
                UltVis = Convert.ToDateTime(sData);
            }

            PagAtual = Canal;
            Status   = tStatus.Canal;
            webBrowser1.Navigate(Canal);

            /* PagAtual = Canal + @"/videos";
             * webBrowser1.Navigate(PagAtual); */
        }
        public ActionResult cnfrm()
        {
            passenger p = new passenger();

            p.passnegerName = Convert.ToString(Session["name"]);
            dc.passengers.InsertOnSubmit(p);
            dc.SubmitChanges();
            Session["pid"] = p.passengerId;
            var id = Convert.ToString(Session["id"]);

            tStatus s = dc.tStatus.First(std => std.trainId == id);

            var    clss = Convert.ToString(Session["class"]);
            ticket t    = new ticket();

            if (clss == "businessSeats")
            {
                s.businessSeats -= 1;
                t.ticketClass    = "Business";
            }
            else
            {
                s.economySeats -= 1;
                t.ticketClass   = "Economy";
            }

            dc.SubmitChanges();

            t.trainId     = id;
            t.passengerId = p.passengerId;
            t.ticketPrice = (int)Session["price"];
            dc.tickets.InsertOnSubmit(t);
            dc.SubmitChanges();

            return(RedirectToAction("csst", t));
        }
示例#5
0
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            Loga("webBrowser1_DocumentCompleted");
            Loga("Status " + Status);
            Loga("PagAtual " + PagAtual);
            Loga("AbsoluteUri " + e.Url.AbsoluteUri);
            Loga(" ");

            if (this.Text != webBrowser1.DocumentTitle)
            {
                this.Text = webBrowser1.DocumentTitle;
                Loga(this.Text);
            }
            switch (Status)
            {
            case tStatus.Canal:
                if (e.Url.AbsoluteUri == PagAtual)
                {
                    if (IndiceVideo == 0)
                    {
                        ConteudoPagCanal = webBrowser1.DocumentText;
                        iniCanais        = ConteudoPagCanal.IndexOf("yt-lockup-content");
                    }
                    CriterioVideo();
                    IndiceVideo++;
                    Loga("Video nr " + IndiceVideo.ToString());
                }
                break;

            case tStatus.CarregandoVideo:
                if (e.Url.AbsoluteUri != "about:blank")
                {
                    if (e.Url.AbsoluteUri != PagAtual)
                    {
                        if (e.Url.AbsoluteUri.IndexOf("google") < 0)
                        {
                            // A princípio não da ver se o vídeo terminou
                            // acho que o ideal seria colocar um temporizador
                            // mas se colocar, não iria funcionar, caso for parado ou adiantado o vídeo


                            // Chegou até aqui porque terminou o video e foi pro próximo
                            // Verificar
                            // 1) Se já não foi visto
                            // 2) Se o vídeo é muito grande ou não
                            CriterioVideo();
                        }
                    }
                    else
                    {
                        Status = tStatus.AMostrarOVideo;
                    }
                }
                break;

            case tStatus.AMostrarOVideo:
                HoraFim        = DateTime.Now.AddSeconds(TmpVideo);
                timer1.Enabled = true;
                Status         = tStatus.MostrandoVideo;
                Loga("Status = MostrandoVideo");
                break;

            default:
                break;
            }
        }