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);
                }
            }
        }
示例#2
0
        /// <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);
                }
            }
        }