private bool UpdateGrabberDetails(string channelId, string grabberId) { tbChannelName.Text = null; tbGrabSite.Text = null; tbGrabDays.Text = null; if (channelId != null && grabberId != null) { tbChannelName.Tag = channelId; ChannelConfigInfo info = (ChannelConfigInfo)_hChannelConfigInfo[channelId]; if (info != null) { tbChannelName.Text = info.FullName; Log.Info("WebEPG Config: Selection: {0}", info.FullName); GrabberConfigInfo gInfo = (GrabberConfigInfo)info.GrabberList[grabberId]; if (gInfo != null) { tbGrabSite.Text = gInfo.GrabberName; //tbGrabSite.Tag = gInfo.GrabberID; tbGrabDays.Text = gInfo.GrabDays.ToString(); return(true); } else { tbGrabSite.Text = "(Unknown)"; } } } return(false); }
private void UpdateList() { //update existing channels foreach (ListViewItem channel in lvMapping.Items) { if (_channelMapping.ContainsKey(channel.Text)) { ChannelMap channelDetails = _channelMapping[channel.Text]; string name = string.Empty; if (channelDetails.id != null) { ChannelConfigInfo info = (ChannelConfigInfo)_hChannelConfigInfo[channelDetails.id]; if (info != null) { name = info.FullName; } } else { if (channelDetails.merged != null) { name = "[Merged]"; } } channel.SubItems[1].Text = name; channel.SubItems[2].Text = channelDetails.id; channel.SubItems[3].Text = channelDetails.grabber; } else { int selectedIndex = 0; if (lvMapping.SelectedIndices.Count > 0) { selectedIndex = lvMapping.SelectedIndices[0]; } lvMapping.Items.Remove(channel); if (lvMapping.Items.Count > 0) { if (lvMapping.Items.Count > selectedIndex) { lvMapping.Items[selectedIndex].Selected = true; } else { lvMapping.Items[lvMapping.Items.Count - 1].Selected = true; } } } } lvMapping.Select(); }
private void RedrawList(string selectName) { int selectedIndex = 0; if (lvMapping.SelectedIndices.Count > 0) { selectedIndex = lvMapping.SelectedIndices[0]; } lvMapping.Items.Clear(); //add all channels foreach (ChannelMap channel in _channelMapping.Values) { ListViewItem channelItem = new ListViewItem(channel.displayName); string name = string.Empty; if (channel.id != null) { ChannelConfigInfo info = (ChannelConfigInfo)_hChannelConfigInfo[channel.id]; if (info != null) { name = info.FullName; } } else { if (channel.merged != null) { name = "[Merged]"; } } channelItem.SubItems.Add(name); channelItem.SubItems.Add(channel.id); channelItem.SubItems.Add(channel.grabber); lvMapping.Items.Add(channelItem); } if (lvMapping.Items.Count > 0) { if (lvMapping.Items.Count > selectedIndex) { lvMapping.Items[selectedIndex].Selected = true; } else { lvMapping.Items[lvMapping.Items.Count - 1].Selected = true; } } lvMapping.Sort(); tbCount.Text = lvMapping.Items.Count.ToString(); lvMapping.Select(); }
private void GetGrabbers(ref TreeNode Main, string Location) { DirectoryInfo dir = new DirectoryInfo(Location); Log.Debug("WebEPG Config: Directory: {0}", Location); GrabberConfigInfo gInfo; foreach (FileInfo file in dir.GetFiles("*.xml")) { gInfo = new GrabberConfigInfo(); //XmlDocument xml = new XmlDocument(); GrabberConfigFile grabberXml; try { Log.Debug("WebEPG Config: File: {0}", file.Name); XmlSerializer s = new XmlSerializer(typeof (GrabberConfigFile)); TextReader r = new StreamReader(file.FullName); grabberXml = (GrabberConfigFile)s.Deserialize(r); } catch (Exception) { Log.Info("WebEPG Config: File open failed - XML error"); return; } gInfo.GrabDays = grabberXml.Info.GrabDays; string GrabberSite = file.Name.Replace(".xml", ""); GrabberSite = GrabberSite.Replace("_", "."); gInfo.GrabberID = file.Directory.Name + "\\" + file.Name; gInfo.GrabberName = GrabberSite; gInfo.Country = file.Directory.Name; hGrabberConfigInfo.Add(gInfo.GrabberID, gInfo); if (CountryList[file.Directory.Name] == null) { CountryList.Add(file.Directory.Name, new SortedList()); } TreeNode gNode = new TreeNode(GrabberSite); Main.Nodes.Add(gNode); //XmlNode cl=sectionList.Attributes.GetNamedItem("ChannelList"); foreach (ChannelInfo channel in grabberXml.Channels) { if (channel.id != null) { ChannelConfigInfo info = (ChannelConfigInfo)hChannelConfigInfo[channel.id]; if (info != null) // && info.GrabberList[gInfo.GrabberID] != null) { TreeNode tNode = new TreeNode(info.FullName); tNode.Tag = new GrabberSelectionInfo(info.ChannelID, gInfo.GrabberID); gNode.Nodes.Add(tNode); if (info.GrabberList == null) { info.GrabberList = new SortedList(); } if (info.GrabberList[gInfo.GrabberID] == null) { info.GrabberList.Add(gInfo.GrabberID, gInfo); } } else { info = new ChannelConfigInfo(); info.ChannelID = channel.id; info.FullName = info.ChannelID; info.GrabberList = new SortedList(); info.GrabberList.Add(gInfo.GrabberID, gInfo); hChannelConfigInfo.Add(info.ChannelID, info); TreeNode tNode = new TreeNode(info.FullName); tNode.Tag = new GrabberSelectionInfo(info.ChannelID, gInfo.GrabberID); gNode.Nodes.Add(tNode); } } } } }
private void LoadConfig() { Log.Info("WebEPG Config: Loading Channels"); hChannelConfigInfo = new Hashtable(); TvMappings.HChannelConfigInfo = hChannelConfigInfo; RadioMappings.HChannelConfigInfo = hChannelConfigInfo; if (File.Exists(_webepgFilesDir + "\\channels\\channels.xml")) { Log.Info("WebEPG Config: Loading Existing channels.xml"); Xml xmlreader = new Xml(_webepgFilesDir + "\\channels\\channels.xml"); int channelCount = xmlreader.GetValueAsInt("ChannelInfo", "TotalChannels", 0); for (int i = 0; i < channelCount; i++) { ChannelConfigInfo channel = new ChannelConfigInfo(); channel.ChannelID = xmlreader.GetValueAsString(i.ToString(), "ChannelID", ""); channel.FullName = xmlreader.GetValueAsString(i.ToString(), "FullName", ""); hChannelConfigInfo.Add(channel.ChannelID, channel); } } Log.Info("WebEPG Config: Loading Grabbers"); hGrabberConfigInfo = new Hashtable(); CountryList = new SortedList(); tGrabbers = new TreeNode("Web Sites"); if (Directory.Exists(_webepgFilesDir + "Grabbers")) { GetTreeGrabbers(ref tGrabbers, _webepgFilesDir + "Grabbers"); } else { Log.Info("WebEPG Config: Cannot find grabbers directory"); } IDictionaryEnumerator Enumerator = hChannelConfigInfo.GetEnumerator(); while (Enumerator.MoveNext()) { ChannelConfigInfo info = (ChannelConfigInfo)Enumerator.Value; if (info.ChannelID != null && info.FullName != null) { if (info.GrabberList != null) { IDictionaryEnumerator grabEnum = info.GrabberList.GetEnumerator(); while (grabEnum.MoveNext()) { GrabberConfigInfo gInfo = (GrabberConfigInfo)grabEnum.Value; SortedList chList = (SortedList)CountryList[gInfo.Country]; if (chList[info.ChannelID] == null) { chList.Add(info.ChannelID, gInfo.GrabberID); //CountryList.Remove(gInfo.Country); //CountryList.Add(gInfo.Country, chList); } } } } } }