private void CrawlPosters(string data) { if (string.IsNullOrEmpty(data)) { return; } JavaScriptSerializer json = new JavaScriptSerializer(); try { data = HttpContext.Current.Server.UrlDecode(data); } catch (Exception) { // in some cases data is already decoded - hence we dont need to redecoded it. it throws an exception } XMLMovieProperties prop = json.Deserialize <XMLMovieProperties>(data); //string movieUrl,string movieUniqueName TableManager tblMgr = new TableManager(); List <string> urls = new SantaImageCrawler().GetMoviePosterUrls(prop.SantaPosterLink); ImdbCrawler ic = new ImdbCrawler(); MovieEntity me = tblMgr.GetMovieByUniqueName(prop.MovieName); List <string> processedUrl = json.Deserialize <List <string> >(me.Posters); me.Pictures = (string.IsNullOrEmpty(me.Pictures) || me.Pictures == "null") ? "[]" : me.Pictures; List <CloudMovie.APIRole.UDT.PosterInfo> posters = json.Deserialize <List <CloudMovie.APIRole.UDT.PosterInfo> >(me.Pictures); int imageCounter = 1; string newImageName = string.Empty; if (processedUrl != null) { imageCounter = processedUrl.Count + 1; foreach (string process in processedUrl) { CloudMovie.APIRole.UDT.PosterInfo info = new CloudMovie.APIRole.UDT.PosterInfo(); info.url = process; posters.Add(info); } } else { processedUrl = new List <string>(); posters = new List <CloudMovie.APIRole.UDT.PosterInfo>(); } foreach (string url in urls) { CloudMovie.APIRole.UDT.PosterInfo info = new CloudMovie.APIRole.UDT.PosterInfo(); try { string posterPath = ic.GetNewImageName(prop.MovieName, ic.GetFileExtension(url), imageCounter, false, ref newImageName); ic.DownloadImage(url, posterPath); processedUrl.Add(newImageName); info.url = newImageName; info.source = prop.SantaPosterLink; posters.Add(info); imageCounter++; } catch (Exception) { // Skip that image } } me.Posters = json.Serialize(processedUrl); me.Pictures = json.Serialize(posters); tblMgr.UpdateMovieById(me); }