static void Main(string[] args) { string path = ConfigurationManager.AppSettings["binarypath"]; string exePath = Path.Combine(path, "Update.exe"); string connection = ConfigurationManager.ConnectionStrings["default"].ConnectionString; string localpath = ConfigurationManager.AppSettings["localfolder"]; bool isEC2 = Convert.ToBoolean(ConfigurationManager.AppSettings["isEC2"]); /* * string ftpHost = ConfigurationManager.AppSettings["ftp-host"]; * string ftpUsername = ConfigurationManager.AppSettings["ftp-username"]; * string ftpPassword = ConfigurationManager.AppSettings["ftp-password"]; */ Settings settings = new Settings(5, connection, "", "", "", false, localpath); FeedUpdater updater = new FeedUpdater(settings); updater.ClearOldItems(); updater.Update(); // Shutdown the PC if (isEC2) { Process.Start("shutdown", "/s"); } }
protected override async Task ExecuteAsync(CancellationToken ct) { while (!ct.IsCancellationRequested) { List <int> feedIds = _context.RssFeeds.Select(f => f.Id).ToList(); foreach (var fId in feedIds) { try { _logger.LogInformation($"Updating feed {fId}"); var results = await _feedUpdater.Update(fId, ct); var successCount = results.OfType <MediaFileSuccessResult>().Count(); var errorCount = results.OfType <MediaFileErrorResult>().Count(); _logger.LogInformation($"Updated feed {fId}. Success: {successCount}. Failed: {errorCount}"); } catch (Exception ex) { _logger.LogError(ex, $"Error on updating feed {fId}"); } } await Task.Delay(UpdateTimeout, ct); } }
private void StartThread() { using (NSAutoreleasePool pool = new NSAutoreleasePool()) { FeedUpdater updater = new FeedUpdater(); updater.FeedSaved += new EventHandler(FeedSaved); try { List <Item> newItems = updater.Update(); // Show the progress bar InvokeOnMainThread(delegate { _activityIndicator.StopAnimating(); _progressView.Alpha = 1f; }); // Save all the items to SQLite if (newItems.Count > 0) { _newFeedCount = newItems.Count; updater.SaveItems(newItems); } // Download images if (_newFeedCount > 0 && Settings.Current.UserSettings.ImagesEnabled) { _saveCount = 0; ImageDownloader.Current.ImageSaved += DownloaderImageSaved; ImageDownloader.Current.PreDownloadForCategories(); UpdateProgressAmount(1); } } catch (ThreadAbortException) { // Stop downloads ImageDownloader.Current.TryStop(); } finally { OnLoadingComplete(EventArgs.Empty); } } }