Exemplo n.º 1
0
 /// <summary>
 /// Create a new contributor object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="contributor_id">Initial value of the contributor_id property.</param>
 public static contributor Createcontributor(global::System.Int32 id, global::System.Int32 contributor_id)
 {
     contributor contributor = new contributor();
     contributor.id = id;
     contributor.contributor_id = contributor_id;
     return contributor;
 }
Exemplo n.º 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);
			}
		}
Exemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the contributors EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTocontributors(contributor contributor)
 {
     base.AddObject("contributors", contributor);
 }