public WallpaperLoadResult LoadWallpaper(BingImage wallpaper) { var index = wallpaper.copyright.IndexOf(START_OF_COPYRIGHT); var caption = wallpaper.copyright.Substring(0, index).Trim(); var httpClient = new HttpClient(); var uri = new Uri(new Uri("http://www.bing.com"), wallpaper.url); var webResult = httpClient.GetAsync(uri).Result; return(new WallpaperLoadResult(new WallpaperInformation { Caption = caption, Hash = wallpaper.hsh, Url = uri, Source = Source }, _workItemManager.ConvertToWorkItem(wallpaper), new[] { new WallpaperFileWithData { FileDto = new WallpaperFileImage(), Data = webResult.Content.ReadAsByteArrayAsync().Result, } })); }
public WallpaperLoadResult LoadWallpaper(GoogleEarthImageId wallpaper) { var relativeUri = $"{wallpaper.Id}.json"; var webResult = _httpClient.GetAsync(relativeUri).Result; var strResult = webResult.Content.ReadAsStringAsync().Result; var result = JsonConvert.DeserializeObject <GoogleResult>(strResult); var pic = Convert.FromBase64String(result.dataUri.Split(',')[1]); result.dataUri = string.Empty; //Remove Data before convert to RawDocument var address = CreateAddress(result); return(new WallpaperLoadResult( new WallpaperInformation { Hash = wallpaper.Id, Url = new Uri(Source.BaseUri, relativeUri), Caption = address.Country + " " + string.Join(" ", address.AdministrativeArea) + " " + address.City + " " + string.Join(" ", address.SubCity) + " " + address.Street, Locations = new List <WallpaperLocation> { new WallpaperLocationCoordinates { Latitude = result.lat, Longtitude = result.lng }, address } }, _workItemManager.ConvertToWorkItem(result), new WallpaperFileWithData[] { new WallpaperFileWithData { Data = pic, FileDto = new WallpaperFileImage() } })); }
public WallpaperLoadResult LoadWallpaper(ItemResult wallpaper) { var uri = new Uri(wallpaper.ad.image_fullscreen_001_landscape.u); var httpClient = new HttpClient(); var webResult = httpClient.GetAsync(uri).Result; return(new WallpaperLoadResult(new WallpaperInformation { Caption = wallpaper.ad.title_text.tx, Hash = wallpaper.GetImageHash(), Url = uri, Source = Source }, _workItemManager.ConvertToWorkItem(wallpaper), new[] { new WallpaperFileWithData { FileDto = new WallpaperFileImage(), Data = webResult.Content.ReadAsByteArrayAsync().Result, } })); }