Пример #1
0
        public void loadPresentation(VideoPresentation presentation)
        {
            tempPresentation = presentation;

            foreach (var entry in presentation.Entries)
            {
                addEvent((VideoPart)entry);
            }
            updateTitle();
            add_video.Enabled = true;
        }
        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);
        }