Ejemplo n.º 1
0
        public async Task GenerateTVProgram()
        {
            var watch = Stopwatch.StartNew();

            var channelsList = new List <ChannelOutput>();
            var recordsList  = new List <TvProgramOutput>();

            var tvGuidesList = await GetTvGuideInParallel <RootObject>(_channelsGroups);

            foreach (var tvGuide in tvGuidesList)
            {
                foreach (var record in tvGuide.Schedule.Programme)
                {
                    channelsList.Add(new ChannelOutput
                    {
                        Id          = record.Channel.Slug,
                        DisplayName = record.Channel.Name,
                        Logo        = $"{_mediaGallery}/{record.Channel.Logo_64}"
                    });

                    recordsList.Add(new TvProgramOutput
                    {
                        Channel        = record.Channel.Slug,
                        Title          = record.Title,
                        Description    = record.Description_long,
                        ProgrammeImage = record.Image,
                        StartTime      = DateTimeFormatter.TimestampToString(record.Start_unix),
                        EndTime        = DateTimeFormatter.TimestampToString(record.Stop_unix),
                        Episode        = record.Ep_nr,
                        Country        = record.Country,
                        Year           = record.Year,
                        Credits        = new Credit
                        {
                            Actor    = record.Cast,
                            Director = record.Director
                        }
                    });
                }
            }

            var generateXML  = GenerateXml.Create(channelsList, recordsList);
            var convertToXml = XmlSerializer.SerializeXml.Convert(generateXML);
            await _s3Uploader.WritingAnObjectAsync(convertToXml);

            watch.Stop();
            var timeSpan = watch.Elapsed;

            var elapsedTime =
                $"{timeSpan.Hours:00}:{timeSpan.Minutes:00}:{timeSpan.Seconds:00}.{timeSpan.Milliseconds / 10:00}";

            Console.WriteLine("RunTime " + elapsedTime);
        }