private async Task Download(Uri repositoryFile, Stream repositoryStream, string proxy, IProgressNotifier parentProgress = null) { if (!string.IsNullOrEmpty(proxy)) { await downloadService.Download(repositoryFile, repositoryStream, new WebProxy(new Uri(proxy)), parentProgress).ConfigureAwait(false); } else { await downloadService.Download(repositoryFile, repositoryStream, parentProgress).ConfigureAwait(false); } }
public async Task Download([FromBody] dynamic obj) { string urn = obj.urn; Credentials = await Credentials.FromSessionAsync(); await downloadService.Download(urn, Credentials.TokenInternal); }
private async Task DownloadClick(object sender, EventArgs e) { var curButton = (Button)sender; var curFileName = curButton.Name; var ret = await downloadService.Download(curFileName); if (!ret) { MessageBox.Show($"Error happened during downloading {curFileName} file"); } }
private static void ManageStaticContent( FullPresentation fullPresentation, ScheduledBlockData scheduledBlockData, IDownloadService downloadService) { StaticRectArea staticRectArea = scheduledBlockData.RectAreas.Where(ra => (ra as StaticRectArea) != null).Select(ra => ra as StaticRectArea).FirstOrDefault(); if (staticRectArea != null) { fullPresentation.StaticImageLocalPath = downloadService.Download(staticRectArea.ImageUrl); } }
/// <summary> /// Initializes a new instance of the <see cref="MockedDownloadServiceAbstraction" /> class. /// </summary> public MockedDownloadServiceAbstraction() { downloadService.Download(null, null, null) .ReturnsForAnyArgs(callinfo => ProcessDownload(callinfo.Arg <Uri>(), callinfo.Arg <Stream>())); downloadService.Download(null, null, null, null) .ThrowsForAnyArgs(callinfo => new DownloadFileNotReachableException(callinfo.Arg <Uri>())); LoadCliRepository(); void LoadCliRepository() { string basePath = "http://localhost/cli/"; Assembly assembly = Assembly.GetExecutingAssembly(); foreach (string name in assembly.GetManifestResourceNames()) { if (!name.StartsWith("Test.PlcNext.Deployment.CliRepository.")) { continue; } using (Stream mainfestStream = assembly.GetManifestResourceStream(name)) { MemoryStream memoryStream = RecyclableMemoryStreamManager.Instance.GetStream(); mainfestStream.CopyTo(memoryStream); availableDownloads.Add(BuildUrl(basePath, name.Replace("Test.PlcNext.Deployment.CliRepository.", "")), memoryStream); } } } Uri BuildUrl(string basePath, string relativePath) { relativePath = relativePath.Substring(0, relativePath.LastIndexOf('.')).Replace('.', '/') + relativePath.Substring(relativePath.LastIndexOf('.')); relativePath = relativePath.Replace("_point", ".").Replace("_remove", ""); return(new Uri(new Uri(basePath), new Uri(relativePath, UriKind.Relative))); } }
private static void ExecuteOneIteration(object sender, ElapsedEventArgs e) { ITimeLogProvider timeLogProvider = ServiceProvider.GetService <ITimeLogProvider>(); IFrixxerService frixxerService = ServiceProvider.GetService <IFrixxerService>(); IAdsService adsService = ServiceProvider.GetService <IAdsService>(); IDownloadService downloadService = ServiceProvider.GetService <IDownloadService>(); FileProcessor fileProcessor = ServiceProvider.GetService <FileProcessor>(); List <PresentationViewModel <Presentation> > presentations = frixxerService.GetPresentations(DateTime.Now, 300); List <FullPresentation> allPresentations = new List <FullPresentation>(); presentations.ForEach(presentation => { // Manage MainContent MainContentRectArea mainContentRectArea = presentation.ScheduledBlockData.RectAreas.Where(ra => (ra as MainContentRectArea) != null).First() as MainContentRectArea; FullPresentation fullPresentation = new FullPresentation(); fullPresentation.Duration = mainContentRectArea.Videos.Sum(v => v.Duration); mainContentRectArea.Videos.ForEach(video => { VideoPresentation videoPresentation = new VideoPresentation(); videoPresentation.LocalPath = downloadService.Download(video.Url); videoPresentation.Duration = video.Duration; videoPresentation.Ads = adsService.GetAds(video.Tags); fullPresentation.Videos.Add(videoPresentation); }); ManageScrollTextsForPresentation(fullPresentation, presentation.ScheduledBlockData); ManageStaticContent(fullPresentation, presentation.ScheduledBlockData, downloadService); ManageWidgets(fullPresentation, presentation.ScheduledBlockData); allPresentations.Add(fullPresentation); }); //Console.WriteLine($"Executing: { timeLogProvider.GenerateCurrentTimeLog() }"); Console.WriteLine($"Executing.................."); string outputPath = $"{Configuration["FrixxerPresentationOutputRoot"]}{timeLogProvider.GenerateCurrentTimeLog()}.json"; string serializedPresentations = JsonConvert.SerializeObject(allPresentations, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented }); fileProcessor.Write(outputPath, serializedPresentations); }
public IActionResult Download([FromBody] BodyParameters body) { try { _logger.Log(LogLevel.Debug, body.YoutubeLink); Console.WriteLine(body.YoutubeLink); _downloadService.Download(body.YoutubeLink); return(Ok()); } catch (Exception exception) { Console.WriteLine(exception.Message); return(BadRequest(exception.Message)); } }
public async Task Run() { try { string[] fields = new string[] { "id", "first_name", "last_name", "email", "picture.type(large)", "link", "locale", "name", "name_format", "updated_time" }; List <Member> members = await _fbClient.GetAllCommunityMembers(fields); if (string.IsNullOrWhiteSpace(_gravatarsConfiguration.DefaultGravatarRelativePath)) { throw new MissingFieldException($"{nameof(_gravatarsConfiguration.DefaultGravatarRelativePath)} cannot be null, empty or white space"); } if (string.IsNullOrWhiteSpace(_gravatarsConfiguration.DestinationFolder)) { throw new MissingFieldException($"{nameof(_gravatarsConfiguration.DestinationFolder)} cannot be null, empty or white space"); } if (!Directory.Exists(_gravatarsConfiguration.DestinationFolder)) { Directory.CreateDirectory(_gravatarsConfiguration.DestinationFolder); } string defaultGravatarFullPath = Path.Combine(Directory.GetCurrentDirectory(), _gravatarsConfiguration.DefaultGravatarRelativePath); if (!File.Exists(defaultGravatarFullPath)) { throw new FileNotFoundException($"Could not find the file {defaultGravatarFullPath}"); } byte[] defaultGravatar = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), _gravatarsConfiguration.DefaultGravatarRelativePath)); List <string> userImageFileNames = new List <string>(); List <string> usersNotFoundInDirectory = new List <string>(); foreach (Member member in members) { if (member.Picture != null && member.Picture.Data != null && !string.IsNullOrWhiteSpace(member.Picture.Data.Url)) { byte[] image; if (!member.Picture.Data.IsSilhouette) { image = await _downloadService.Download(member.Picture.Data.Url); } else { image = defaultGravatar; } string facebookUserEmail = member.Email.Trim().ToLowerInvariant(); IEnumerable <string> emailAliases = await _googleAdminClient.GetAccountAliases(facebookUserEmail); if (emailAliases == null) { usersNotFoundInDirectory.Add(facebookUserEmail); } List <string> emailsList = emailAliases?.ToList() ?? new List <string>(); if (!emailsList.Contains(facebookUserEmail)) { emailsList.Add(facebookUserEmail); } foreach (string userEmail in emailsList) { string userEmailMD5 = _cryptographyService.CalculateMD5Hash(userEmail); string userEmailMD5FileName = $"{userEmailMD5}.jpg"; string fullFileName = Path.Combine(_gravatarsConfiguration.DestinationFolder, userEmailMD5FileName); File.WriteAllBytes(fullFileName, image); _logger.LogInformation($"User {userEmail} picture has been saved as {fullFileName}"); userImageFileNames.Add(userEmailMD5FileName); } } else { _logger.LogWarning($"User {member.Email} picture is null, empty or white space"); } } cleanUpFiles(userImageFileNames); if (usersNotFoundInDirectory.Any()) { _logger.LogWarning($"Could not find the following address in Google directory: {string.Join(", ", usersNotFoundInDirectory)}"); } } catch (Exception ex) { _logger.LogError(ex.ToString()); } }
private void DownloadTask() { DownloadService.Download(); }