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 GetListItems(AdsListFilterRequest filter) { var allAdsResult = _adsService.GetAds(); if (!allAdsResult.Success) { return(BadRequest("Something bad happened. Try again.")); } var allAdsFiltered = GetAdsFiltered(allAdsResult.Value, filter); var model = new GetAdResponse(); model.Ads = allAdsFiltered; var result = ToJson(model); return(Ok(result)); }