ArgusTV.Recorder.MediaPortalTvServer.DvbEpgThread.ImportProgramsAsync C# (CSharp) 메소드

ImportProgramsAsync() 공개 메소드

public ImportProgramsAsync ( List guidePrograms ) : void
guidePrograms List
리턴 void
        public void ImportProgramsAsync(List<GuideProgram> guidePrograms)
        {
            if (guidePrograms != null
                && guidePrograms.Count > 0)
            {
                lock (_guideProgramsToImportLock)
                {
                    _guideProgramsToImport.Add(guidePrograms);
                    if (_newProgramsToImportEvent != null)
                    {
                        _newProgramsToImportEvent.Set();
                    }
                }
            }
        }

Usage Example

예제 #1
0
        private void ImportEpgPrograms(EpgChannel epgChannel)
        {
            if (!this.IsArgusTVConnectionInitialized)
            {
                InitializeArgusTVConnection(null);
            }
            if (this.IsArgusTVConnectionInitialized)
            {
                TvDatabase.TvBusinessLayer layer = new TvDatabase.TvBusinessLayer();
                bool epgSyncOn = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncOn, false.ToString()).Value);
                if (epgSyncOn)
                {
                    DVBBaseChannel dvbChannel = epgChannel.Channel as DVBBaseChannel;
                    if (dvbChannel != null)
                    {
                        TvDatabase.Channel mpChannel = layer.GetChannelByTuningDetail(dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId);
                        if (mpChannel != null)
                        {
                            Log.Debug("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms(): received {0} programs on {1}", epgChannel.Programs.Count, mpChannel.DisplayName);

                            using (CoreServiceAgent coreAgent = new CoreServiceAgent())
                                using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
                                    using (GuideServiceAgent tvGuideAgent = new GuideServiceAgent())
                                    {
                                        bool   epgSyncAutoCreateChannels          = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannels, false.ToString()).Value);
                                        bool   epgSyncAutoCreateChannelsWithGroup = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannelsWithGroup, false.ToString()).Value);
                                        string epgLanguages = layer.GetSetting("epgLanguages").Value;

                                        Channel channel = EnsureChannelForDvbEpg(tvSchedulerAgent, mpChannel, epgSyncAutoCreateChannels, epgSyncAutoCreateChannelsWithGroup);
                                        if (channel != null)
                                        {
                                            EnsureGuideChannelForDvbEpg(tvSchedulerAgent, tvGuideAgent, channel, mpChannel);

                                            List <GuideProgram> guidePrograms = new List <GuideProgram>();

                                            foreach (EpgProgram epgProgram in epgChannel.Programs)
                                            {
                                                string title;
                                                string description;
                                                string genre;
                                                int    starRating;
                                                string classification;
                                                int    parentalRating;
                                                GetProgramInfoForLanguage(epgProgram.Text, epgLanguages, out title, out description, out genre,
                                                                          out starRating, out classification, out parentalRating);

                                                if (!String.IsNullOrEmpty(title))
                                                {
                                                    GuideProgram guideProgram = new GuideProgram();
                                                    guideProgram.GuideChannelId = channel.GuideChannelId.Value;
                                                    guideProgram.StartTime      = epgProgram.StartTime;
                                                    guideProgram.StopTime       = epgProgram.EndTime;
                                                    guideProgram.StartTimeUtc   = epgProgram.StartTime.ToUniversalTime();
                                                    guideProgram.StopTime       = epgProgram.EndTime;
                                                    guideProgram.StopTimeUtc    = epgProgram.EndTime.ToUniversalTime();
                                                    guideProgram.Title          = title;
                                                    guideProgram.Description    = description;
                                                    guideProgram.Category       = genre;
                                                    guideProgram.Rating         = classification;
                                                    guideProgram.StarRating     = starRating / 7.0;
                                                    guidePrograms.Add(guideProgram);
                                                }
                                            }

                                            _dvbEpgThread.ImportProgramsAsync(guidePrograms);
                                        }
                                        else
                                        {
                                            Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to ensure channel.");
                                        }
                                    }
                        }
                        else
                        {
                            Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to find MP channel.");
                        }
                    }
                }
            }
        }