本文整理汇总了C#中TvDatabase.TvBusinessLayer.MapChannelToCard方法的典型用法代码示例。如果您正苦于以下问题:C# TvBusinessLayer.MapChannelToCard方法的具体用法?C# TvBusinessLayer.MapChannelToCard怎么用?C# TvBusinessLayer.MapChannelToCard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TvDatabase.TvBusinessLayer
的用法示例。
在下文中一共展示了TvBusinessLayer.MapChannelToCard方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Importxmlfile
//.........这里部分代码省略.........
#if(MP13)
try
{
dbChannel.ChannelNumber = Int32.Parse(GetNodeAttribute(nodeChannel, "ChannelNumber", "10000"));
//Ilist string Groupnames
//Group CurrentGroup
//program CurrentProgram
//program NextProgram
}
catch //do nothing
{
}
#endif
dbChannel.Persist();
if (channelcardmappings == true)
{
foreach (XmlNode nodeMap in mappingList)
{
int idCard = Int32.Parse(nodeMap.Attributes["IdCard"].Value);
//get xml position
bool mapflag = false;
for (int j = 1; j <= allXMLcards; j++)
{
if (idCard == cardidpos[j]) //position of card can be different to id
{
if (xmlcardassigned[cardmaptranslator[j]] == true)
{
try
{
layer.MapChannelToCard(TVcards[cardmaptranslator[j]], dbChannel, false);
mapflag = true;
}
catch (Exception exe)
{
textoutput("<RED>Failed to map channel " + dbChannel.DisplayName + " to card id " + cardmaptranslator[j].ToString());
textoutput("<RED>Exception message is " + exe.Message);
}
}
}
}
if (mapflag == false)
{
textoutput("<RED>Failed to map channel " + dbChannel.DisplayName + " to any card");
}
}
}
foreach (XmlNode nodeTune in tuningList)
{
#if (MP12)
#else
int pcrPid = -1;
int audioPid = -1;
int videoPid = -1;
try
{
pcrPid = Int32.Parse(nodeTune.Attributes["PcrPid"].Value);
}
示例2: DoScan
//.........这里部分代码省略.........
if (dbChannel.IsTv)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
if (checkBoxCreateSignalGroup.Checked)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.DVBC);
}
if (checkBoxCreateGroups.Checked)
{
layer.AddChannelToGroup(dbChannel, channel.Provider);
}
}
if (dbChannel.IsRadio)
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
if (checkBoxCreateSignalGroup.Checked)
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.DVBC);
}
if (checkBoxCreateGroups.Checked)
{
layer.AddChannelToRadioGroup(dbChannel, channel.Provider);
}
}
if (currentDetail == null)
{
layer.AddTuningDetails(dbChannel, channel);
}
else
{
//update tuning details...
TuningDetail td = layer.UpdateTuningDetails(dbChannel, channel, currentDetail);
td.Persist();
}
if (channel.IsTv)
{
if (exists)
{
tv.updChannel++;
}
else
{
tv.newChannel++;
tv.newChannels.Add(channel);
}
}
if (channel.IsRadio)
{
if (exists)
{
radio.updChannel++;
}
else
{
radio.newChannel++;
radio.newChannels.Add(channel);
}
}
layer.MapChannelToCard(card, dbChannel, false);
line = String.Format("{0}tp- {1} {2} {3}:New TV/Radio:{4}/{5} Updated TV/Radio:{6}/{7}", 1 + index,
tuneChannel.Frequency, tuneChannel.ModulationType, tuneChannel.SymbolRate,
tv.newChannel, radio.newChannel, tv.updChannel, radio.updChannel);
item.Text = line;
}
tv.updChannelSum += tv.updChannel;
radio.updChannelSum += radio.updChannel;
}
}
catch (Exception ex)
{
Log.Write(ex);
}
finally
{
RemoteControl.Instance.StopCard(user);
RemoteControl.Instance.EpgGrabberEnabled = true;
progressBar1.Value = 100;
scanState = ScanState.Done;
SetButtonState();
}
listViewStatus.Items.Add(
new ListViewItem(String.Format("Total radio channels updated:{0}, new:{1}", radio.updChannelSum,
radio.newChannelSum)));
foreach (IChannel newChannel in radio.newChannels)
{
listViewStatus.Items.Add(new ListViewItem(String.Format(" -> new channel: {0}", newChannel.Name)));
}
listViewStatus.Items.Add(
new ListViewItem(String.Format("Total tv channels updated:{0}, new:{1}", tv.updChannelSum, tv.newChannelSum)));
foreach (IChannel newChannel in tv.newChannels)
{
listViewStatus.Items.Add(new ListViewItem(String.Format(" -> new channel: {0}", newChannel.Name)));
}
ListViewItem lastItem = listViewStatus.Items.Add(new ListViewItem("Scan done..."));
lastItem.EnsureVisible();
}
示例3: DoTvScan
//.........这里部分代码省略.........
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);
}
}
if (dbChannel.IsRadio)
{
layer.AddChannelToGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
if (checkBoxCreateSignalGroup.Checked)
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.Analog);
}
}
if (exists)
{
line = String.Format("channel:{0} source:{1} : Channel update found - {2}", channel.ChannelNumber,
mpComboBoxSource.SelectedItem, channel.Name);
channelsUpdated++;
}
else
{
line = String.Format("channel:{0} source:{1} : New channel found - {2}", channel.ChannelNumber,
mpComboBoxSource.SelectedItem, channel.Name);
channelsNew++;
}
item.Text = line;
}
示例4: importButton_Click
//.........这里部分代码省略.........
}
dbChannel.GrabEpg = grabEpg;
dbChannel.IsRadio = isRadio;
dbChannel.IsTv = isTv;
dbChannel.LastGrabTime = lastGrabTime;
dbChannel.SortOrder = sortOrder;
dbChannel.TimesWatched = timesWatched;
dbChannel.TotalTimeWatched = totalTimeWatched;
dbChannel.VisibleInGuide = visibileInGuide;
dbChannel.DisplayName = displayName;
dbChannel.Persist();
//
// chemelli: When we import channels we need to add those to the "AllChannels" group
//
if (isTv)
{
layer.AddChannelToGroup(dbChannel, TvConstants.TvGroupNames.AllChannels);
}
else
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
}
foreach (XmlNode nodeMap in mappingList)
{
int idCard = Int32.Parse(nodeMap.Attributes["IdCard"].Value);
XmlNode nodeCard =
doc.SelectSingleNode(String.Format("/tvserver/servers/server/cards/card[@IdCard={0}]", idCard));
Card dbCard = layer.GetCardByDevicePath(nodeCard.Attributes["DevicePath"].Value);
if (dbCard != null)
{
layer.MapChannelToCard(dbCard, dbChannel, false);
}
}
foreach (XmlNode nodeTune in tuningList)
{
int bandwidth = Int32.Parse(nodeTune.Attributes["Bandwidth"].Value);
int channelNumber = Int32.Parse(nodeTune.Attributes["ChannelNumber"].Value);
int channelType = Int32.Parse(nodeTune.Attributes["ChannelType"].Value);
int countryId = Int32.Parse(nodeTune.Attributes["CountryId"].Value);
int diseqc = Int32.Parse(nodeTune.Attributes["Diseqc"].Value);
bool fta = (nodeTune.Attributes["FreeToAir"].Value == "True");
int frequency = Int32.Parse(nodeTune.Attributes["Frequency"].Value);
int majorChannel = Int32.Parse(nodeTune.Attributes["MajorChannel"].Value);
int minorChannel = Int32.Parse(nodeTune.Attributes["MinorChannel"].Value);
int modulation = Int32.Parse(nodeTune.Attributes["Modulation"].Value);
string name = nodeTune.Attributes["Name"].Value;
int networkId = Int32.Parse(nodeTune.Attributes["NetworkId"].Value);
int pmtPid = Int32.Parse(nodeTune.Attributes["PmtPid"].Value);
int polarisation = Int32.Parse(nodeTune.Attributes["Polarisation"].Value);
string provider = GetNodeAttribute(nodeTune, "Provider", "");
int serviceId = Int32.Parse(nodeTune.Attributes["ServiceId"].Value);
int switchingFrequency = Int32.Parse(nodeTune.Attributes["SwitchingFrequency"].Value);
int symbolrate = Int32.Parse(nodeTune.Attributes["Symbolrate"].Value);
int transportId = Int32.Parse(nodeTune.Attributes["TransportId"].Value);
int tuningSource = Int32.Parse(GetNodeAttribute(nodeTune, "TuningSource", "0"));
int videoSource = Int32.Parse(GetNodeAttribute(nodeTune, "VideoSource", "0"));
int audioSource = Int32.Parse(GetNodeAttribute(nodeTune, "AudioSource", "0"));
bool isVCRSignal = (GetNodeAttribute(nodeChannel, "IsVCRSignal", "False") == "True");
int SatIndex = Int32.Parse(GetNodeAttribute(nodeTune, "SatIndex", "-1"));
int InnerFecRate = Int32.Parse(GetNodeAttribute(nodeTune, "InnerFecRate", "-1"));
int band = Int32.Parse(GetNodeAttribute(nodeTune, "Band", "0"));
int pilot = Int32.Parse(GetNodeAttribute(nodeTune, "Pilot", "-1"));
int rollOff = Int32.Parse(GetNodeAttribute(nodeTune, "RollOff", "-1"));
示例5: DoRadioScan
//.........这里部分代码省略.........
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);
channelsNew++;
}
item.Text = line;
dbChannel.IsTv = channel.IsTv;
dbChannel.IsRadio = channel.IsRadio;
dbChannel.Persist();
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.AllChannels);
if (checkBoxCreateSignalGroup.Checked)
{
layer.AddChannelToRadioGroup(dbChannel, TvConstants.RadioGroupNames.Analog);
}
layer.AddTuningDetails(dbChannel, channel);
layer.MapChannelToCard(card, dbChannel, false);
freq += 300000;
}
else
{
line = String.Format("frequence:{0} MHz : No Signal", freqMHz.ToString("f2"));
item.Text = line;
item.ForeColor = Color.Red;
}
}
}
catch (Exception ex)
{
Log.Write(ex);
}
finally
{
checkButton.Enabled = true;
IUser user = new User();
user.CardId = _cardNumber;
RemoteControl.Instance.StopCard(user);
RemoteControl.Instance.EpgGrabberEnabled = true;
mpButtonScanRadio.Text = buttonText;
progressBar1.Value = 100;
mpComboBoxCountry.Enabled = true;
mpComboBoxSource.Enabled = true;
mpComboBoxSensitivity.Enabled = true;
checkBoxCreateSignalGroup.Enabled = true;
checkBoxNoMerge.Enabled = true;
mpButtonScanTv.Enabled = true;
mpButtonScanRadio.Enabled = true;
mpButtonAddSvideoChannels.Enabled = true;
_isScanning = false;
}
ListViewItem lastItem =
mpListView1.Items.Add(
new ListViewItem(String.Format("Total radio channels new:{0} updated:{1}", channelsNew, channelsUpdated)));
lastItem.EnsureVisible();
}
示例6: 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();
//.........这里部分代码省略.........
示例7: DoScan
//.........这里部分代码省略.........
{
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();
}
if (channel.IsTv)
{
if (exists)
{
tvChannelsUpdated++;
updatedChannels++;
}
else
{
tvChannelsNew++;
newChannels++;
}
}
if (channel.IsRadio)
{
if (exists)
{
radioChannelsUpdated++;
updatedChannels++;
}
else
{
radioChannelsNew++;
newChannels++;
}
}
layer.MapChannelToCard(card, dbChannel, false);
line = String.Format("{0}- {1} :New:{2} Updated:{3}", 1 + index, tuneChannel.Name, newChannels,
updatedChannels);
item.Text = line;
}
}
//DatabaseManager.Instance.SaveChanges();
}
catch (Exception ex)
{
Log.Write(ex);
}
finally
{
RemoteControl.Instance.StopCard(user);
RemoteControl.Instance.EpgGrabberEnabled = true;
progressBar1.Value = 100;
mpComboBoxService.Enabled = true;
checkBoxCreateGroups.Enabled = true;
checkBoxEnableChannelMoveDetection.Enabled = true;
mpButtonScanTv.Text = buttonText;
_isScanning = false;
}
ListViewItem lastItem = listViewStatus.Items.Add(new ListViewItem("Scan done..."));
lastItem =
listViewStatus.Items.Add(
new ListViewItem(String.Format("Total radio channels new:{0} updated:{1}", radioChannelsNew,
radioChannelsUpdated)));
lastItem =
listViewStatus.Items.Add(
new ListViewItem(String.Format("Total tv channels new:{0} updated:{1}", tvChannelsNew, tvChannelsUpdated)));
lastItem.EnsureVisible();
}
示例8: mpButtonMap_Click
private void mpButtonMap_Click(object sender, EventArgs e)
{
NotifyForm dlg = new NotifyForm("Mapping selected channels to TV-Card...",
"This can take some time\n\nPlease be patient...");
dlg.Show(this);
dlg.WaitForDisplay();
Card card = ((CardInfo)mpComboBoxCard.SelectedItem).Card;
mpListViewChannels.BeginUpdate();
mpListViewMapped.BeginUpdate();
try
{
ListView.SelectedListViewItemCollection selectedItems = mpListViewChannels.SelectedItems;
TvBusinessLayer layer = new TvBusinessLayer();
foreach (ListViewItem item in selectedItems)
{
Channel channel = (Channel)item.Tag;
ChannelMap map = layer.MapChannelToCard(card, channel, mpCheckBoxMapForEpgOnly.Checked);
mpListViewChannels.Items.Remove(item);
string displayName = channel.DisplayName;
if (mpCheckBoxMapForEpgOnly.Checked)
displayName = channel.DisplayName + " (EPG Only)";
ListViewItem newItem = mpListViewMapped.Items.Add(displayName, item.ImageIndex);
newItem.Tag = map;
}
mpListViewMapped.Sort();
dlg.Close();
}
finally
{
mpListViewChannels.EndUpdate();
mpListViewMapped.EndUpdate();
}
//DatabaseManager.Instance.SaveChanges();
}
示例9: mpButtonMap_Click_1
private void mpButtonMap_Click_1(object sender, EventArgs e)
{
NotifyForm dlg = new NotifyForm("Mapping selected channels to TV-Card...",
"This can take some time\n\nPlease be patient...");
dlg.Show(this);
dlg.WaitForDisplay();
Card card = ((CardInfo)mpComboBoxCard.SelectedItem).Card;
mpListViewChannels.BeginUpdate();
mpListViewMapped.BeginUpdate();
try
{
ListView.SelectedListViewItemCollection selectedItems = mpListViewChannels.SelectedItems;
TvBusinessLayer layer = new TvBusinessLayer();
foreach (ListViewItem item in selectedItems)
{
Channel channel = (Channel)item.Tag;
ChannelMap map = layer.MapChannelToCard(card, channel, false);
mpListViewChannels.Items.Remove(item);
ListViewItem newItem = mpListViewMapped.Items.Add(channel.DisplayName, item.ImageIndex);
newItem.Tag = map;
}
dlg.Close();
}
finally
{
mpListViewChannels.EndUpdate();
mpListViewMapped.EndUpdate();
}
}
示例10: DoScan
//.........这里部分代码省略.........
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();
}
if (channel.IsTv)
{
if (exists)
{
tvChannelsUpdated++;
updatedChannels++;
}
else
{
tvChannelsNew++;
newChannels++;
}
}
if (channel.IsRadio)
{
if (exists)
{
radioChannelsUpdated++;
updatedChannels++;
}
else
{
radioChannelsNew++;
newChannels++;
}
}
layer.MapChannelToCard(card, dbChannel, false);
line = String.Format("physical channel:{0} frequency:{1} modulation:{2} New:{3} Updated:{4}",
tuneChannel.PhysicalChannel, tuneChannel.Frequency, tuneChannel.ModulationType,
newChannels, updatedChannels);
item.Text = line;
}
}
//DatabaseManager.Instance.SaveChanges();
}
catch (Exception ex)
{
Log.Write(ex);
}
finally
{
IUser user = new User();
user.CardId = _cardNumber;
RemoteControl.Instance.StopCard(user);
RemoteControl.Instance.EpgGrabberEnabled = true;
progressBar1.Value = 100;
checkBoxQAM.Enabled = true;
mpComboBoxFrequencies.Enabled = true;
mpButtonScanTv.Text = buttonText;
_isScanning = false;
}
listViewStatus.Items.Add(
new ListViewItem(String.Format("Total radio channels new:{0} updated:{1}", radioChannelsNew,
radioChannelsUpdated)));
listViewStatus.Items.Add(
new ListViewItem(String.Format("Total tv channels new:{0} updated:{1}", tvChannelsNew, tvChannelsUpdated)));
ListViewItem lastItem = listViewStatus.Items.Add(new ListViewItem("Scan done..."));
lastItem.EnsureVisible();
}
示例11: DoScan
//.........这里部分代码省略.........
{
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();
}
if (channel.IsTv)
{
if (exists)
{
tvChannelsUpdated++;
updatedChannels++;
}
else
{
tvChannelsNew++;
newChannels++;
}
}
if (channel.IsRadio)
{
if (exists)
{
radioChannelsUpdated++;
updatedChannels++;
}
else
{
radioChannelsNew++;
newChannels++;
}
}
layer.MapChannelToCard(card, dbChannel, false);
}
line += string.Format("new = {0}, updated = {1}", newChannels, updatedChannels);
item.Text = line;
Log.Info("ATSC: scan result, new = {0}, updated = {1}", newChannels, updatedChannels);
}
}
catch (Exception ex)
{
Log.Write(ex);
}
finally
{
IUser user = new User();
user.CardId = _cardNumber;
RemoteControl.Instance.StopCard(user);
RemoteControl.Instance.EpgGrabberEnabled = true;
progressBar1.Value = 100;
mpComboBoxTuningMode.Enabled = true;
UpdateQamFrequencyFieldAvailability();
mpButtonScanTv.Text = buttonText;
_isScanning = false;
}
listViewStatus.Items.Add(
new ListViewItem(String.Format("Total radio channels, new = {0}, updated = {1}", radioChannelsNew,
radioChannelsUpdated)));
listViewStatus.Items.Add(
new ListViewItem(String.Format("Total TV channels, new = {0} updated = {1}", tvChannelsNew, tvChannelsUpdated)));
ListViewItem lastItem = listViewStatus.Items.Add(new ListViewItem("Scan done!"));
lastItem.EnsureVisible();
Log.Info("ATSC: scan summary, new TV = {0}, updated TV = {1}, new radio = {2}, updated radio = {3}", tvChannelsNew, tvChannelsUpdated, radioChannelsNew, radioChannelsUpdated);
}