static void Main(string[] args) { ConfigureLogger(); var logger = new Logger(nameof(Program)); try { var feedService = new RssFeedUpdaterService(logger); var userDao = new UserDAO(Configuration.GetConnectionString()); var feedDao = new FeedDAO(Configuration.GetConnectionString()); var deletedUserIds = userDao.DeleteOldUsersAsync().Result; foreach (var userId in deletedUserIds) { feedDao.DeleteAsync(userId).Wait(); } feedService.UpdateAsync().Wait(); } catch (Exception ex) { logger.Log(ex); if (ex.InnerException != null) { logger.Log(ex.InnerException); } } }
/// <summary> /// Run. /// </summary> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public static async Task RunAsync() { var logger = new Logger(nameof(UpdateFeedsJob)); try { var feedService = new RssFeedUpdaterService(logger); var userDao = new UserDAO(Configuration.GetConnectionString()); var feedDao = new FeedDAO(Configuration.GetConnectionString()); var deletedUserIds = await userDao.DeleteOldUsersAsync(); foreach (var userId in deletedUserIds) { await feedDao.DeleteAsync(userId); } await feedService.UpdateAsync(); } catch (Exception ex) { logger.Log(ex); if (ex.InnerException != null) { logger.Log(ex.InnerException); } } }
/// <summary> /// Initializes a new instance of the <see cref="RssFeedService"/> class. /// </summary> /// <param name="currentUserProvider">CurrentUserProvider.</param> /// <param name="logger">Logger.</param> public RssFeedService(ICurrentUserProvider currentUserProvider, ILogger logger) { this.seriesDAO = new SeriesDAO(Configuration.GetConnectionString()); this.feedDAO = new FeedDAO(Configuration.GetConnectionString()); this.userDAO = new UserDAO(Configuration.GetConnectionString()); this.currentUserProvider = currentUserProvider; this.torrentFileDownloader = new TorrentFileDownloader(new TorrentFileDAO(Configuration.GetTorrentPath(), logger), logger); }
/// <summary> /// Initializes a new instance of the <see cref="RssFeedUpdaterService"/> class. /// </summary> /// <param name="logger">Logger.</param> public RssFeedUpdaterService(ILogger logger) { var connectionString = Configuration.GetConnectionString(); this.logger = logger != null?logger.CreateScope(nameof(RssFeedUpdaterService)) : throw new ArgumentNullException(nameof(logger)); this.reteOrgRssFeed = new ReteOrgRssFeed(logger); this.feedDAO = new FeedDAO(connectionString); this.seriesCoverService = new SeriesCoverService(logger); this.seriesDAO = new SeriesDAO(connectionString); this.subscriptionDAO = new SubscriptionDAO(connectionString); }
public async Task <IEnumerable <string> > GetFollowersAsync() { var session = auth.SessionId; var user = auth.UserName; using (var dao = new FeedDAO(config)) { var result = await dao.GetFollowersAsync(user, session); var followers = result.data; return(followers.Select(f => f.user.name)); } }
private static void TestDAOs() { UserDAO userDAO = new UserDAO(); //userDAO.Add(new User() { // Username = "******", // Name = "Jonatan 2" //}, "prueba"); var user = userDAO.Login("jonifer", "abc123."); Console.WriteLine(user?.Name); FeedDAO feedDAO = new FeedDAO(); var feeds = feedDAO.FindAllByUser(user); foreach (var feed in feeds) { Console.WriteLine("Feed[id={0}, name={1}, url={2}]", feed.Id, feed.Name, feed.Url); } FilterDAO filterDAO = new FilterDAO(); var filter = new Filter() { Name = "Filtro de prueba", Text = "prueba", User = user, Feeds = feeds }; filterDAO.Add(filter); Console.WriteLine("=== Se ha insertado el filtro {0} ===", filter.Id); var filters = filterDAO.FindAllByUser(user); foreach (var filterAux in filters) { Console.WriteLine("Filter[id={0}, name={1}, text={2}]", filterAux.Id, filterAux.Name, filterAux.Text); foreach (var feed in filterAux.Feeds) { Console.WriteLine("Feed[id={0}, name={1}, url={2}]", feed.Id, feed.Name, feed.Url); } } }
public async Task <bool> UnfollowAsync(string username) { var session = auth.SessionId; using (var dao = new FeedDAO(config)) { var result = await dao.UnfollowAsync(username, session); var response = result.data; if (result.result.ToLower() == "ok") { return(true); } else { return(false); } } }
/// <summary> Retrieves Entity rows in a datatable which match the specified filter. It will always create a new connection to the database.</summary> /// <param name="selectFilter">A predicate or predicate expression which should be used as filter for the entities to retrieve.</param> /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param> /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param> /// <param name="relations">The set of relations to walk to construct to total query.</param> /// <param name="pageNumber">The page number to retrieve.</param> /// <param name="pageSize">The page size of the page to retrieve.</param> /// <returns>DataTable with the rows requested.</returns> public static DataTable GetMultiAsDataTable(IPredicate selectFilter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, int pageNumber, int pageSize) { FeedDAO dao = DAOFactory.CreateFeedDAO(); return(dao.GetMultiAsDataTable(maxNumberOfItemsToReturn, sortClauses, selectFilter, relations, pageNumber, pageSize)); }