當前位置: 首頁>>代碼示例>>C#>>正文


C# Channel.Persist方法代碼示例

本文整理匯總了C#中TvDatabase.Channel.Persist方法的典型用法代碼示例。如果您正苦於以下問題:C# Channel.Persist方法的具體用法?C# Channel.Persist怎麽用?C# Channel.Persist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TvDatabase.Channel的用法示例。


在下文中一共展示了Channel.Persist方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ImportChannels

        /// <summary>
        /// Imports the channels.
        /// </summary>
        /// <param name="delay">The delay in ms between each record.</param>
        /// <returns></returns>
        public int ImportChannels(int delay)
        {
            ClearCache();

             ImportStats stats = new ImportStats();

             if (_lineupHasChanged && _remapChannelsOnLineupChange)
            VerifyChannelMapping(delay);

             // Refresh the channel cache
             _mpChannelCache = (IList)Channel.ListAll();

             foreach (SchedulesDirect.SoapEntities.TVLineup lineup in _results.Data.Lineups.List)
             {
            Log.WriteFile("Processing lineup {0} [id={1} type={2} postcode={3}]", lineup.Name, lineup.ID, lineup.Type, lineup.PostalCode);
            foreach (SchedulesDirect.SoapEntities.TVStationMap tvStationMap in lineup.StationMap)
            {
               if (ShowProgress != null)
                  ShowProgress(this, stats);

               SchedulesDirect.SoapEntities.TVStation tvStation = _results.Data.Stations.StationById(tvStationMap.StationId);
               if (tvStation == null)
               {
                  Log.WriteFile("Unable to find stationId #{0} specified in lineup", tvStationMap.StationId);
                  continue;
               }

               if (tvStationMap.ChannelMajor < 0)
               {
                  Log.WriteFile("TVStationMap ChannelMajor Not Valid. StationID: {3} ChannelMajor: {0} ChannelMinor: {1} SchedulesDirectChannel: {2}", tvStationMap.ChannelMajor, tvStationMap.ChannelMinor, tvStationMap.SchedulesDirectChannel, tvStationMap.StationId);
                  continue;
               }

               Channel mpChannel = FindTVChannel(tvStation, tvStationMap, lineup.IsLocalBroadcast());
               // Update the channel and map it
               if (mpChannel != null)
               {
                  mpChannel.GrabEpg = false;
                  mpChannel.LastGrabTime = DateTime.Now;
                  mpChannel.ExternalId = BuildXmlTvId(lineup.IsLocalBroadcast(), tvStation, tvStationMap);  //tvStation.ID + XMLTVID;
                  if (_renameChannels)
                  {
                     string oldName = mpChannel.DisplayName;
                     mpChannel.DisplayName = BuildChannelName(tvStation, tvStationMap);
                     mpChannel.DisplayName = BuildChannelName(tvStation, tvStationMap);
                     RenameLogo(oldName, mpChannel.DisplayName);
                  }
                  stats._iChannels++;

                  mpChannel.Persist();

                  Log.WriteFile("Updated channel {1} [id={0} xmlid={2}]", mpChannel.IdChannel, mpChannel.DisplayName, mpChannel.ExternalId);
               }
               else if ((_createChannels == true && lineup.IsAnalogue() == false)
                  || (_createChannels == true && _createAnalogChannels == true && lineup.IsAnalogue() == true))
               {
                  // Create the channel
                  string cname = BuildChannelName(tvStation, tvStationMap);
                  string xId   = BuildXmlTvId(lineup.IsLocalBroadcast(), tvStation, tvStationMap);

                  mpChannel = new Channel(false, true, 0, Schedule.MinSchedule, false, Schedule.MinSchedule, 10000, true, xId, cname);
                  mpChannel.Persist();

                  TvLibrary.Implementations.AnalogChannel tuningDetail = new TvLibrary.Implementations.AnalogChannel();

                  tuningDetail.IsRadio = false;
                  tuningDetail.IsTv = true;
                  tuningDetail.Name = cname;
                  tuningDetail.Frequency = 0;
                  tuningDetail.ChannelNumber = tvStationMap.ChannelMajor;

                  //(int)PluginSettings.ExternalInput;
                  //tuningDetail.VideoSource = PluginSettings.ExternalInput;
                  tuningDetail.VideoSource = _ExternalInput; // PluginSettings.ExternalInput;

                  // Too much overhead using settings directly for country
                  if (_ExternalInputCountry != null)
                     tuningDetail.Country = _ExternalInputCountry; // PluginSettings.ExternalInputCountry;

                  if (lineup.IsLocalBroadcast())
                     tuningDetail.TunerSource = DirectShowLib.TunerInputType.Antenna;
                  else
                     tuningDetail.TunerSource = DirectShowLib.TunerInputType.Cable;

                  //mpChannel.XMLId                  = tvStation.ID + XMLTVID;
                  //mpChannel.Name                   = BuildChannelName(tvStation, tvStationMap);
                  //mpChannel.AutoGrabEpg            = false;
                  //mpChannel.LastDateTimeEpgGrabbed = DateTime.Now;
                  //mpChannel.External               = true; // This may change with cablecard support one day
                  //mpChannel.ExternalTunerChannel   = tvStationMap.ChannelMajor.ToString();
                  //mpChannel.Frequency              = 0;
                  //mpChannel.Number                 = (int)PluginSettings.ExternalInput;

                  tvLayer.AddTuningDetails(mpChannel, tuningDetail);

//.........這裏部分代碼省略.........
開發者ID:ijprest,項目名稱:mp-schedulesdirect,代碼行數:101,代碼來源:EpgListingsImporter.cs

示例2: btnPlaylist_Click

 private void btnPlaylist_Click(object sender, EventArgs e)
 {
   OpenFileDialog dlg = new OpenFileDialog();
   dlg.AddExtension = false;
   dlg.CheckFileExists = true;
   dlg.CheckPathExists = true;
   dlg.Filter = "playlists (*.m3u;*.pls;*.b4s;*.wpl)|*.m3u;*.pls;*.b4s;*.wpl";
   dlg.Multiselect = false;
   dlg.Title = "Select the playlist file to import";
   if (dlg.ShowDialog(this) != DialogResult.OK)
     return;
   IPlayListIO listIO = PlayListFactory.CreateIO(dlg.FileName);
   PlayList playlist = new PlayList();
   if (!listIO.Load(playlist, dlg.FileName))
   {
     MessageBox.Show("There was an error parsing the playlist file", "Error", MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
     return;
   }
   TvBusinessLayer layer = new TvBusinessLayer();
   int iInserted = 0;
   foreach (PlayListItem item in playlist)
   {
     if (string.IsNullOrEmpty(item.FileName))
       continue;
     if (string.IsNullOrEmpty(item.Description))
       item.Description = item.FileName;
     Channel channel = new Channel(true, false, 0, Schedule.MinSchedule, false,
                                   Schedule.MinSchedule, 10000, true, "", item.Description);
     channel.Persist();
     layer.AddWebStreamTuningDetails(channel, item.FileName, 0);
     layer.AddChannelToRadioGroup(channel, TvConstants.RadioGroupNames.AllChannels);
     iInserted++;
   }
   MessageBox.Show("Imported " + iInserted + " new channels from playlist");
   OnSectionActivated();
 }
開發者ID:npcomplete111,項目名稱:MediaPortal-1,代碼行數:37,代碼來源:RadioChannels.cs


注:本文中的TvDatabase.Channel.Persist方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。