Пример #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the scan_pips_contributors EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToscan_pips_contributors(scan_pips_contributors scan_pips_contributors)
 {
     base.AddObject("scan_pips_contributors", scan_pips_contributors);
 }
Пример #2
0
		private async Task FetchItemGenreAndIonAsync(scan_pips_contributors item, Thumbnail thumbnail, IProgress progress, bool isTags, bool isIonContributors, bool isCategories)
		{
			if (progress.IsCancelled)
			{
				return;
			}
			thumbnail.ShowImage("http://node2.bbcimg.co.uk/iplayer/images/episode/" + item.pid + "_314_176.jpg");

			try
			{

				if (isTags || isIonContributors)
				{
					WebClient client = new WebClient();
					string result = await client.DownloadStringTaskAsync("http://www.bbc.co.uk/iplayer/ion/episodedetail/episode/" + item.pid + "/format/xml");

					XElement episode = XElement.Parse(result);
					XNamespace ion = "http://bbc.co.uk/2008/iplayer/ion";
					if (isIonContributors)
					{
						await TaskEx.Run(() =>
							{
								var contributors = episode.Elements(ion + "blocklist")
													.Elements(ion + "episode_detail")
													.Elements(ion + "contributors")
													.Elements(ion + "contributor");
								var data = new ReduxEntities();
								foreach (var contributor in contributors)
								{
									var ct = new contributor
									{
										character_name = contributor.Element(ion + "character_name").Value,
										family_name = contributor.Element(ion + "family_name").Value,
										given_name = contributor.Element(ion + "given_name").Value,
										role = contributor.Element(ion + "role").Value,
										role_name = contributor.Element(ion + "role_name").Value,
										type = contributor.Element(ion + "type").Value,
										contributor_id = Convert.ToInt32(contributor.Element(ion + "id").Value),
										pid = item.pid
									};
									data.AddObject("contributors", ct);
								}
								data.SaveChanges();
							});
					}
					if (isTags)
					{
						await TaskEx.Run(() =>
							{
								var tags = episode.Elements(ion + "blocklist")
													.Elements(ion + "episode_detail")
													.Elements(ion + "tag_schemes")
													.Elements(ion + "tag_scheme")
													.Elements(ion + "tags")
													.Elements(ion + "tag");
								var data = new ReduxEntities();
								foreach (var tag in tags)
								{
									var tg = new tag
									{
										tag_id = tag.Element(ion + "id").Value,
										name = tag.Element(ion + "name").Value,
										value = tag.Element(ion + "value").Value,
										pid = item.pid
									};
									data.AddObject("tags", tg);
								}
								data.SaveChanges();
							});
					}
				}
				if (isCategories)
				{
					WebClient catClient = new WebClient();
					var catresult = await catClient.DownloadStringTaskAsync("http://www.bbc.co.uk/programmes/" + item.pid + ".xml");
					var root = XElement.Parse(catresult);

					await TaskEx.Run(() =>
						{
							var cats = from cat in root.XPathSelectElements("categories/category[@type != 'genre']")
									   select new category()
									   {
										   pid = item.pid,
										   type = cat.Attribute("type").Value,
										   catkey = cat.Attribute("key").Value,
										   title = cat.Element("title").Value
									   };
							var db = new ReduxEntities();
							foreach (var c in cats)
							{
								db.AddObject("categories", c);
							}
							db.SaveChanges();
						});
				}
				item.scanned = true;
			}
			catch (WebException wex)
			{
				MessageBox.Show("Can't find programme " + item.pid);
				//throw new Exception("Couldn't find programme " + item.pid, wex);
			}
		}
Пример #3
0
 /// <summary>
 /// Create a new scan_pips_contributors object.
 /// </summary>
 /// <param name="pid">Initial value of the pid property.</param>
 /// <param name="scanned">Initial value of the scanned property.</param>
 public static scan_pips_contributors Createscan_pips_contributors(global::System.String pid, global::System.Boolean scanned)
 {
     scan_pips_contributors scan_pips_contributors = new scan_pips_contributors();
     scan_pips_contributors.pid = pid;
     scan_pips_contributors.scanned = scanned;
     return scan_pips_contributors;
 }