private void OnParseDone(RSSWorkStatus status) { Core.UserInterfaceAP.QueueJobAt(DateTime.Now.AddSeconds(1), new MethodInvoker(_statusWriter.ClearStatus)); Trace.WriteLineIf(Settings.Trace, "Finished parse of " + _httpReader.URL + " with status " + status); _status = status; if (ParseDone != null) { ParseDone(this, EventArgs.Empty); } }
public RSSUnitOfWork(IResource feed, bool parseItems, bool acceptHtmlIfXmlError) { Trace.WriteLineIf(Settings.Trace, "Starting update of feed " + feed.DisplayName); _feed = feed; _parseItems = parseItems; _acceptHtmlIfXmlError = acceptHtmlIfXmlError; _statusWriter = Core.UIManager.GetStatusWriter(this, StatusPane.Network); string feedUrl = feed.GetStringProp(Props.URL); if (!HttpReader.IsSupportedProtocol(feedUrl)) { throw new ArgumentException("Unsupported feed protocol: " + feedUrl); } if (parseItems) { FavIconManager favIconManager = (FavIconManager)Core.GetComponentImplementation(typeof(FavIconManager)); favIconManager.DownloadFavIcon(feedUrl); } _httpReader = new HttpReader(feedUrl); string etag = feed.GetPropText(Props.ETag); if (etag.Length > 0) { _httpReader.IfNoneMatch = etag; } string httpUserName = feed.GetStringProp(Props.HttpUserName); string httpPassword = feed.GetStringProp(Props.HttpPassword); if (httpUserName != null && httpPassword != null) { _httpReader.Credentials = new NetworkCredential(httpUserName, httpPassword); } _httpReader.AcceptInstanceManipulation = "feed"; if (_feed.HasProp(Props.DisableCompression) || Settings.DisableCompression) { _httpReader.AcceptEncoding = null; } _httpReader.CookieProvider = CookiesManager.GetUserCookieProvider(typeof(RSSUnitOfWork)); _status = RSSWorkStatus.NotStarted; Timeout = Settings.TimeoutInSec * 1000; OnTimeout += RSSUnitOfWork_OnTimeout; }
protected override void Execute() { if (_status == RSSWorkStatus.NotStarted) { ResourceProxy proxy = new ResourceProxy(_feed); // the immediate priority is required to make sure that the resource job to set // (updating) status is executed before the parse job, which also has // immediate priority proxy.AsyncPriority = JobPriority.Immediate; proxy.SetPropAsync(Props.UpdateStatus, "(updating)"); _status = RSSWorkStatus.InProgress; } RSSLoadDelegate(); }
private void JobParseDone(object sender, EventArgs e) { RSSUnitOfWork job = (RSSUnitOfWork)sender; if (job.Status != RSSWorkStatus.Success) { Trace.WriteLine("MultipleFeedsJob -- JobParseDone failed with code " + _currStatus); _failedFeeds.Add(job.Feed); _lastException = job.LastException; } // Update status if only previous iterations were successful. // Otherwise keep the fact that an error has already occured. // This is necessary in the case when some is parsed correctly // after the errorneous one. if (_currStatus == RSSWorkStatus.Success) { _currStatus = job.Status; } }
private void ShowErrorInformation(RSSWorkStatus status, Exception lastException) { if (status == RSSWorkStatus.FoundXML) { ShowErrorInformation("The specified URL points to an XML file which is not an RSS or ATOM feed", string.Empty); } else if (status == RSSWorkStatus.XMLError) { ShowErrorInformation("The address does not point to a valid HTML or XML page", lastException.Message); } else if (lastException != null) { ShowErrorInformation(lastException.Message, string.Empty); } else { ShowErrorInformation("Unknown Error", string.Empty); } }
public override void EnumerationStarting() { _currStatus = RSSWorkStatus.Success; }