Exemplo n.º 1
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         LiveBroadcastRepository liveBroadcastRepository = new LiveBroadcastRepository();
         LiveBroadcast           stream = ParseStream();
         liveBroadcastRepository.Insert(stream);
         RedirectToStreamList(stream.ID);
     }
     catch (Exception ex)
     {
         displayError(ex.Message);
     }
 }
        protected void btnDelete_OnClick(object sender, EventArgs e)
        {
            string streamID = lblID.Text.Trim();
            LiveBroadcastRepository liveBroadcastRepository = new LiveBroadcastRepository();
            LiveBroadcast           lb = liveBroadcastRepository.Get(streamID);

            if (lb != null)
            {
                try
                {
                    liveBroadcastRepository.Delete(ParseStream());
                }
                catch (Exception ex)
                {
                    displayError(ex.Message);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Get the stream ID and attempt to load it

                if (!string.IsNullOrEmpty(Request.QueryString["i"]))
                {
                    string streamID = Request.QueryString["i"].ToString();
                    LiveBroadcastRepository liveBroadcastRepository = new LiveBroadcastRepository();
                    LiveBroadcast           lb = liveBroadcastRepository.Get(streamID);

                    if (lb != null)
                    {
                        DisplayStream(lb);
                    }
                    else
                    {
                        displayError("A stream with that ID was not found.");
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LiveBroadcastRepository liveBroadcastRepository = new LiveBroadcastRepository();
                List <LiveBroadcast>    AllLiveBroadcasts       = liveBroadcastRepository.GetAll();

                // See if we should highlight one (that would have been just added)
                string HighLightID = string.Empty;

                if (Request.QueryString["highlight"] != null)
                {
                    HighLightID = Request.QueryString["highlight"].ToString().Trim();
                }

                foreach (LiveBroadcast stream in AllLiveBroadcasts.OrderByDescending(l => l.IsLive).ThenByDescending(l => l.StartTime))
                {
                    bool highlight = (HighLightID != string.Empty) && (HighLightID == stream.ID);

                    tblStreams.Rows.Add(addBroadcastTableRow(stream, highlight));
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            VideoRepository         videoRepository         = new VideoRepository();
            LiveBroadcastRepository liveBroadcastRepository = new LiveBroadcastRepository();

            // Determine if the user can access private videos
            bool includePrivateContent = false;

            List <Video>         NewestVideos         = videoRepository.GetNewest(includePrivateContent, 60);
            List <Video>         FeaturedVideos       = videoRepository.GetFeatured(includePrivateContent);
            List <LiveBroadcast> UpcomingStreams      = liveBroadcastRepository.GetUpcoming();
            List <LiveBroadcast> CurrentlyLiveStreams = liveBroadcastRepository.GetLive();

            // Display live streams currently broadcasting
            if (CurrentlyLiveStreams.Count > 0)
            {
                if (CurrentlyLiveStreams.Count == 1)
                {
                    if (CurrentlyLiveStreams.First().EmbedInsteadOfLink)
                    {
                        litPlayer.Visible     = true;
                        litStreamInfo.Visible = true;

                        litPlayer.Text     = YoutubeLiveBroadcastPlayer.GetHTML(CurrentlyLiveStreams.First());
                        litStreamInfo.Text = buildLiveStreamInfoHTML(CurrentlyLiveStreams.First());
                    }
                    else
                    {
                        litLiveStreams.Visible = true;
                        litLiveStreams.Text    = showMultipleLiveStreams(CurrentlyLiveStreams);
                    }
                }
                else
                {
                    litLiveStreams.Visible = true;
                    litLiveStreams.Text    = showMultipleLiveStreams(CurrentlyLiveStreams);
                }
            }
            else
            {
                litPlayer.Visible      = false;
                litStreamInfo.Visible  = false;
                litLiveStreams.Visible = false;
            }


            // Display upcoming streams
            if (UpcomingStreams.Count > 0)
            {
                title_upcoming.Visible     = true;
                litUpcomingStreams.Visible = true;
                litUpcomingStreams.Text    = upcomingStreamsSection(UpcomingStreams);
            }
            else
            {
                title_upcoming.Visible     = false;
                litUpcomingStreams.Visible = false;
            }

            // Display newest videos (if any exist)
            if (NewestVideos.Count > 0)
            {
                litNewestVideos.Visible = true;
                litNewestVideos.Text    = newestVideosSection(NewestVideos);
            }
            else
            {
                litNewestVideos.Visible = false;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["i"]))
            {
                // Sanitize the video ID
                string requestedID = Sanitizers.SanitizeQueryStringID(Request.QueryString["i"]);

                // See if this video exists
                LiveBroadcastRepository liveBroadcastRepository = new LiveBroadcastRepository();
                LiveBroadcast           liveStream = liveBroadcastRepository.Get(requestedID);

                if (liveStream != null)
                {
                    // Determine if the viewer is viewing from inside the network
                    string clientIP = Request.ServerVariables["REMOTE_ADDR"];
                    bool   canUserAccessPrivateContent = Config.CanAccessPrivate(clientIP);

                    // Set the page title
                    string originalTitle = Page.Header.Title;
                    Page.Header.Title = liveStream.Name + " - " + originalTitle;

                    if (liveStream.IsEnded && !liveStream.ForcedLive)
                    {
                        displayError("This live stream has ended.");
                    }
                    else
                    {
                        if (
                            ((liveStream.IsPrivate) && (canUserAccessPrivateContent)) ||
                            (!liveStream.IsPrivate))
                        {
                            tblContainer.Visible = true;
                            if (liveStream.EmbedInsteadOfLink)
                            {
                                litPlayer.Text = YoutubeLiveBroadcastPlayer.GetHTML(liveStream);
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(liveStream.YouTubeID))
                                {
                                    Response.Redirect(@"https://www.youtube.com/watch?v=" + liveStream.YouTubeID);
                                }
                                else
                                {
                                    displayError("Live stream has no Youtube ID set");
                                }
                            }

                            litStreamInfo.Text = streamInfoBox(liveStream);
                        }
                        else
                        {
                            displayError("This live stream is marked as private. You can only watch from within the LSKYSD network.");
                        }
                    }
                }
                else
                {
                    displayError("A live stream with that ID does not exist.");
                }
            }
            else
            {
                displayError("Stream ID not specified.");
            }
        }