当前位置: 首页>>代码示例>>C#>>正文


C# TvBusinessLayer.AddNewChannel方法代码示例

本文整理汇总了C#中TvDatabase.TvBusinessLayer.AddNewChannel方法的典型用法代码示例。如果您正苦于以下问题:C# TvBusinessLayer.AddNewChannel方法的具体用法?C# TvBusinessLayer.AddNewChannel怎么用?C# TvBusinessLayer.AddNewChannel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TvDatabase.TvBusinessLayer的用法示例。


在下文中一共展示了TvBusinessLayer.AddNewChannel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Importxmlfile


//.........这里部分代码省略.........
                            bool grabEpg = (GetNodeAttribute(nodeChannel, "GrabEpg", "True") == "True");
                            bool isRadio = (GetNodeAttribute(nodeChannel, "IsRadio", "False") == "True");
                            bool isTv = (GetNodeAttribute(nodeChannel, "IsTv", "True") == "True");
                            DateTime lastGrabTime = DateTime.ParseExact("2000-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                            DateTime totalTimeWatched = DateTime.ParseExact("2000-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);

                            try
                            {
                                lastGrabTime = DateTime.ParseExact(GetNodeAttribute(nodeChannel, "LastGrabTime", "1900-01-01 00:00:00"), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                                totalTimeWatched = DateTime.ParseExact(GetNodeAttribute(nodeChannel, "TotalTimeWatched", "1900-01-01 00:00:00"), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                            }
                            catch
                            {
                                textoutput("<RED>Date and time could not be parsed for LastGrabTime and TotalTimeWatched - skipping values");
                            }
                            int sortOrder = Int32.Parse(GetNodeAttribute(nodeChannel, "SortOrder", "0"));
                            int timesWatched = Int32.Parse(GetNodeAttribute(nodeChannel, "TimesWatched", "0"));

                            bool visibileInGuide = (GetNodeAttribute(nodeChannel, "VisibleInGuide", "True") == "True");
                            bool FreeToAir = (GetNodeAttribute(nodeChannel, "FreeToAir", "True") == "True");
                            string displayName = GetNodeAttribute(nodeChannel, "DisplayName", name);
                            bool epgHasGaps = (GetNodeAttribute(nodeChannel, "EpgHasGaps", "False") == "True");
                            string externalId = GetNodeAttribute(nodeChannel, "ExternalId", "0");

                            // rtv: since analog allows NOT to merge channels we need to take care of this. US users e.g. have multiple stations named "Sport" with different tuningdetails.
                            // using AddChannel would incorrectly "merge" these totally different channels.
                            // see this: http://forum.team-mediaportal.com/1-0-rc1-svn-builds-271/importing-exported-channel-list-groups-channels-39368/

                            /*
                            if (DEBUG == true)
                            {
                                Log.Info("TvChannels: Adding {0}. channel: {1} ({2})", channelCount, name, displayName);
                            }*/
                            dbChannel = layer.AddNewChannel(name);
                            if (dbChannel == null)
                            {
                                textoutput("<RED>Failed to add channel " + name + " - aborting import");
                                return false;
                            }
                            dbChannel.GrabEpg = grabEpg;
                            dbChannel.IsRadio = isRadio;
                            dbChannel.IsTv = isTv;
                            dbChannel.LastGrabTime = lastGrabTime;
                            dbChannel.SortOrder = sortOrder;
                            dbChannel.TimesWatched = timesWatched;
                            dbChannel.TotalTimeWatched = totalTimeWatched;
                            dbChannel.VisibleInGuide = visibileInGuide;

            #if (MP12)
            #else
                            try
                            {
                                dbChannel.FreeToAir = FreeToAir;
                            }
                            catch //do nothing
                            {

                            }
            #endif
                            dbChannel.DisplayName = displayName;  //possible bug
                            dbChannel.EpgHasGaps = epgHasGaps;
                            dbChannel.ExternalId = externalId;

            #if(MP13)
                                        try
                                        {
开发者ID:huha001,项目名称:BackupSettings,代码行数:67,代码来源:BackupSettingsExportImport.cs

示例2: DoScan

    /// <summary>
    /// Scan Thread
    /// </summary>
    private void DoScan()
    {
      suminfo tv = new suminfo();
      suminfo radio = new suminfo();
      IUser user = new User();
      user.CardId = _cardNumber;
      try
      {
        scanState = ScanState.Scanning;
        if (_dvbcChannels.Count == 0)
          return;

        RemoteControl.Instance.EpgGrabberEnabled = false;

        SetButtonState();
        TvBusinessLayer layer = new TvBusinessLayer();
        Card card = layer.GetCardByDevicePath(RemoteControl.Instance.CardDevice(_cardNumber));

        for (int index = 0; index < _dvbcChannels.Count; ++index)
        {
          if (scanState == ScanState.Cancel)
            return;

          float percent = ((float)(index)) / _dvbcChannels.Count;
          percent *= 100f;
          if (percent > 100f)
            percent = 100f;
          progressBar1.Value = (int)percent;

          Application.DoEvents();

          DVBCChannel tuneChannel = new DVBCChannel(_dvbcChannels[index]); // new DVBCChannel();
          string line = String.Format("{0}tp- {1}", 1 + index, tuneChannel.TuningInfo.ToString());
          ListViewItem item = listViewStatus.Items.Add(new ListViewItem(line));
          item.EnsureVisible();

          if (index == 0)
          {
            RemoteControl.Instance.Scan(ref user, tuneChannel, -1);
          }

          IChannel[] channels = RemoteControl.Instance.Scan(_cardNumber, tuneChannel);
          UpdateStatus();

          if (channels == null || channels.Length == 0)
          {
            if (RemoteControl.Instance.TunerLocked(_cardNumber) == false)
            {
              line = String.Format("{0}tp- {1} {2} {3}:No signal", 1 + index, tuneChannel.Frequency,
                                   tuneChannel.ModulationType, tuneChannel.SymbolRate);
              item.Text = line;
              item.ForeColor = Color.Red;
              continue;
            }
            line = String.Format("{0}tp- {1} {2} {3}:Nothing found", 1 + index, tuneChannel.Frequency,
                                 tuneChannel.ModulationType, tuneChannel.SymbolRate);
            item.Text = line;
            item.ForeColor = Color.Red;
            continue;
          }

          radio.newChannel = 0;
          radio.updChannel = 0;
          tv.newChannel = 0;
          tv.updChannel = 0;
          for (int i = 0; i < channels.Length; ++i)
          {
            Channel dbChannel;
            DVBCChannel channel = (DVBCChannel)channels[i];
            bool exists;
            TuningDetail currentDetail;
            //Check if we already have this tuningdetail. The user has the option to enable channel move detection...
            if (checkBoxEnableChannelMoveDetection.Checked)
            {
              //According to the DVB specs ONID + SID is unique, therefore we do not need to use the TSID to identify a service.
              //The DVB spec recommends that the SID should not change if a service moves. This theoretically allows us to
              //track channel movements.
              currentDetail = layer.GetTuningDetail(channel.NetworkId, channel.ServiceId,
                                                                 TvBusinessLayer.GetChannelType(channel));
            }
            else
            {
              //There are certain providers that do not maintain unique ONID + SID combinations.
              //In those cases, ONID + TSID + SID is generally unique. The consequence of using the TSID to identify
              //a service is that channel movement tracking won't work (each transponder/mux should have its own TSID).
              currentDetail = layer.GetTuningDetail(channel.NetworkId, channel.TransportId, channel.ServiceId,
                                                                 TvBusinessLayer.GetChannelType(channel));
            }

            if (currentDetail == null)
            {
              //add new channel
              exists = false;
              dbChannel = layer.AddNewChannel(channel.Name);
              dbChannel.SortOrder = 10000;
              if (channel.LogicalChannelNumber >= 1)
              {
//.........这里部分代码省略.........
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:101,代码来源:CardDvbC.cs

示例3: DoTvScan


//.........这里部分代码省略.........
          channel.IsTv = true;
          channel.IsRadio = false;
          channel.VideoSource = AnalogChannel.VideoInputType.Tuner;
          channel.AudioSource = AnalogChannel.AudioInputType.Automatic;
          string line = String.Format("channel:{0} source:{1} ", channel.ChannelNumber, mpComboBoxSource.SelectedItem);
          ListViewItem item = mpListView1.Items.Add(new ListViewItem(line));
          item.EnsureVisible();

          IChannel[] channels = RemoteControl.Instance.Scan(_cardNumber, channel);
          UpdateStatus();
          if (channels == null || channels.Length == 0)
          {
            if (RemoteControl.Instance.TunerLocked(_cardNumber) == false)
            {
              line = String.Format("channel:{0} source:{1} : No Signal", channel.ChannelNumber,
                                   mpComboBoxSource.SelectedItem);
              item.Text = line;
              item.ForeColor = Color.Red;
              continue;
            }
            line = String.Format("channel:{0} source:{1} : Nothing found", channel.ChannelNumber,
                                 mpComboBoxSource.SelectedItem);
            item.Text = line;
            item.ForeColor = Color.Red;
            continue;
          }
          bool exists = false;
          channel = (AnalogChannel)channels[0];
          if (channel.Name == "")
            channel.Name = String.Format(channel.ChannelNumber.ToString());
          Channel dbChannel = null;
          if (checkBoxNoMerge.Checked)
          {
            dbChannel = layer.AddNewChannel(channel.Name);
          }
          else
          {
            IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channel.Name, 0);
            if (tuningDetails != null && tuningDetails.Count > 0)
            {
              dbChannel = tuningDetails[0].ReferencedChannel();
            }

            if (dbChannel != null)
            {
              exists = true;
            }
            else
            {
              dbChannel = layer.AddNewChannel(channel.Name);
            }
          }
          dbChannel.IsTv = channel.IsTv;
          dbChannel.IsRadio = channel.IsRadio;
          dbChannel.Persist();
          layer.AddTuningDetails(dbChannel, channel);
          layer.MapChannelToCard(card, dbChannel, false);

          if (dbChannel.IsTv)
          {
            layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
            if (checkBoxCreateSignalGroup.Checked)
            {
              layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.Analog);
            }
          }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:67,代码来源:CardAnalog.cs

示例4: importButton_Click

    private void importButton_Click(object sender, EventArgs e)
    {
      bool importtv = imCheckTvChannels.Checked;
      bool importtvgroups = imCheckTvGroups.Checked;
      bool importradio = imCheckRadioChannels.Checked;
      bool importradiogroups = imCheckRadioGroups.Checked;
      bool importschedules = imCheckSchedules.Checked;

      openFileDialog1.CheckFileExists = true;
      openFileDialog1.DefaultExt = "xml";
      openFileDialog1.RestoreDirectory = true;
      openFileDialog1.Title = "Load channels, channel groups and schedules";
      openFileDialog1.InitialDirectory = String.Format(@"{0}\Team MediaPortal\MediaPortal TV Server",
                                                       Environment.GetFolderPath(
                                                         Environment.SpecialFolder.CommonApplicationData));
      openFileDialog1.FileName = "export.xml";
      openFileDialog1.AddExtension = true;
      openFileDialog1.Multiselect = false;
      if (openFileDialog1.ShowDialog(this) != DialogResult.OK)
        return;
      NotifyForm dlg = new NotifyForm("Importing tv channels...", "This can take some time\n\nPlease be patient...");
      try
      {
        dlg.Show();
        dlg.WaitForDisplay();
        CountryCollection collection = new CountryCollection();
        TvBusinessLayer layer = new TvBusinessLayer();
        bool mergeChannels = false; // every exported channel will be imported on its own.
        int channelCount = 0;
        int scheduleCount = 0;
        int tvChannelGroupCount = 0;
        int radioChannelGroupCount = 0;

        if (layer.Channels.Count > 0 && (importtv || importradio))
        {
          // rtv: we could offer to set a "merge" property here so tuningdetails would be updated for existing channels.
          if (
            MessageBox.Show(
              "Existing channels detected! \nIf you continue to import your old backup then all identically named channels will be treated equal - there is a risk of duplicate entries. \nDo you really want to go on?",
              "Channels found", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
            return;
          else
            mergeChannels = true;
        }

        XmlDocument doc = new XmlDocument();
        Log.Info("TvChannels: Trying to import channels from {0}", openFileDialog1.FileName);
        doc.Load(openFileDialog1.FileName);
        XmlNodeList channelList = doc.SelectNodes("/tvserver/channels/channel");
        XmlNodeList tvChannelGroupList = doc.SelectNodes("/tvserver/channelgroups/channelgroup");
        XmlNodeList radioChannelGroupList = doc.SelectNodes("/tvserver/radiochannelgroups/radiochannelgroup");
        XmlNodeList scheduleList = doc.SelectNodes("/tvserver/schedules/schedule");
        if (channelList != null)
        {
          foreach (XmlNode nodeChannel in channelList)
          {
            try
            {
              Channel dbChannel;
              XmlNodeList tuningList = nodeChannel.SelectNodes("TuningDetails/tune");
              XmlNodeList mappingList = nodeChannel.SelectNodes("mappings/map");
              bool grabEpg = (GetNodeAttribute(nodeChannel, "GrabEpg", "True") == "True");
              bool isRadio = (GetNodeAttribute(nodeChannel, "IsRadio", "False") == "True");
              bool isTv = (GetNodeAttribute(nodeChannel, "IsTv", "True") == "True");
              DateTime lastGrabTime = DateTime.ParseExact(GetNodeAttribute(nodeChannel, "LastGrabTime", "01.01.1900"),
                                                          "yyyy-M-d H:m:s", CultureInfo.InvariantCulture);
              int sortOrder = Int32.Parse(GetNodeAttribute(nodeChannel, "SortOrder", "0"));
              int timesWatched = Int32.Parse(GetNodeAttribute(nodeChannel, "TimesWatched", "0"));
              DateTime totalTimeWatched =
                DateTime.ParseExact(GetNodeAttribute(nodeChannel, "TotalTimeWatched", "01.01.1900"), "yyyy-M-d H:m:s",
                                    CultureInfo.InvariantCulture);
              bool visibileInGuide = (GetNodeAttribute(nodeChannel, "VisibleInGuide", "True") == "True");
              bool FreeToAir = (GetNodeAttribute(nodeChannel, "FreeToAir", "True") == "True");
              string displayName = GetNodeAttribute(nodeChannel, "DisplayName", "Unkown");
              int chChannelNumber = Int32.Parse(GetNodeAttribute(nodeChannel, "ChannelNumber", "10000"));

              // Only import TV or radio channels if the corresponding checkbox was checked
              if ((isTv && !importtv) || (isRadio && !importradio))
                continue;

              channelCount++;

              // rtv: since analog allows NOT to merge channels we need to take care of this. US users e.g. have multiple stations named "Sport" with different tuningdetails.
              // using AddChannel would incorrectly "merge" these totally different channels.
              // see this: http://forum.team-mediaportal.com/1-0-rc1-svn-builds-271/importing-exported-channel-list-groups-channels-39368/
              Log.Info("TvChannels: Adding {0}. channel: {1}", channelCount, displayName);
              IList<Channel> foundExistingChannels = layer.GetChannelsByName(displayName);
              if (mergeChannels && (foundExistingChannels != null && foundExistingChannels.Count > 0))
              {
                dbChannel = foundExistingChannels[0];
              }
              else
              {
                dbChannel = layer.AddNewChannel(displayName, chChannelNumber);
              }

              dbChannel.GrabEpg = grabEpg;
              dbChannel.IsRadio = isRadio;
              dbChannel.IsTv = isTv;
              dbChannel.LastGrabTime = lastGrabTime;
//.........这里部分代码省略.........
开发者ID:nio22,项目名称:MediaPortal-1,代码行数:101,代码来源:ImportExport.cs

示例5: mpButton1_Click

    private void mpButton1_Click(object sender, EventArgs e)
    {
      if (string.IsNullOrEmpty(_configuration.Graph.Crossbar.Name))
      {
        IUser user = new User();
        user.CardId = _cardNumber;
        AnalogChannel temp = new AnalogChannel();
        temp.TunerSource = TunerInputType.Antenna;
        temp.VideoSource = AnalogChannel.VideoInputType.Tuner;
        temp.AudioSource = AnalogChannel.AudioInputType.Tuner;
        temp.IsRadio = false;
        temp.IsTv = true;
        RemoteControl.Instance.Tune(ref user, temp, -1);
        _configuration = Configuration.readConfiguration(_cardNumber, _cardName, _devicePath);
        if (string.IsNullOrEmpty(_configuration.Graph.Crossbar.Name))
        {
          MessageBox.Show(this, "The S-Video channels could not be detected.");
          return;
        }
        ReCheckSettings();
      }

      TvBusinessLayer layer = new TvBusinessLayer();
      Dictionary<AnalogChannel.VideoInputType, int> videoPinMap = _configuration.Graph.Crossbar.VideoPinMap;
      AnalogChannel tuningDetail;
      Card card = layer.GetCardByDevicePath(RemoteControl.Instance.CardDevice(_cardNumber));
      Channel dbChannel;
      if (videoPinMap.ContainsKey(AnalogChannel.VideoInputType.VideoInput1))
      {
        string channelName = "CVBS#1 on " + card.IdCard;
        IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channelName, 0);
        if (tuningDetails != null && tuningDetails.Count > 0)
        {
          dbChannel = tuningDetails[0].ReferencedChannel();
        }
        else
        {
          dbChannel = layer.AddNewChannel(channelName);
        }
        dbChannel.IsTv = true;
        dbChannel.Persist();
        tuningDetail = new AnalogChannel();
        tuningDetail.IsTv = true;
        tuningDetail.Name = dbChannel.DisplayName;
        tuningDetail.VideoSource = AnalogChannel.VideoInputType.VideoInput1;
        layer.AddTuningDetails(dbChannel, tuningDetail);
        layer.MapChannelToCard(card, dbChannel, false);
        layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
      }
      if (videoPinMap.ContainsKey(AnalogChannel.VideoInputType.VideoInput2))
      {
        string channelName = "CVBS#2 on " + card.IdCard;
        IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channelName, 0);
        if (tuningDetails != null && tuningDetails.Count > 0)
        {
          dbChannel = tuningDetails[0].ReferencedChannel();
        }
        else
        {
          dbChannel = layer.AddNewChannel(channelName);
        }
        dbChannel.IsTv = true;
        dbChannel.Persist();
        tuningDetail = new AnalogChannel();
        tuningDetail.IsTv = true;
        tuningDetail.Name = dbChannel.DisplayName;
        tuningDetail.VideoSource = AnalogChannel.VideoInputType.VideoInput2;
        layer.AddTuningDetails(dbChannel, tuningDetail);
        layer.MapChannelToCard(card, dbChannel, false);
        layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
      }
      if (videoPinMap.ContainsKey(AnalogChannel.VideoInputType.VideoInput3))
      {
        string channelName = "CVBS#3 on " + card.IdCard;
        IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channelName, 0);
        if (tuningDetails != null && tuningDetails.Count > 0)
        {
          dbChannel = tuningDetails[0].ReferencedChannel();
        }
        else
        {
          dbChannel = layer.AddNewChannel(channelName);
        }
        dbChannel.IsTv = true;
        dbChannel.Persist();
        tuningDetail = new AnalogChannel();
        tuningDetail.IsTv = true;
        tuningDetail.Name = dbChannel.DisplayName;
        tuningDetail.VideoSource = AnalogChannel.VideoInputType.VideoInput3;
        layer.AddTuningDetails(dbChannel, tuningDetail);
        layer.MapChannelToCard(card, dbChannel, false);
        layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
      }
      if (videoPinMap.ContainsKey(AnalogChannel.VideoInputType.SvhsInput1))
      {
        string channelName = "S-Video#1 on " + card.IdCard;
        IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channelName, 0);
        if (tuningDetails != null && tuningDetails.Count > 0)
        {
          dbChannel = tuningDetails[0].ReferencedChannel();
//.........这里部分代码省略.........
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:101,代码来源:CardAnalog.cs

示例6: DoRadioScan

    private void DoRadioScan()
    {
      int channelsNew = 0;
      int channelsUpdated = 0;

      checkButton.Enabled = false;
      int sensitivity = 1;
      switch (mpComboBoxSensitivity.Text)
      {
        case "High":
          sensitivity = 10;
          break;
        case "Medium":
          sensitivity = 2;
          break;
        case "Low":
          sensitivity = 1;
          break;
      }
      string buttonText = mpButtonScanRadio.Text;
      try
      {
        _isScanning = true;
        _stopScanning = false;
        mpButtonScanRadio.Text = "Cancel...";
        RemoteControl.Instance.EpgGrabberEnabled = false;
        TvBusinessLayer layer = new TvBusinessLayer();
        Card card = layer.GetCardByDevicePath(RemoteControl.Instance.CardDevice(_cardNumber));
        mpComboBoxCountry.Enabled = false;
        mpComboBoxSource.Enabled = false;
        mpComboBoxSensitivity.Enabled = false;
        checkBoxCreateSignalGroup.Enabled = false;
        checkBoxNoMerge.Enabled = false;
        mpButtonScanTv.Enabled = false;
        mpButtonAddSvideoChannels.Enabled = false;
        UpdateStatus();
        mpListView1.Items.Clear();
        CountryCollection countries = new CountryCollection();
        for (int freq = 87500000; freq < 108000000; freq += 100000)
        {
          if (_stopScanning)
            return;
          float percent = ((freq - 87500000)) / (108000000f - 87500000f);
          percent *= 100f;
          if (percent > 100f)
            percent = 100f;
          progressBar1.Value = (int)percent;
          AnalogChannel channel = new AnalogChannel();
          channel.IsRadio = true;
          channel.TunerSource = mpComboBoxSource.SelectedIndex == 0 ? TunerInputType.Antenna : TunerInputType.Cable;
          channel.VideoSource = AnalogChannel.VideoInputType.Tuner;
          channel.AudioSource = AnalogChannel.AudioInputType.Automatic;
          channel.Country = countries.Countries[mpComboBoxCountry.SelectedIndex];
          channel.Frequency = freq;
          channel.IsTv = false;
          channel.IsRadio = true;
          float freqMHz = channel.Frequency;
          freqMHz /= 1000000f;
          string line = String.Format("frequence:{0} MHz ", freqMHz.ToString("f2"));
          ListViewItem item = mpListView1.Items.Add(new ListViewItem(line));
          item.EnsureVisible();
          IUser user = new User();
          user.CardId = _cardNumber;
          TvResult tuneResult = RemoteControl.Instance.Tune(ref user, channel, -1);
          if (tuneResult == TvResult.SWEncoderMissing)
          {
            Log.Error("analog: DoTvScan error (missing software encoder)");
            MessageBox.Show("Please install a supported audio/video encoder for your software analog card",
                            "Unable to scan", MessageBoxButtons.OK, MessageBoxIcon.Error);
            break;
          }
          if (tuneResult == TvResult.GraphBuildingFailed)
          {
            Log.Error("analog: DoTvScan error (missing software encoder)");
            MessageBox.Show(
              "The graph building. Mostly your card is not supported by TvServer. Please create a report in our forum",
              "Unable to scan", MessageBoxButtons.OK, MessageBoxIcon.Error);
            break;
          }
          UpdateStatus();
          Thread.Sleep(2000);
          if (SignalStrength(sensitivity) == 100)
          {
            channel.Name = String.Format("{0}", freq);
            Channel dbChannel = null;
            IList<TuningDetail> tuningDetails = layer.GetTuningDetailsByName(channel.Name, 0);
            if (tuningDetails != null && tuningDetails.Count > 0)
            {
              dbChannel = tuningDetails[0].ReferencedChannel();
            }
            if (dbChannel != null)
            {
              line = String.Format("frequence:{0} MHz : Channel update found - {1}", freqMHz.ToString("f2"),
                                   channel.Name);
              channelsUpdated++;
            }
            else
            {
              dbChannel = layer.AddNewChannel(channel.Name);
              line = String.Format("frequence:{0} MHz : New channel found - {1}", freqMHz.ToString("f2"), channel.Name);
//.........这里部分代码省略.........
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:101,代码来源:CardAnalog.cs

示例7: DoScan


//.........这里部分代码省略.........
            Channel dbChannel;
            DVBIPChannel channel = (DVBIPChannel)channels[i];
            if (channels.Length > 1)
            {
              if (channel.Name.IndexOf("Unknown") == 0)
              {
                channel.Name = name + (i + 1);
              }
            }
            else
            {
              channel.Name = name;
            }
            bool exists;
            TuningDetail currentDetail;
            //Check if we already have this tuningdetail. According to DVB-IP specifications there are two ways to identify DVB-IP
            //services: one ONID + SID based, the other domain/URL based. At this time we don't fully and properly implement the DVB-IP
            //specifications, so the safest method for service identification is the URL. The user has the option to enable the use of
            //ONID + SID identification and channel move detection...
            if (checkBoxEnableChannelMoveDetection.Checked)
            {
              currentDetail = layer.GetTuningDetail(channel.NetworkId, channel.ServiceId,
                                                                 TvBusinessLayer.GetChannelType(channel));
            }
            else
            {
              currentDetail = layer.GetTuningDetail(channel.Url, TvBusinessLayer.GetChannelType(channel));
            }

            if (currentDetail == null)
            {
              //add new channel
              exists = false;
              dbChannel = layer.AddNewChannel(channel.Name, channel.LogicalChannelNumber);
              dbChannel.SortOrder = 10000;
              if (channel.LogicalChannelNumber >= 1)
              {
                dbChannel.SortOrder = channel.LogicalChannelNumber;
              }
              dbChannel.IsTv = channel.IsTv;
              dbChannel.IsRadio = channel.IsRadio;
              dbChannel.Persist();
            }
            else
            {
              exists = true;
              dbChannel = currentDetail.ReferencedChannel();
            }

            layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);

            if (checkBoxCreateGroups.Checked)
            {
              layer.AddChannelToGroup(dbChannel, channel.Provider);
            }
            if (currentDetail == null)
            {
              layer.AddTuningDetails(dbChannel, channel);
            }
            else
            {
              //update tuning details...
              TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail);
              td.Persist();
            }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:66,代码来源:CardDvbIP.cs

示例8: DoScan


//.........这里部分代码省略.........
       if (channels == null || channels.Length == 0)
       {
         if (RemoteControl.Instance.TunerLocked(_cardNumber) == false)
         {
           line = String.Format("physical channel:{0} frequency:{1} modulation:{2}: No signal",
                                tuneChannel.PhysicalChannel, tuneChannel.Frequency, tuneChannel.ModulationType);
           item.Text = line;
           item.ForeColor = Color.Red;
           continue;
         }
         line = String.Format("physical channel:{0} frequency:{1} modulation:{2}: Nothing found",
                              tuneChannel.PhysicalChannel, tuneChannel.Frequency, tuneChannel.ModulationType);
         item.Text = line;
         item.ForeColor = Color.Red;
         continue;
       }
       int newChannels = 0;
       int updatedChannels = 0;
       for (int i = 0; i < channels.Length; ++i)
       {
         Channel dbChannel;
         ATSCChannel channel = (ATSCChannel)channels[i];
         //No support for channel moving, or merging with existing channels here.
         //We do not know how ATSC works to correctly implement this.
         TuningDetail currentDetail = layer.GetTuningDetail(channel);
         if (currentDetail != null)
           if (channel.Frequency != currentDetail.Frequency)
             currentDetail = null;
         bool exists;
         if (currentDetail == null)
         {
           //add new channel
           exists = false;
           dbChannel = layer.AddNewChannel(channel.Name);
           dbChannel.SortOrder = 10000;
           if (channel.LogicalChannelNumber >= 1)
           {
             dbChannel.SortOrder = channel.LogicalChannelNumber;
           }
         }
         else
         {
           exists = true;
           dbChannel = currentDetail.ReferencedChannel();
         }
         dbChannel.IsTv = channel.IsTv;
         dbChannel.IsRadio = channel.IsRadio;
         dbChannel.Persist();
         if (dbChannel.IsTv)
         {
           layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
         }
         if (dbChannel.IsRadio)
         {
           layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
         }
         if (currentDetail == null)
         {
           layer.AddTuningDetails(dbChannel, channel);
         }
         else
         {
           //update tuning details...
           TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail);
           td.Persist();
         }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:67,代码来源:CardAtsc.cs

示例9: DoScan


//.........这里部分代码省略.........
         if (tuneChannel.PhysicalChannel > 0 && !RemoteControl.Instance.TunerLocked(_cardNumber))
         {
           line += "no signal";
         }
         else
         {
           line += "signal locked, no channels found";
         }
         item.Text = line;
         item.ForeColor = Color.Red;
         continue;
       }
       int newChannels = 0;
       int updatedChannels = 0;
       for (int i = 0; i < channels.Length; ++i)
       {
         Channel dbChannel;
         ATSCChannel channel = (ATSCChannel)channels[i];
         //No support for channel moving, or merging with existing channels here.
         //We do not know how ATSC works to correctly implement this.
         TuningDetail currentDetail = layer.GetTuningDetail(channel);
         if (currentDetail != null)
         {
           if (channel.IsDifferentTransponder(layer.GetTuningChannel(currentDetail)))
           {
             currentDetail = null;
           }
         }
         bool exists;
         if (currentDetail == null)
         {
           //add new channel
           exists = false;
           dbChannel = layer.AddNewChannel(channel.Name, channel.LogicalChannelNumber);
           dbChannel.SortOrder = 10000;
           if (channel.LogicalChannelNumber >= 1)
           {
             dbChannel.SortOrder = channel.LogicalChannelNumber;
           }
         }
         else
         {
           exists = true;
           dbChannel = currentDetail.ReferencedChannel();
         }
         dbChannel.IsTv = channel.IsTv;
         dbChannel.IsRadio = channel.IsRadio;
         dbChannel.Persist();
         if (dbChannel.IsTv)
         {
           layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
         }
         if (dbChannel.IsRadio)
         {
           layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
         }
         if (currentDetail == null)
         {
           layer.AddTuningDetails(dbChannel, channel);
         }
         else
         {
           //update tuning details...
           TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail);
           td.Persist();
         }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:67,代码来源:CardAtsc.cs


注:本文中的TvDatabase.TvBusinessLayer.AddNewChannel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。