public StringBuilder GetChannels()
 {
     StringBuilder JSONResponse = new StringBuilder();
     DA_Streams daStreams = new DA_Streams();
     List<Channels> channels= daStreams.GetChannelObjects();
     JSONResponse.Append(JsonConvert.SerializeObject(channels));
     return JSONResponse;
 }
 public StringBuilder GetStreams()
 {
     StringBuilder JSONResponse = new StringBuilder();
     DA_Streams daStreams = new DA_Streams();
     List<TwitchStuff> streams = daStreams.GetStreamObjects(String.Format("#{0}", Request["channel"].ToString()));
     var streamVariable = streams.OrderBy(x => Convert.ToInt32(x.streamerviewcount));
     JSONResponse.Append(JsonConvert.SerializeObject(streamVariable));
     return JSONResponse;
 }
Beispiel #3
0
    public void rptChannelStreams_Bind(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Channels twitchChannel = ((Channels)e.Item.DataItem);
            Repeater rptStreams = (Repeater)e.Item.FindControl("rptStreams");
            HtmlControl genericDiv = (HtmlControl)e.Item.FindControl("individualstreamdiv");

            //LinkButton navLink = (LinkButton)sender;
            DA_Streams daStreams = new DA_Streams();
            //DataTable dtStreams = daStreams.GetStreams(navLink.CommandArgument);
            List<TwitchStuff> twitchInfo = daStreams.GetStreamObjects(twitchChannel.ChannelName);
            genericDiv.Attributes.Add("class", "ChannelStreams streamsfor" + twitchChannel.ChannelID);
            if (Request["channel"] != null)
            {
                if (("#" + Request["channel"].ToString()) == twitchChannel.ChannelName)
                {

                }
                else
                {
                    genericDiv.Attributes.Add("style", "display:none;");
                }
            }
            else
            {
                genericDiv.Attributes.Add("style", "display:none;");
            }

            rptStreams.DataSource = twitchInfo;
            rptStreams.DataBind();
            HtmlControl offlineDiv = (HtmlControl)e.Item.FindControl("OfflineStreamers");
            Label channelname = (Label)e.Item.FindControl("lblchannelName");
            channelname.Text = twitchChannel.ChannelName;
            if (OfflineStreamers.ContainsKey(twitchChannel.ChannelName)) {
                if (OfflineStreamers[twitchChannel.ChannelName].Count != 0 && OfflineStreamers[twitchChannel.ChannelName] != null)
                {
                    string msg = "<h3>The following users are offline:</h3><div class='writeOffline" + twitchChannel.ChannelID + "'>" + String.Join(", ", OfflineStreamers[twitchChannel.ChannelName]) + "</div>";
                    LiteralControl displaymsg = new LiteralControl(msg);
                    offlineDiv.Controls.Add(displaymsg);
                }
            }
        }
    }
Beispiel #4
0
 public void rptChannels_Bind(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         Channels twitchChannel = ((Channels)e.Item.DataItem);
         HtmlAnchor linkNav = (HtmlAnchor)e.Item.FindControl("linkNavigateChannel");
         linkNav.InnerText = twitchChannel.ChannelName;
         linkNav.Attributes.Add("onclick","$('.ChannelStreams').hide();$('.streamsfor" + twitchChannel.ChannelID + "').fadeToggle();");
         linkNav.Attributes["class"] = "Channel" + twitchChannel.ChannelName.Replace("#", "");
         DA_Streams daStreams = new DA_Streams();
         //DataTable dtStreams = daStreams.GetStreams(navLink.CommandArgument);
         List<TwitchStuff> twitchInfo = daStreams.GetStreamObjects(twitchChannel.ChannelName);
         if (twitchInfo.Count == 0)
         {
             linkNav.Visible = false;
         }
         if (!OfflineStreamers.ContainsKey(twitchChannel.ChannelName))
         {
             OfflineStreamers.Add(twitchChannel.ChannelName, new List<string>());
         }
     }
 }
Beispiel #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     DateTime dtStart = DateTime.Now;
     DA_Streams daStreams = new DA_Streams();
     List<Channels> ChannelList = daStreams.GetChannelObjects();
     rptChannels.DataSource = ChannelList;
     rptChannels.DataBind();
     litChannelCount.Text = ChannelList.Count.ToString();
     rptChannelStreams.DataSource = ChannelList;
     rptChannelStreams.DataBind();
     DateTime dtEnd = DateTime.Now;
     DataTable streamList = daStreams.GetStreams();
     litStreamWatches.Text = streamList.Rows.Count.ToString();
     List<TwitchStuff> fullList = TwitchStuff.ConvertDataTableNoChannel(streamList);
     var o = from twitchstuff in fullList
             where twitchstuff.streamerlive == "true"
             select twitchstuff;
     litStreamersLive.Text = o.Count().ToString();
     litViewerCount.Text = daStreams.GetViewers().ToString();
     if (Request["stream"] != null)
     {
         String scriptText = "";
         scriptText += "$(document).ready(function() {";
         scriptText += "UpdateStreamInfo('" + Request["stream"] + "');";
         scriptText += "});";
         Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"StartStream", scriptText, true);
     }
     TimeSpan renderTime = dtEnd - dtStart;
     litPageRender.Text = renderTime.TotalSeconds.ToString() + " seconds";
 }