Exemple #1
0
        /// <summary>
        /// FindChannel Click event
        /// </summary>
        /// <param name="sender">What raised the event</param>
        /// <param name="e">Event arguments</param>
        protected void FindChannel_Click(object sender, EventArgs e)
        {
            string url = "http://api.rovicorp.com/TVlistings/v9/listings/gridschedule/{0}/info?apikey={1}&sig=sig&locale=en-US&duration=240&format=json";

            url = string.Format(url, ServiceProviders.SelectedValue, this.ApiKey.Text);

            GridScheduleObject shows = this.GetGridSchedule(url);

            this.PopulateGridSchedule(shows);
        }
Exemple #2
0
        /// <summary>
        /// Gets the grid schedule
        /// </summary>
        /// <param name="url">Grid schedule URL</param>
        /// <returns>List of shows</returns>
        private GridScheduleObject GetGridSchedule(string url)
        {
            GridScheduleObject shows  = null;
            object             cached = Cache[url];

            if (cached == null)
            {
                HttpWebResponse webResponse;
                string          response = this.GetResponse(url, out webResponse);
                if (this.HandleResponse(webResponse, response, this.FindChannelError))
                {
                    shows = this.Deserialize <GridScheduleObject>(response);
                    Cache.Insert(url, shows, null, DateTime.Now.AddDays(7), System.Web.Caching.Cache.NoSlidingExpiration);
                }
            }
            else
            {
                shows = cached as GridScheduleObject;
            }

            return(shows);
        }
Exemple #3
0
        /// <summary>
        /// Populates the grid schedule
        /// </summary>
        /// <param name="shows">List of shows</param>
        private void PopulateGridSchedule(GridScheduleObject shows)
        {
            FindChannelError.Visible = false;

            // Find any shows matching the show name query
            var query = from c in shows.GridScheduleResult.GridChannels
                        from a in c.Airings
                        where a.Title.IndexOf(ShowName.Text, StringComparison.OrdinalIgnoreCase) != -1
                        select new { Channel = c, Airing = a };

            if (query.Any())
            {
                ResultsPanel.Visible = true;

                // Save the client cookie to the request
                HttpCookie cookie = Request.Cookies["SelectedServiceId"];
                if (cookie != null)
                {
                    Response.Cookies.Add(new HttpCookie("SelectedServiceId", cookie.Value)
                    {
                        Expires = DateTime.MaxValue
                    });
                }
            }
            else
            {
                ResultsPanel.Visible = false;
            }

            int count = 0;

            foreach (var x in query)
            {
                // Parse out the air time
                DateTime parsedDate = DateTime.MinValue;
                if (DateTime.TryParse(x.Airing.AiringTime, out parsedDate))
                {
                    DateTime.SpecifyKind(parsedDate, DateTimeKind.Utc);
                    parsedDate = parsedDate.ToLocalTime();
                }

                // Create the row
                TableRow row = new TableRow();
                row.Cells.AddRange(new TableCell[]
                {
                    new TableCell()
                    {
                        Text = x.Channel.Channel
                    },
                    new TableCell()
                    {
                        Text = x.Channel.DisplayName
                    },
                    new TableCell()
                    {
                        Text = parsedDate.ToString()
                    },
                    new TableCell()
                    {
                        Text = x.Airing.Title
                    },
                });

                if (count++ % 2 == 0)
                {
                    row.CssClass = "alt";
                }

                ResultsTable.Rows.Add(row);
            }
        }