/// <summary> /// Constructor initializes class. /// </summary> /// <param name="applicationName">The Application Name or ID that uses the component. /// This will be used to initialize the user path to store the /// download registry.</param> /// <param name="downloadInfoProvider">The IDownloadInfoProvider instance. It is used to /// request the download informations like proxy or credentials at the time the real /// download is queued.</param> public BackgroundDownloadManager(string applicationName, FeedSource downloadInfoProvider) { applicationId = applicationName; this.downloadInfoProvider = downloadInfoProvider; DownloadRegistryManager.Current.SetBaseFolder(GetUserPath(applicationId)); }
public void Users(int feedId) { FeedSource feed = feedService.GetById(feedId); DataPage <Subscription> list = subscriptionService.GetPage(feedId); bindUserList(feed, list); }
private void downalodFeed(object arg) { FeedSource f = arg as FeedSource; RssItemList articles; try { logger.Info("RssChannel.Create=>" + f.FeedLink); articles = RssChannel.Create(f.FeedLink).RssItems; } catch (Exception ex) { logger.Error("download rss:" + f.FeedLink); logger.Error(ex.Message); return; } //最后更新时间 f.LastRefreshTime = DateTime.Now; db.update(f, "LastRefreshTime"); logger.Info("download feed ok"); RssChannel c = new RssChannel(); c.RssItems = articles; f.RssChannel = c; saveFeedItems(f); }
public void SelectedFeedSourceUsed() { using (var thread = new TemporaryDispatcherThread()) { var feedSource = new FeedSource("http://oo.com", "test source"); var sources = new FeedSource[] { new FeedSource("http://fake.com", "this shouldn't be selected"), feedSource }; var feedSourceStore = new InMemoryFeedSourceStore(feedSource, sources); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.Equal<FeedSource>(packageSourcesViewModel.ActiveFeedSource, viewModel.SelectedFeedSource); } }
public async Task ParseWebResponse(FeedSource source, WebResponse response) { await Console.Error.WriteLineAsync("[Builder/Html] Parsing Html"); // Parse the HTML HtmlDocument html = new HtmlDocument(); using (StreamReader reader = new StreamReader(response.GetResponseStream())) html.LoadHtml(await reader.ReadToEndAsync()); HtmlNode document = html.DocumentNode; document.AbsolutifyUris(new Uri(source.Feed.Url)); await Console.Error.WriteLineAsync("[Builder/Html] Generating feed content"); // Add the title await feed.WriteTitle(ReferenceSubstitutor.Replace(source.Feed.Title, document)); await feed.WriteSubtitle(ReferenceSubstitutor.Replace(source.Feed.Subtitle, document)); // Add the logo if (source.Feed.Logo != null) { HtmlNode logoNode = document.QuerySelector(source.Feed.Logo.Selector); xml.WriteElementString("logo", logoNode.Attributes[source.Feed.Logo.Attribute].Value); } // Add the feed entries foreach (HtmlNode nextNode in document.QuerySelectorAll(source.Entries.Selector)) { await addEntry(source, nextNode); } }
internal int IndexNewsItems(IList <INewsItem> newsItems) { if (newsItems != null) { for (int i = 0; i < newsItems.Count; i++) { INewsItem item = newsItems[i]; if (item != null) { try { // we do not always have the content loaded: if (item.ContentType == ContentType.None && item.Feed != null && item.Feed.owner != null) { if (item.Feed.owner != null) { FeedSource handler = (FeedSource)item.Feed.owner; handler.GetCachedContentForItem(item); } } indexModifier.Add(LuceneNewsItemSearch.Document(item), item.Language); } catch (Exception ex) { Log.Error("IndexNewsItems() error", ex); } } } return(newsItems.Count); } return(0); }
public void CreateViewModel() { using (var thread = new TemporaryDispatcherThread()) { var feedSource = new FeedSource("http://oo.com", "test source"); var feedSourceStore = new InMemoryFeedSourceStore(feedSource); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.False(viewModel.Loading, "The view model should be done loading"); Assert.Equal<FeedSource>(feedSource, viewModel.SelectedFeedSource); } }
/// <summary> /// Adds a FeedSource to the list of NewsHandlers being processed by this Search handler /// </summary> /// <param name="handler"></param> public void AddNewsHandler(FeedSource handler) { if (handler != null) { _feedSources.Add(handler); } }
public void SelectedFeedSourceUsed() { using (var thread = new TemporaryDispatcherThread()) { var feedSource = new FeedSource("http://oo.com", "test source"); var sources = new FeedSource[] { new FeedSource("http://fake.com", "this shouldn't be selected"), feedSource }; var feedSourceStore = new InMemoryFeedSourceStore(feedSource, sources); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.Equal <FeedSource>(packageSourcesViewModel.ActiveFeedSource, viewModel.SelectedFeedSource); } }
public void CreateViewModel() { using (var thread = new TemporaryDispatcherThread()) { var feedSource = new FeedSource("http://oo.com", "test source"); var feedSourceStore = new InMemoryFeedSourceStore(feedSource); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.False(viewModel.Loading, "The view model should be done loading"); Assert.Equal <FeedSource>(feedSource, viewModel.SelectedFeedSource); } }
public void SelectPrereleaseFilter() { using (var thread = new TemporaryDispatcherThread()) { var feedSource = new FeedSource("http://oo.com", "test source"); var feedSourceStore = new InMemoryFeedSourceStore(feedSource); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.Equal <string>(Resources.Prerelease_Filter_StableOnly, viewModel.SelectedPrereleaseFilter); viewModel.SelectedPrereleaseFilter = Resources.Prerelease_Filter_IncludePrerelease; Assert.Equal <string>(Resources.Prerelease_Filter_IncludePrerelease, viewModel.SelectedPrereleaseFilter); } }
public void SelectAnotherFilter() { using (var thread = new TemporaryDispatcherThread()) { var feedSource1 = new FeedSource("http://1.com", "source1"); var feedSource2 = new FeedSource("http://2.com", "source2"); var sources = new FeedSource[] { feedSource1, feedSource2 }; var feedSourceStore = new InMemoryFeedSourceStore(feedSource1, sources); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource1, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.True(viewModel.Filters.Count >= 2, "This test needs at least 2 filters"); Assert.Equal <IListViewFilter>(viewModel.Filters[0], viewModel.SelectedFilter); viewModel.SelectedFilter = viewModel.Filters[1]; Assert.Equal <IListViewFilter>(viewModel.Filters[1], viewModel.SelectedFilter); } }
public void SourceWithPackages() { using (var thread = new TemporaryDispatcherThread()) { var feedSource = new FeedSource("http://1.com", "source1"); var feedSourceStore = new InMemoryFeedSourceStore(feedSource); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var packageManager = new InMemoryPackageManager(); packageManager.RemotePackages.Add(PackageFactory.Create("package1")); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.True(viewModel.Filters.Any(f => f.Count > 0), "One of the filters should have some items"); } }
private FeedSource createNewSource(String url) { FeedSource feedsrc = new FeedSource(); RssChannel rss = RssChannel.Create(url); feedsrc.RssChannel = rss; //----------------------------------- feedsrc.Title = rss.Title; feedsrc.FeedLink = url; feedsrc.Link = rss.Link; feedsrc.Description = rss.Description; feedsrc.BlogLanguage = rss.Language; feedsrc.LastBuildDate = rss.LastBuildDate; if (feedsrc.LastBuildDate == null || feedsrc.LastBuildDate < new DateTime(1900, 1, 1)) { feedsrc.LastBuildDate = DateTime.Now; } feedsrc.PubDate = rss.PubDate; if (feedsrc.PubDate == null || feedsrc.PubDate < new DateTime(1900, 1, 1)) { feedsrc.PubDate = DateTime.Now; } feedsrc.LastRefreshTime = DateTime.Now; feedsrc.Generator = rss.Generator; feedsrc.Created = DateTime.Now; db.insert(feedsrc); return(feedsrc); }
private static ICredentials RebuildCredentials(ICredentials credentials, string redirectUrl) { CredentialCache cc = credentials as CredentialCache; if (cc != null) { IEnumerator iterate = cc.GetEnumerator(); while (iterate.MoveNext()) { NetworkCredential c = iterate.Current as NetworkCredential; if (c != null) { // we just take the first one to recreate string domainUser = c.Domain; if (!string.IsNullOrEmpty(domainUser)) { domainUser = domainUser + @"\"; } domainUser = String.Concat(domainUser, c.UserName); return(FeedSource.CreateCredentialsFrom(redirectUrl, domainUser, c.Password)); } } } // give up/forward original credentials: return(credentials); }
private void saveFeedItems(FeedSource channel) { RssItemList posts = channel.RssChannel.RssItems; for (int i = posts.Count - 1; i >= 0; i--) { RssItem post = posts[i]; FeedEntry entry = new FeedEntry(); entry.FeedSource = channel; entry.Author = post.Author; entry.Category = post.Category; entry.Description = post.Description; entry.Link = post.Link; entry.PubDate = post.PubDate; if (entry.PubDate == null || entry.PubDate < new DateTime(1900, 1, 1)) { entry.PubDate = DateTime.Now; } entry.Title = post.Title; entry.Created = DateTime.Now; FeedEntry savedEntry = entryService.GetByLink(entry.Link); if (savedEntry == null) { db.insert(entry); } } }
public virtual void Create() { String rssLink = ctx.Post("Link"); if (strUtil.IsNullOrEmpty(rssLink)) { echoError("rss url can not be empty"); return; } long categoryId = ctx.PostLong("CategoryId"); FeedSysCategory category = categoryService.GetById(categoryId); String name = ctx.Post("Name"); FeedSource f = feedService.CreateRss(rssLink, name, category); if (f == null) { echoError("create rss error,please try again later"); return; } else { redirect(Index); } }
IEnumerator CreateSpriteFromUrl(FeedSource source, string displayUrl, string caption) { Sprite displaySprite = null; using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(displayUrl)) { yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { Debug.Log(uwr.error); } else { // Get downloaded asset bundle Texture2D texture = DownloadHandlerTexture.GetContent(uwr); displaySprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f); } } if (displayUrl != null) { if (source == FeedSource.Spikeball) { spikeballFeed.AddSpriteToFeed(displaySprite, caption); } else { roundnetFeed.AddSpriteToFeed(displaySprite, caption); } } }
IEnumerator CreateSpriteListForSource(FeedSource source) { string sourceUrl = source == FeedSource.Spikeball ? InstaStructs.SPIKEBALL_URL : InstaStructs.ROUNDNET_URL; string json = ""; // Using the static constructor var request = UnityWebRequest.Get(sourceUrl); // Wait for the response and then get our data yield return(request.SendWebRequest()); json = request.downloadHandler.text; InstaEdge[] edges; if (source == FeedSource.Spikeball) { InstaUserJSON userJSON = Deserialize <InstaUserJSON>(json); edges = userJSON.data.user.edge_owner_to_timeline_media.edges; } else { InstaTagJSON tagJSON = Deserialize <InstaTagJSON>(json); edges = tagJSON.graphql.hashtag.edge_hashtag_to_media.edges; } yield return(GetSpritesForFeed(source, edges)); }
/// <summary> /// Initiate a remote (web) search using the engine incl. search expression specified /// by searchFeedUrl. We assume, the specified Url will return a RSS feed. /// This can be used e.g. to get a RSS search result from feedster. /// </summary> /// <param name="searchFeedUrl">Complete Url of the search engine incl. search expression</param> /// <param name="tag">optional, can be used by the caller</param> public void SearchRemoteFeed(string searchFeedUrl, object tag) { var unreturnedMatchItems = new List <INewsItem>(1); try { unreturnedMatchItems = RssParser.DownloadItemsFromFeed(searchFeedUrl); } catch (Exception remoteSearchException) { unreturnedMatchItems.Add(FeedSource.CreateHelpNewsItemFromException(remoteSearchException)); } int feedmatches = 1; int itemmatches = unreturnedMatchItems.Count; var fi = new FeedInfo(String.Empty, String.Empty, unreturnedMatchItems, String.Empty, String.Empty, String.Empty, new Dictionary <XmlQualifiedName, string>(), String.Empty); var fil = new FeedInfoList(String.Empty) { fi }; RaiseSearchFinishedEvent(tag, fil, feedmatches, itemmatches); }
/// <summary> /// Initializes a new instance of the <see cref="FeedSourceEntry"/> class. /// </summary> /// <param name="id">The id.</param> /// <param name="source">The source.</param> /// <param name="name">The name.</param> /// <param name="ordinal">The ordinal.</param> public FeedSourceEntry(int id, FeedSource source, string name, int ordinal) { ID = id; Name = name; Ordinal = ordinal; Source = source; }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundDownloadManager"/> class. /// </summary> /// <param name="downloadInfoProvider">The IDownloadInfoProvider instance. It is used to /// request the download informations like proxy or credentials at the time the real /// download is queued.</param> public BackgroundDownloadManager(FeedSource downloadInfoProvider) { applicationId = FeedSource.DefaultConfiguration.ApplicationID; this.downloadInfoProvider = downloadInfoProvider; DownloadRegistryManager.Current.SetBaseFolder(FeedSource.DefaultConfiguration.UserLocalApplicationDataPath); }
public void FirstFilterSelected() { using (var thread = new TemporaryDispatcherThread()) { var feedSource = new FeedSource("http://oo.com", "test source"); var feedSourceStore = new InMemoryFeedSourceStore(feedSource); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.Equal <IListViewFilter>(viewModel.Filters[0], viewModel.SelectedFilter); } }
public async Task Print(FeedSource source, string feedFile) { var feedParser = this.feedParserFactory.Create(source); if (feedParser != null) { var fixtures = await feedParser.Parse(feedFile); foreach (var fixture in fixtures) { this.consoleWrapper.WriteLine(seperator); this.consoleWrapper.WriteLine($"{fixture.FixtureName} - {fixture.FixtureDate.ToString("dd-MM-yyyy hh:mm:ss tt")}"); this.consoleWrapper.WriteLine(seperator); this.consoleWrapper.WriteLine(string.Format("{0, -20}{1, -20}{2, -20}", "Type", "Horse", "Price")); var orderedOdds = fixture.FixtureOdds.OrderBy(o => o.Price); foreach (var odd in orderedOdds) { this.consoleWrapper.WriteLine($"{odd.OddType, -20}{odd.HorseName, -20}{odd.Price, -20}"); } } if (!fixtures.Any()) { this.consoleWrapper.WriteLine("No race fixture found."); } } }
/// <summary> /// Initializes a new instance of the <see cref="PostReplyThreadHandler"/> class. /// </summary> /// <param name="feedHandler">The feed handler.</param> /// <param name="commentApiUri">The comment API URI.</param> /// <param name="item2post">The item2post.</param> /// <param name="inReply2item">The in reply2item.</param> public PostReplyThreadHandler(FeedSource feedHandler, string commentApiUri, INewsItem item2post, INewsItem inReply2item) { this.feedHandler = feedHandler; this.commentApiUri = commentApiUri; this.item2post = item2post; this.inReply2item = inReply2item; }
/// <summary> /// Asynchronous download method implementation. /// </summary> /// <param name="task">The DownloadTask to process.</param> public void BeginDownload(DownloadTask task) { currentTask = task; // If we resume way too often, just return if (CheckForResumeAndProceed(currentTask)) { return; } Uri reqUri = new Uri(task.DownloadItem.Enclosure.Url); int priority = 10; RequestParameter reqParam = RequestParameter.Create(reqUri, FeedSource.UserAgentString(String.Empty), task.DownloadItem.Proxy, task.DownloadItem.Credentials, DateTime.MinValue, null); // global cookie handling: reqParam.SetCookies = FeedSource.SetCookies; state = BackgroundDownloadManager.AsyncWebRequest.QueueRequest(reqParam, OnRequestStart, OnRequestComplete, OnRequestException, OnRequestProgress, priority); }
/// <inheritdoc /> public IFeedReader Resolve(FeedSource source) { var type = Assembly.GetAssembly(typeof(FeedReaderResolver)).GetType($"FeedReaders.{source}FeedReader"); var instance = this._provider.GetService(type); return(instance as IFeedReader); }
public IFeed CreateFeed(FeedSource feedSource) { var feedXml = feedSource.SourceType == SearchSource.File ? File.ReadAllLines(feedSource.Source).Aggregate(string.Empty, (current, next) => current + "\r\n" + next).Trim() : this.downloadService.Download(feedSource.Source); return(this.CreateFeed(feedXml)); }
private void bindEdit(FeedSource f, List <FeedSysCategory> categories) { set("feed.Title", f.Title); set("feed.Name", f.Name); set("feed.RssLink", f.FeedLink); long selected = f.Category == null ? 0 : f.Category.Id; dropList("CategoryId", categories, "Name=Id", selected); }
private void PopulateNntpServerDefinition(string nntpServerID) { if (nntpServerID != null && this.nntpServers.Contains(nntpServerID)) { NntpServerDefinition sd = (NntpServerDefinition)this.nntpServers[nntpServerID]; txtNewsAccountName.Text = sd.Name; cboDefaultIdentities.Text = sd.DefaultIdentity; chkConsiderServerOnRefresh.Checked = false; if (sd.PreventDownloadOnRefreshSpecified) { chkConsiderServerOnRefresh.Checked = !sd.PreventDownloadOnRefresh; } txtNewsServerName.Text = sd.Server; string u, p; FeedSource.GetNntpServerCredentials(sd, out u, out p); chkUseAuthentication.Checked = false; txtServerAuthName.Enabled = txtServerAuthPassword.Enabled = false; if (!string.IsNullOrEmpty(u)) { chkUseAuthentication.Checked = true; txtServerAuthName.Enabled = txtServerAuthPassword.Enabled = true; txtServerAuthName.Text = u; txtServerAuthPassword.Text = p; } else { txtServerAuthName.Text = txtServerAuthPassword.Text = String.Empty; } txtServerPort.Text = String.Empty; if (sd.PortSpecified) { txtServerPort.Text = sd.Port.ToString(); } chkUseSSL.Checked = false; if (sd.UseSSLSpecified) { chkUseSSL.Checked = sd.UseSSL; } trackBarServerTimeout.Value = 0; lblCurrentTimout.Text = "0"; if (sd.TimeoutSpecified) { trackBarServerTimeout.Value = sd.Timeout; lblCurrentTimout.Text = sd.Timeout.ToString(); } IList <string> groups = application.LoadNntpNewsGroups(this, sd, false); listOfGroups.Tag = null; this.PopulateNewsGroups(sd, groups, application.CurrentSubscriptions(sd)); } }
public InMemoryFeedSourceStore(FeedSource source, IEnumerable<FeedSource> sources = null) { Assert.NotNull(source); this.Sources = new List<FeedSource>(sources ?? new FeedSource[] { source }); this.SelectedFeed = source; Assert.Contains(this.SelectedFeed, this.Sources); }
public InMemoryFeedSourceStore(FeedSource source, IEnumerable <FeedSource> sources = null) { Assert.NotNull(source); this.Sources = new List <FeedSource>(sources ?? new FeedSource[] { source }); this.SelectedFeed = source; Assert.Contains(this.SelectedFeed, this.Sources); }
private void bindFeedInfo(FeedSource f) { set("feed.Title", f.Title); set("feed.Link", f.Link); set("LastRefreshTime", f.LastRefreshTime); //set( "feed.MemberListUrl", to( Users, f.Id ) ); set("feed.UserCount", f.UserCount); }
private void bindFeedInfo( FeedSource f ) { set( "feed.Title", f.Title ); set( "feed.Link", f.Link ); set( "LastRefreshTime", f.LastRefreshTime ); //set( "feed.MemberListUrl", to( Users, f.Id ) ); set( "feed.UserCount", f.UserCount ); }
public static void AddSource(FeedSource source) { if (!FeedSources.Contains(source)) { FeedSources.Add(source); Services.EventAggregator.GetEvent<Events.FeedSourceAddedEvent>() .Publish(new Events.FeedSourceAddedEventPayload(source)); } else Services.Log("Tried to add FeedSource but it already is added. Url = " + source.UriString, LogPriority.Low, LogCategory.Warning); }
/// <summary> /// Configures all injections. /// </summary> /// <param name="obj"></param> private static void ConfigureInjections(ConfigurationExpression configuration) { configuration.For<IRepository<UserDto>>().HttpContextScoped().Use<Repository<UserDto>>(); configuration.For<IUserRepository>().HttpContextScoped().Use<UserRepository>(); // this is necessary if we would like to use EF for example and make sure no 2 threads will access one DbContext. // For demo purposes, Im using a single source throughout the whole app. configuration.For<IFeedSource>().Singleton().Use((() => { var source = new FeedSource<SimpleNewsGator>(); source.Subscribe(new FeedDispatcher(new FeedItemHub())); source.Start(); return source; })); }
// private void bindFeedItem( FeedSource f, DataPage<FeedEntry> list ) { // String feedTitle = f.Title; // String feedLink = f.Link; // String lastRefreshTime = f.LastRefreshTime.ToString( "g" ); // set( "feed.Title", feedTitle ); // set( "feed.Link", feedLink ); // set( "LastRefreshTime", lastRefreshTime ); // set( "feed.MemberListUrl", to( Users, f.Id ) ); // set( "feed.UserCount", f.UserCount ); // IBlock itemBlock = getBlock( "item" ); // foreach (FeedEntry item in list.Results) { // itemBlock.Set( "item.Title", item.Title ); // itemBlock.Set( "item.Link", to( new EntryController().Show, item.Id ) ); // itemBlock.Set( "item.PubDate", item.PubDate.ToString() ); // itemBlock.Set( "item.Description", item.Abstract ); // itemBlock.Next(); // } // set( "page", list.PageBar ); // } private void bindUserList( FeedSource feed, DataPage<Subscription> list ) { set( "feed.Title", feed.Title ); set( "feed.Link", feed.Link ); IBlock block = getBlock( "list" ); foreach (Subscription sf in list.Results) { block.Set( "member.Name", sf.User.Name ); block.Set( "member.Face", sf.User.PicSmall ); block.Set( "member.Url", Link.ToMember( sf.User ) ); block.Next(); } set( "feed.UserCount", list.RecordCount ); set( "page", list.PageBar ); }
public void NuGetModel_CachingTest() { FeedSource source = new FeedSource(@"c:\", "test"); string destination = @"c:\"; var model = NuGetModel.GetModel(this.Descriptor, new IWebMatrixHostMock(), source, destination, null, TaskScheduler.Default); Assert.False(model.FromCache); model = NuGetModel.GetModel(this.Descriptor, new IWebMatrixHostMock(), source, destination, null, TaskScheduler.Default); Assert.True(model.FromCache); model = null; NuGetModel.ClearCache(); model = NuGetModel.GetModel(this.Descriptor, new IWebMatrixHostMock(), source, destination, null, TaskScheduler.Default); Assert.False(model.FromCache); model = NuGetModel.GetModel(this.Descriptor, new IWebMatrixHostMock(), source, destination, null, TaskScheduler.Default); Assert.True(model.FromCache); }
public EndToEndViewModelTests() { NuGetModel.ClearCache(); this.CloseCommand = new Mock<ICommand>().Object; this.Descriptor = new Mock<INuGetGalleryDescriptor>(); // makes sure tests report a failure if an exception is caught by the view model this.Host = new Mock<IWebMatrixHost>(); this.Host .Setup(host => host.ShowExceptionMessage(null, null, null)) .Throws(new Exception("Test tried to report an error to the user")); this.PackageManager = new InMemoryPackageManager(); var feedSource = new FeedSource("http://oo.com", "test source"); var feedSourceStore = new InMemoryFeedSourceStore(feedSource); this.PackageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); this.ReadonlyDestination = Path.GetFullPath(@".\DO_NOT_WRITE_HERE\"); }
public static void RemoveSource(FeedSource source, bool publish = true) { if (FeedSources.Contains(source)) { FeedSources.Remove(source); if (publish) { Services.EventAggregator.GetEvent<Events.FeedSourceRemovedEvent>() .Publish(new Events.FeedSourceRemovedEventPayload(source)); } } else { //try to remove source with same id var resultsSameId = from s in FeedSources where s.Id == source.Id select s; int countOfSourcesWithSameId = resultsSameId.Count(); IEnumerable<FeedSource> sourcesToRemove = resultsSameId.ToList(); if (countOfSourcesWithSameId > 0) { foreach (FeedSource toRemove in sourcesToRemove) { FeedSources.Remove(toRemove); if (publish) Services.EventAggregator.GetEvent<Events.FeedSourceRemovedEvent>() .Publish(new Events.FeedSourceRemovedEventPayload(toRemove)); } } else { Services.Log("Tried to remove source but it is not in the sources list. Url = " + source.UriString, LogPriority.Low, LogCategory.Warning); } } }
private bool TryParseViaXDocument(FeedSource feedSource, string downloadResult) { bool parsedSuccessfully = true; List<FeedItem> feedItemsToAdd = new List<FeedItem>(); try { XDocument document = XDocument.Parse(downloadResult); var results = from c in document.Root.Element("channel").Elements("item") select c; foreach (var xElement in results) { FeedItem newItem = new FeedItem(); newItem.Summary = xElement.Element("description").Value; newItem.Title = xElement.Element("title").Value; newItem.PostUri = new Uri(xElement.Element("link").Value); newItem.Source = feedSource; feedItemsToAdd.Add(newItem); } } catch (Exception e) { parsedSuccessfully = false; if (feedItemsToAdd != null) feedItemsToAdd.Clear(); Services.Log("SyndicationFeed did not work with url " + feedSource.UriString + "\n" + "Exception.Message: " + e.Message, LogPriority.Low, LogCategory.Information); } if (parsedSuccessfully) { //copy method-scoped feeditems to higher level scope results object foreach (var item in feedItemsToAdd) { _DownloadFeedResults.FeedItems.Add(item); } } return parsedSuccessfully; }
private bool TryParseViaSyndicationFeed(FeedSource downloadRssSource, string downloadResult) { bool parsedSuccessfully = true; List<FeedItem> FeedItemsToAdd = new List<FeedItem>(); try { XmlReader xmlReader = XmlReader.Create(new StringReader(downloadResult)); SyndicationFeed synFeed = SyndicationFeed.Load(xmlReader); foreach (var synFeedItem in synFeed.Items) { if (synFeedItem != null && synFeedItem.Title != null && synFeedItem.Links.Count > 0) { FeedItem FeedItem = new FeedItem(); FeedItem.Title = synFeedItem.Title.Text; if (synFeedItem.Summary != null) FeedItem.Summary = synFeedItem.Summary.Text; //links Uri postUri = null; foreach (var link in synFeedItem.Links) { string relType = link.RelationshipType.ToString(); if (relType == "self" || relType == "replies") continue; else postUri = link.GetAbsoluteUri(); } if (postUri == null) postUri = synFeedItem.Links[0].GetAbsoluteUri(); FeedItem.PostUri = postUri; //FeedItem.PostUri = synFeedItem.Links[0].GetAbsoluteUri(); FeedItem.Source = downloadRssSource; FeedItemsToAdd.Add(FeedItem);//add to method-scoped list first } } } catch (Exception e) { parsedSuccessfully = false; if (FeedItemsToAdd != null) FeedItemsToAdd.Clear(); Services.Log("SyndicationFeed did not work with url " + downloadRssSource.UriString + "\n" + "Exception.Message: " + e.Message, LogPriority.Low, LogCategory.Information); } if (parsedSuccessfully) { //copy method-scoped feeditems to higher level scope results object foreach (var item in FeedItemsToAdd) { _DownloadFeedResults.FeedItems.Add(item); } } return parsedSuccessfully; }
private static Subscription subscribe( FeedCategory category, String name, int orderId, User user, FeedSource feedsrc ) { Subscription subscription = new Subscription(); subscription.FeedSource = feedsrc; subscription.Category = category; subscription.User = user; subscription.Name = strUtil.HasText( name ) ? name : feedsrc.Title; subscription.AppId = category.AppId; subscription.OrderId = orderId; db.insert( subscription ); return subscription; }
private FeedSource createNewSource( String url ) { FeedSource feedsrc = new FeedSource(); RssChannel rss = RssChannel.Create( url ); feedsrc.RssChannel = rss; //----------------------------------- feedsrc.Title = rss.Title; feedsrc.FeedLink = url; feedsrc.Link = rss.Link; feedsrc.Description = rss.Description; feedsrc.BlogLanguage = rss.Language; feedsrc.LastBuildDate = rss.LastBuildDate; if (feedsrc.LastBuildDate == null || feedsrc.LastBuildDate < new DateTime( 1900, 1, 1 )) feedsrc.LastBuildDate = DateTime.Now; feedsrc.PubDate = rss.PubDate; if (feedsrc.PubDate == null || feedsrc.PubDate < new DateTime( 1900, 1, 1 )) feedsrc.PubDate = DateTime.Now; feedsrc.LastRefreshTime = DateTime.Now; feedsrc.Generator = rss.Generator; feedsrc.Created = DateTime.Now; db.insert( feedsrc ); return feedsrc; }
public void SelectAPackage() { using (var thread = new TemporaryDispatcherThread()) { var feedSource = new FeedSource("http://1.com", "source1"); var feedSourceStore = new InMemoryFeedSourceStore(feedSource); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var packageManager = new InMemoryPackageManager(); packageManager.RemotePackages.Add(PackageFactory.Create("package1")); NuGetViewModel viewModel = null; thread.Invoke(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); }); viewModel.WaitUntilComplete(); var filterToSelect = viewModel.Filters.First(f => f.Count > 0); if (viewModel.SelectedFilter != filterToSelect) { viewModel.SelectedFilter = filterToSelect; } Assert.Equal<IListViewFilter>(filterToSelect, viewModel.SelectedFilter); Assert.Null(viewModel.SelectedItem); var itemToSelect = filterToSelect.FilteredItems.OfType<object>().First(); thread.Invoke(() => { viewModel.SelectedItem = itemToSelect; }); Assert.Equal(itemToSelect, viewModel.SelectedItem); Assert.NotNull(itemToSelect); } }
public void DownloadBlogItems( FeedSource f ) { downalodFeed( f ); }
public void FirstFilterSelected() { using (var thread = new TemporaryDispatcherThread()) { var feedSource = new FeedSource("http://oo.com", "test source"); var feedSourceStore = new InMemoryFeedSourceStore(feedSource); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.Equal<IListViewFilter>(viewModel.Filters[0], viewModel.SelectedFilter); } }
private void DownloadFeed(FeedSource source) { if (Services.FeedDownloader == null) throw new Exception(Prez.ErrorMsgNotResolved(typeof(IFeedDownloader).ToString())); Services.FeedDownloader.DownloadFeedsAsync(new List<FeedSource>(){source}, DownloadFeedResultsHandler); }
public void SelectPrereleaseFilter() { using (var thread = new TemporaryDispatcherThread()) { var feedSource = new FeedSource("http://oo.com", "test source"); var feedSourceStore = new InMemoryFeedSourceStore(feedSource); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.Equal<string>(Resources.Prerelease_Filter_StableOnly, viewModel.SelectedPrereleaseFilter); viewModel.SelectedPrereleaseFilter = Resources.Prerelease_Filter_IncludePrerelease; Assert.Equal<string>(Resources.Prerelease_Filter_IncludePrerelease, viewModel.SelectedPrereleaseFilter); } }
private bool TryParseViaXDocumentAtom(FeedSource feedSource, string downloadResult) { bool parsedSuccessfully = true; List<FeedItem> feedItemsToAdd = null; try { XDocument doc = XDocument.Load(downloadResult); // Feed/Entry var entries = from item in doc.Root.Elements().Where(i => i.Name.LocalName == "entry") select new FeedItem { //FeedType = FeedType.Atom, Summary = item.Elements().First(i => i.Name.LocalName == "content").Value, PostUri = new Uri(item.Elements().First(i => i.Name.LocalName == "link").Attribute("href").Value), //PublishDate = ParseDate(item.Elements().First(i => i.Name.LocalName == "published").Value), Title = item.Elements().First(i => i.Name.LocalName == "title").Value }; feedItemsToAdd = entries.ToList(); } catch (Exception e) { parsedSuccessfully = false; if (feedItemsToAdd != null) feedItemsToAdd.Clear(); Services.Log("SyndicationFeed did not work with url " + feedSource.UriString + "\n" + "Exception.Message: " + e.Message, LogPriority.Low, LogCategory.Information); } if (parsedSuccessfully) { //copy method-scoped feeditems to higher level scope results object foreach (var item in feedItemsToAdd) { _DownloadFeedResults.FeedItems.Add(item); } } return parsedSuccessfully; }
public void SelectAnotherFilterHidesDetails() { using (var thread = new TemporaryDispatcherThread()) { var feedSource1 = new FeedSource("http://1.com", "source1"); var feedSource2 = new FeedSource("http://2.com", "source2"); var sources = new FeedSource[] { feedSource1, feedSource2 }; var feedSourceStore = new InMemoryFeedSourceStore(feedSource1, sources); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource1, feedSourceStore)); var packageManager = new InMemoryPackageManager(); packageManager.RemotePackages.Add(PackageFactory.Create("select me")); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); var firstFilter = viewModel.Filters[0]; Assert.True(viewModel.Filters.Count >= 2, "This test needs at least 2 filters"); Assert.Equal<IListViewFilter>(firstFilter, viewModel.SelectedFilter); var itemToSelect = firstFilter.FilteredItems.OfType<object>().First(); thread.Invoke(() => { viewModel.SelectedItem = itemToSelect; // show the details page viewModel.IsDetailsPaneVisible = true; }); viewModel.SelectedFilter = viewModel.Filters[1]; viewModel.WaitUntilComplete(); Assert.Equal<IListViewFilter>(viewModel.Filters[1], viewModel.SelectedFilter); Assert.False(viewModel.IsDetailsPaneVisible, "The details page should be hidden"); } }
public void Update( FeedSource f ) { f.update(); }
public void SelectAnotherFilter() { using (var thread = new TemporaryDispatcherThread()) { var feedSource1 = new FeedSource("http://1.com", "source1"); var feedSource2 = new FeedSource("http://2.com", "source2"); var sources = new FeedSource[] { feedSource1, feedSource2 }; var feedSourceStore = new InMemoryFeedSourceStore(feedSource1, sources); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource1, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.True(viewModel.Filters.Count >= 2, "This test needs at least 2 filters"); Assert.Equal<IListViewFilter>(viewModel.Filters[0], viewModel.SelectedFilter); viewModel.SelectedFilter = viewModel.Filters[1]; Assert.Equal<IListViewFilter>(viewModel.Filters[1], viewModel.SelectedFilter); } }
public Result Delete( FeedSource f ) { List<Subscription> list = db.find<Subscription>( "FeedSource.Id=" + f.Id ).list(); if (list.Count > 0) { return new Result( "can not delete this feed : been subscribed by others" ); } else { return new Result(); } }
private void saveFeedItems( FeedSource channel ) { RssItemList posts = channel.RssChannel.RssItems; for (int i = posts.Count - 1; i >= 0; i--) { RssItem post = posts[i]; FeedEntry entry = new FeedEntry(); entry.FeedSource = channel; entry.Author = post.Author; entry.Category = post.Category; entry.Description = post.Description; entry.Link = post.Link; entry.PubDate = post.PubDate; if (entry.PubDate == null || entry.PubDate < new DateTime( 1900, 1, 1 )) entry.PubDate = DateTime.Now; entry.Title = post.Title; entry.Created = DateTime.Now; FeedEntry savedEntry = entryService.GetByLink( entry.Link ); if (savedEntry == null) { db.insert( entry ); } } }
private void bindEdit( FeedSource f, List<FeedSysCategory> categories ) { set( "feed.Title", f.Title ); set( "feed.Name", f.Name ); set( "feed.RssLink", f.FeedLink ); int selected = f.Category == null ? 0 : f.Category.Id; dropList( "CategoryId", categories, "Name=Id", selected ); }
private void RemoveFeedItemsBelongToSource(FeedSource source) { List<FeedItem> itemsToRemove = new List<FeedItem>(); foreach (var feedItem in FeedItems) { if (feedItem.Source == source) itemsToRemove.Add(feedItem); } foreach (var item in itemsToRemove) { FeedItems.Remove(item); } }
public void PorpSourceToDb(FeedSource source) { if (source == null) throw new ArgumentNullException("source"); //first, get all the sources from the Db. These will be "twin copies": //different instances with the same source properties. ICollection<FeedSource> allSources = GetAllSources(); //now pull out the twin of the updated source var results = from twinSource in allSources where twinSource.Id == source.Id select twinSource; if (results.Count() != 1) throw new Exception(); allSources.Remove(results.ToList()[0]); //now ("re")add the updated source allSources.Add(source); //write back to the Db PorpAllSourcesToDb(allSources); }
public void SelectAnotherSource() { using (var thread = new TemporaryDispatcherThread()) { var feedSource1 = new FeedSource("http://1.com", "source1"); var feedSource2 = new FeedSource("http://2.com", "source2"); var sources = new FeedSource[] { feedSource1, feedSource2 }; var feedSourceStore = new InMemoryFeedSourceStore(feedSource1, sources); var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource1, feedSourceStore)); var packageManager = new InMemoryPackageManager(); NuGetViewModel viewModel = null; thread.Dispatcher.Invoke((Action)(() => { viewModel = new NuGetViewModel( this.Descriptor.Object, this.Host.Object, packageSourcesViewModel, (uri, site) => packageManager, this.ReadonlyDestination, thread.Scheduler); })); viewModel.WaitUntilComplete(); Assert.Equal<FeedSource>(feedSource1, viewModel.SelectedFeedSource); thread.Dispatcher.Invoke((Action)(() => { viewModel.SelectedFeedSourceItem = feedSource2; })); viewModel.WaitUntilComplete(); Assert.Equal<FeedSource>(feedSource2, viewModel.SelectedFeedSource); } }