public OPML GetOPML() { string locality = ""; string country = ""; string givenname = ""; string surname = ""; AuthorizationContext ctx = OperationContext.Current.ServiceSecurityContext.AuthorizationContext; foreach (ClaimSet claimSet in ctx.ClaimSets) { foreach (Claim claim in claimSet) { if (claim.ClaimType == ClaimTypes.Locality) { locality = claim.Resource.ToString(); } if (claim.ClaimType == ClaimTypes.Country) { country = claim.Resource.ToString(); } if (claim.ClaimType == ClaimTypes.GivenName) { givenname = claim.Resource.ToString(); } if (claim.ClaimType == ClaimTypes.Surname) { surname = claim.Resource.ToString(); } } } Rss.OPML opml = new OPML(@"C:\temp\top100withimages.opml"); return(opml); }
private void DisplayOutlinesInControl(OPML opml) { dgvOPML.Rows.Clear(); int gridRowNbr = 0; int ParentIndex = 0; Color evenRowColorValue = Color.AliceBlue; Color oddRowColorValue = Color.LightSteelBlue; foreach (OPMLOutline outline in opml.Body.Outlines) { DataGridViewRow row = new DataGridViewRow(); DataGridViewCheckBoxCell check = new DataGridViewCheckBoxCell(); DataGridViewTextBoxCell count = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell text = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell categories = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell description = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell xmlUrl = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell type = new DataGridViewTextBoxCell(); DataGridViewTextBoxCell version = new DataGridViewTextBoxCell(); row.DefaultCellStyle.Font = this.Font; if (gridRowNbr % 2 == 0) { row.DefaultCellStyle.BackColor = oddRowColorValue; } else { row.DefaultCellStyle.BackColor = evenRowColorValue; } //Set the tag value for the row to the outline element row.Tag = outline; text.Value = outline.Text; //Set the tool tile to the description text.ToolTipText = outline.Description; categories.Value = outline.Categories; description.Value = outline.Description; xmlUrl.Value = outline.XmlUrl; type.Value = outline.Type; version.Value = outline.Version; row.Cells.Add(check); row.Cells.Add(text); row.Cells.Add(categories); row.Cells.Add(description); row.Cells.Add(xmlUrl); row.Cells.Add(type); row.Cells.Add(version); dgvOPML.Rows.Add(row); gridRowNbr++; } }
internal static OPML ToOPML(DataRow dr) { var o = new OPML { Id = dr.ToIntOrZero("Id"), UserId = dr.ToIntOrZero("UserId"), FileName = dr.ToStringOrNull("FileName"), Parsed = dr.ToBoolOrFase("Parsed"), Date = dr.ToDateTimeOrMinValue("Date") }; return(o); }
static void Main(string[] args) { var helper = new OPML("/Users/faschenk/Downloads/sql-server.opml.xml"); foreach (var item in helper.outlines) { Console.WriteLine(item.Title); foreach (var feed in item.Feeds) { Console.WriteLine(feed.Title + ": " + feed.Found); } } Console.WriteLine("Hello World!"); }
private async void ExportOPML(RoutedEventArgs e) { OPML opml = new OPML(); try { XDocument doc = opml.Export(_allData); SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = ".opml"; sfd.Filter = "OPML Files (*.opml)|*.opml"; if (sfd.ShowDialog() == true) { doc.Save(sfd.FileName); } } catch (Exception ex) { IsBrowserVisible = false; RaisePropertyChanged("IsBrowserVisible"); await _dialogCoordinator.ShowMessageAsync(this, "Export OPML", "Unable to export: " + ex.Message); } }
public async Task <IActionResult> ImportOPML([FromBody] XmlString xml) { OPML feeds = new OPML(xml.xml); return(Ok(feeds.outlines)); }
private Dictionary <string, List <Feed> > GetFeeds(OPML opml) { var result = new Dictionary <string, List <Feed> >(); string fileLoc = System.Diagnostics.Debugger.IsAttached ? @"D:\Dropbox\Projects\RSSReader\Web\OPML" : @"C:\websites\rssheap\OPML"; string xml = File.ReadAllText(Path.Combine(fileLoc, opml.FileName)); var htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.LoadHtml(xml); var outlines = htmlDoc.DocumentNode.SelectNodes("//outline"); if (outlines == null) { return(null); } foreach (var outline in outlines) { var attr = outline.Attributes["xmlUrl"]; if (attr == null) //it is a folder { var folderName = outline.Attributes["title"] != null ? outline.Attributes["title"].Value : string.Empty; if (folderName.IsNullOrEmpty()) { folderName = outline.Attributes["text"] != null ? outline.Attributes["text"].Value : string.Empty; } if (folderName.IsNullOrEmpty()) { folderName = string.Empty; } //maybe it is in format outline and than outline var innerOutlines = outline.SelectNodes("//outline"); if (outlines == null) { continue; } foreach (var innerOutline in innerOutlines) { var url = innerOutline.Attributes.FirstOrDefault(a => !a.Value.IsNullOrEmpty() && a.Name.ToLower() == "xmlurl"); if (url != null) { var siteUrlAttr = innerOutline.Attributes.FirstOrDefault(a => !a.Value.IsNullOrEmpty() && a.Name.ToLower() == "htmlurl"); var siteUrl = siteUrlAttr != null ? siteUrlAttr.Value : string.Empty; var feed = new Feed { Url = url.Value, SiteUrl = siteUrl }; if (result.ContainsKey(folderName)) { var feeds = result[folderName]; if (feeds == null) { feeds = new List <Feed>(); } feeds.Add(feed); } else { result.Add(folderName, new List <Feed> { feed }); } } } } else { string url = attr.Value; var siteUrl = outline.Attributes["htmlUrl"] != null ? outline.Attributes["htmlUrl"].Value : string.Empty; var feed = new Feed { Url = url, SiteUrl = siteUrl }; if (result.ContainsKey("")) { var feeds = result[""]; if (feeds == null) { feeds = new List <Feed>(); } feeds.Add(feed); } else { result.Add("", new List <Feed> { feed }); } } } return(result); }
private async void ImportOPML(RoutedEventArgs e) { try { OPML opml = new OPML(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Multiselect = false; openFileDialog.DefaultExt = ".opml"; openFileDialog.Filter = "OPML Files (*.opml)|*.opml"; Exception exc = null; if (openFileDialog.ShowDialog() == true) { List<Feed> t = opml.Import(openFileDialog.FileName); foreach (Feed f in t) { try { Data.Feed feed = new Data.Feed(f); feed.Location = f.Location; feed.Save(false); } catch (Exception ee) { exc = ee; } } // Reload tree InitializeData(true); await _dialogCoordinator.ShowMessageAsync(this, "Import OPML", "OPML imported successfully. Allow some minutes to let feed titles update from the RSS feed."); // Update details from the uri Task updaterTask = Task.Factory.StartNew(async () => { _updaterInPause = true; foreach (Feed f in t) { try { Data.Feed feed = new Data.Feed(f); feed.Location = f.Location; feed.UpdateFromUri(true, RetentionDays); feed.Save(true); } catch (Exception ee) { exc = ee; } } _updaterInPause = false; InitializeData(true); if (exc != null) await _dialogCoordinator.ShowMessageAsync(this, "Import OPML", "Unable to update feeds: " + exc.Message); }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); if (exc != null) throw exc; } } catch (Exception ex) { IsBrowserVisible = false; RaisePropertyChanged("IsBrowserVisible"); await _dialogCoordinator.ShowMessageAsync(this, "Import OPML", "Unable to import: " + ex.Message); } }
private async void ImportOPML(RoutedEventArgs e) { try { OPML opml = new OPML(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Multiselect = false; openFileDialog.DefaultExt = ".opml"; openFileDialog.Filter = "OPML Files (*.opml)|*.opml"; Exception exc = null; if (openFileDialog.ShowDialog() == true) { List <Feed> t = opml.Import(openFileDialog.FileName); foreach (Feed f in t) { try { Data.Feed feed = new Data.Feed(f); feed.Location = f.Location; feed.Save(false); } catch (Exception ee) { exc = ee; } } // Reload tree InitializeData(true); await _dialogCoordinator.ShowMessageAsync(this, "Import OPML", "OPML imported successfully. Allow some minutes to let feed titles update from the RSS feed."); // Update details from the uri Task updaterTask = Task.Factory.StartNew(async() => { _updaterInPause = true; foreach (Feed f in t) { try { Data.Feed feed = new Data.Feed(f); feed.Location = f.Location; feed.UpdateFromUri(true, RetentionDays); feed.Save(true); } catch (Exception ee) { exc = ee; } } _updaterInPause = false; InitializeData(true); if (exc != null) { await _dialogCoordinator.ShowMessageAsync(this, "Import OPML", "Unable to update feeds: " + exc.Message); } }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); if (exc != null) { throw exc; } } } catch (Exception ex) { IsBrowserVisible = false; RaisePropertyChanged("IsBrowserVisible"); await _dialogCoordinator.ShowMessageAsync(this, "Import OPML", "Unable to import: " + ex.Message); } }