private async Task LoadFeed() { feed = await FeedService.GetFeedDetails(FeedId); Logger.LogInformation("Feed {0}", feed); FeedTitle = feed.Title; }
IObservable <List <ArticleViewModel> > GetAndFetchLatestArticles() { return(Cache.GetAndFetchLatest(BlobCacheKeys.GetCacheKeyForFeedAddress(FeedAddress), async() => await Task.Run(() => FeedService.GetFeedFor(FeedAddress)), datetimeOffset => true, // store the results in the cache for 31 days. RxApp.MainThreadScheduler.Now + TimeSpan.FromDays(31))); }
private async Task MainAsync() { DeserializeSettings(); _client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Verbose, AlwaysDownloadUsers = true, MessageCacheSize = 50 }); _commandService = new CommandService(new CommandServiceConfig { CaseSensitiveCommands = false, DefaultRunMode = RunMode.Async }); _loggingService = new LoggingService(_client, _settings); _databaseService = new DatabaseService(_loggingService, _settings); _publisherService = new PublisherService(_client, _databaseService, _settings); _animeService = new AnimeService(_client, _loggingService, _settings); _feedService = new FeedService(_client, _settings); _updateService = new UpdateService(_client, _loggingService, _publisherService, _databaseService, _animeService, _settings, _feedService); _userService = new UserService(_client, _databaseService, _loggingService, _updateService, _settings, _userSettings); _audioService = new AudioService(_loggingService, _client, _settings); _currencyService = new CurrencyService(); _serviceCollection = new ServiceCollection(); _serviceCollection.AddSingleton(_loggingService); _serviceCollection.AddSingleton(_databaseService); _serviceCollection.AddSingleton(_userService); //_serviceCollection.AddSingleton(_work); //TODO: rework work service _serviceCollection.AddSingleton(_publisherService); _serviceCollection.AddSingleton(_updateService); _serviceCollection.AddSingleton(_audioService); _serviceCollection.AddSingleton(_animeService); _serviceCollection.AddSingleton(_settings); _serviceCollection.AddSingleton(_rules); _serviceCollection.AddSingleton(_payWork); _serviceCollection.AddSingleton(_userSettings); _serviceCollection.AddSingleton(_currencyService); _services = _serviceCollection.BuildServiceProvider(); await InstallCommands(); _client.Log += Logger; // await InitCommands(); await _client.LoginAsync(TokenType.Bot, _settings.Token); await _client.StartAsync(); _client.Ready += () => { Console.WriteLine("Bot is connected"); //_audio.Music(); return(Task.CompletedTask); }; await Task.Delay(-1); }
private ActionResult GetIndexView(ArticlesRequest request) { var hvm = new EntriesVM(); hvm.Request = request; if (!request.SearchQuery.IsNullOrEmpty()) { var isPro = PaymentService.IsPro(CurrentUser); if (!isPro) { var numberOfSearchesAlready = FeedService.GetUserSearchesForDate(CurrentUser); if (numberOfSearchesAlready >= NumberOfFreeSearches) { hvm.ExcededFreeSearchCount = true; } } FeedService.AddSearch(request.SearchQuery, CurrentUser); } if (!hvm.ExcededFreeSearchCount) { hvm.Articles = FeedService.GetArticles(request); } SaveRequestToCookie(); hvm.CurrentUser = CurrentUser; return(View("Index", hvm)); }
public async void Loading(Page sender) { Padding = defaultThickness; //hide all labels and show loading sender.IsBusy = IsBusy = true; ShowLabels = false; try{ DataSource = await FeedService.GetWordAsync().ConfigureAwait(true); OnPropertyChanged("DataSource"); } catch (Exception e) { Insights.Report(e); } finally { Padding = CalculatePadding(sender); //disable loading stuff. sender.IsBusy = IsBusy = false; //show resulting labels ShowLabels = true; } }
public void DeleteFeedArticles() { var feedId = 3; var articles = new FeedService().GetArticlesWithoutBody(feedId); articles.ForEach(a => new FeedService().DeleteArticle(a.Id)); }
private static void TestFeedItems(FeedService feedService) { List <Feed> feeds = feedService.GetFeeds(); List <BagOfWords> bags = new List <BagOfWords>(); foreach (Feed feed in feeds) { bags.AddRange(feedService.AnalyzeFeedItems(feed)); } Clustering clustering = new Clustering(); double[,] similars = new double[bags.Count, bags.Count]; var docSimilars = new Dictionary <Tuple <BagOfWords, BagOfWords>, double>(); for (int i = 0; i < bags.Count - 1; i++) { for (int j = i + 1; j < bags.Count; j++) { if (bags[i].Type == bags[j].Type) { continue; } double sim = clustering.GetCosineDistance(bags[i], bags[j], true); similars[i, j] = sim; docSimilars.Add(new Tuple <BagOfWords, BagOfWords>(bags[i], bags[j]), sim); } } Console.In.ReadLine(); OutputSimilarityMatrix(docSimilars); }
public ActionResult Feeds(int feedId, string action) { var feed = FeedService.GetFeed(feedId); switch (action) { case "reviewed": feed.Reviewed = true; break; case "public": feed.Public = true; break; } if (action == "delete") { FeedService.DeleteFeed(feedId); } else { FeedService.UpdateFeed(feed); } if (action == "public") { var articles = FeedService.GetArticles(feed.Id); foreach (var article in articles) { article.Feed = feed; article.Tags = FeedService.GetArticleTags(article.Id); Redis.AddArticle(article); } } return(RedirectToAction("Feeds")); }
public ActionResult Me(string tab) { var account = new AccountVM { Tab = tab ?? "feeds", User = CurrentUser }; switch (account.Tab) { case "feeds": account.Feeds = FeedService.GetSubmitedFeeds(CurrentUser.Id); break; case "tagged": account.TaggedArticles = FeedService.GetTaggedArticles(CurrentUser.Id); account.UserTags = FeedService.GetTaggedArticlesStatuses(CurrentUser.Id); account.Tags = FeedService.GetTags(account.UserTags.Select(t => t.TagId).ToList()); break; case "ignored": account.IgnoredArticles = FeedService.GetIgnoredArticles(CurrentUser.Id); break; } return(View(account)); }
public async Task Loading(Page sender) { Padding = default(Thickness); //hide all labels and show loading sender.IsBusy = IsBusy = true; ShowLabels = false; try{ DataSource = await FeedService.GetWordAsync( (Language)Enum.Parse(typeof(Language), SelectedLanguage)) .ConfigureAwait(true); } // Analysis disable once EmptyGeneralCatchClause catch (Exception e) { #if RELEASE Insights.Report(e); #endif } finally { Padding = CalculatePadding(sender); //disable loading stuff. sender.IsBusy = IsBusy = false; //show resulting labels ShowLabels = true; } }
//[ValidateAntiForgeryToken] public void IncreaseViewsCount(int articleId, int userId) { var cookie = Request.Cookies["article"]; var expirationTime = DateTime.Now.AddMinutes(2); if (cookie == null) { FeedService.UpdateArticleAsRead(userId, articleId); cookie = new HttpCookie("article", articleId.ToString()) { Expires = expirationTime }; Response.Cookies.Add(cookie); } else { var cookieValue = cookie.Value; if (!cookieValue.ToCommaSeparatedListOfIds().Contains(articleId)) { FeedService.UpdateArticleAsRead(userId, articleId); cookieValue += "," + articleId; cookie.Value = cookieValue; cookie.Expires = expirationTime; Response.Cookies.Add(cookie); } } }
public void GamesPlayedTest() { var target = new FeedService(); const string gamertag = "Bundy"; var gamesPlayed = target.GamesPlayed(gamertag); Assert.IsTrue(gamesPlayed.Games.Count > 0); }
public ActionResult Index(int?userId, string date, string sortBy, string sortOrder) { var model = new FeedIndexModel(); model.Tab = "Feed"; model.Users = DataHelper.GetUserList(); model.UserId = userId ?? 0; model.UserName = DataHelper.ToString(model.Users, model.UserId, "any user"); model.UserDisplayName = DataHelper.Clip(model.UserName, 20); model.Date = date ?? string.Empty; model.SortBy = sortBy ?? "CreatedDate"; model.SortOrder = sortOrder ?? "DESC"; model.SortableColumns.Add("CreatedDate", "Date"); model.SortableColumns.Add("Type", "Type"); model.SortableColumns.Add("UserName", "User"); var criteria = new FeedCriteria() { CreatedBy = userId, CreatedDate = new DateRangeCriteria(model.Date) }; var feeds = FeedService.FeedFetchInfoList(criteria) .AsQueryable(); feeds = feeds.OrderBy(string.Format("{0} {1}", model.SortBy, model.SortOrder)); model.Feeds = feeds; return(this.View(model)); }
public void GamerDoesntExistTest() { var target = new FeedService(); const string gamertag = "Bundyaaaaaaa"; var actual = target.GamerExists(gamertag); Assert.IsFalse(actual); }
public void GamerExistsTest() { var target = new FeedService(); const string gamertag = "Bundy"; var actual = target.GamerExists(gamertag); Assert.IsTrue(actual); }
/// <summary> /// Used consructor injection to get all needed services /// </summary> /// <param name="FeedService"></param> /// <param name="LoggerFactory"></param> /// <param name="CacheManager"></param> public FeedController(FeedService FeedService, ILoggerFactory LoggerFactory, ICacheManager CacheManager) { feedService = FeedService; logger = LoggerFactory.CreateLogger <FeedController>(); CacheManager.DurationInSeconds = cacheExpiration; }
public void GetFeeds() { var feedService = new FeedService(); var feeds = feedService.GetFeeds(10, "salesforce"); Assert.IsTrue(feeds.Count() == 10); }
// // GET: /Manage/Index public async Task <ActionResult> Index(ManageMessageId?message) { ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set." : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." : message == ManageMessageId.Error ? "An error has occurred." : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." : ""; var userId = User.Identity.GetUserId(); var feedService = new FeedService(new FeedReaderContext()); var model = new IndexViewModel { HasPassword = HasPassword(), PhoneNumber = await UserManager.GetPhoneNumberAsync(userId), TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId), Logins = await UserManager.GetLoginsAsync(userId), BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId), Feeds = await feedService.GetByUser(userId) }; return(View(model)); }
public void LoadData() { IsBusy = true; // Load data with services Items = FeedService.GetAll(); Videos = YoutubeService.GetAll(); // Check if user enabled the Twitter feature. if (Preferences.Get(ENABLE_TWITTER_FEED_PREF_KEY, false)) { // Update binded Tweets member with service-based tweets. Tweets = TwitterService.GetAll(); } else { // Else return dummy tweet entry with helpful text that the // feature is disabled by the user. Tweets = new List <Tweet> { CreateFeatureInfoTweet() }; } IsBusy = false; }
public ConsumerBackgroundService(Serilog.ILogger logger, CategorysService categoryService, SpecificationsService specificationService, SpecificationsGroupService specificationGroupService, BrandsService brandsService, ProductsService productService, SKUService SKUService, SpecificationValuesService specificationValuesService, ProductSpecificationsService productSpecificationsService, SKUSpecificationsService SKUSpecificationsService, SKUFilesService SKUFilesService, InventoryService inventoryService, PricesService pricesService, MotosService motosService, FeedService feedService, OrderService ordersService) { _logger = logger; _categoryService = categoryService; _specificationService = specificationService; _specificationGroupService = specificationGroupService; _brandsService = brandsService; _productService = productService; _SKUService = SKUService; _specificationValuesService = specificationValuesService; _productSpecificationsService = productSpecificationsService; _SKUSpecificationsService = SKUSpecificationsService; _SKUFilesService = SKUFilesService; _inventoryService = inventoryService; _pricesService = pricesService; _motosService = motosService; _feedService = feedService; _ordersService = ordersService; }
public async Task OnFollowFeed() { await FeedService.AddFeed(Feed); NotificationService.NotifyFeedChange(); UriHelper.NavigateTo($"/feed/{Feed.Id}"); }
public FeedController() { feedService = new FeedService(); friendService = new FriendService(); visitorService = new VisitorService(); followService = new FollowerService(); }
public void ValidCredentials() { var feedService = new FeedService(); string strAccessToken = feedService.GetAccessToken().ToString(); Assert.IsTrue(!string.IsNullOrEmpty(strAccessToken)); }
/// <summary> /// Gets the feeds. /// </summary> /// <param name="user">The user for which feeds are retrieved.</param> /// <returns>The list of feeds.</returns> public Feed[] GetFeeds(AdWordsUser user) { using (FeedService feedService = (FeedService)user.GetService(AdWordsService.v201809.FeedService)) { Selector selector = new Selector() { fields = new string[] { Feed.Fields.Id, Feed.Fields.Name, Feed.Fields.Origin, Feed.Fields.Attributes, Feed.Fields.SystemFeedGenerationData, Feed.Fields.FeedStatus }, predicates = new Predicate[] { Predicate.Contains(Feed.FilterableFields.Name, "sitelink") }, paging = Paging.Default }; FeedPage page = feedService.get(selector); if (page.totalNumEntries > 0) { return(page.entries); } return(null); } }
public ActionResult Flag(int id) { var article = FeedService.GetArticle(id); if (article == null) { return(Json(false)); } if (article.FlaggedBy.Contains(CurrentUser.Id)) { return(Json(false)); } article.FlaggedBy.Add(CurrentUser.Id); article.Flagged = article.FlaggedBy.Count >= 3 || CurrentUser.IsAdmin;; FeedService.UpdateArticle(article); if (article.Flagged && article.FlaggedBy.Count > 0) { IISTaskManager.Run(() => { var userToAddRep = article.FlaggedBy.First(); var user = UserService.GetUser(userToAddRep); if (user != null) { user.Reputation += 2; UserService.UpdateUser(user); } }); } return(Json(true)); }
public MicroblogService() { feedService = new FeedService(); nfService = new NotificationService(); friendService = new FriendService(); followerService = new FollowerService(); }
public ActionResult Index(string dashboard) { var model = new HomeIndexModel(); model.Tab = "Home"; model.Dashboard = dashboard ?? "My"; model.StartDate = DateTime.Today.ToStartOfWeek(); model.EndDate = DateTime.Today.ToEndOfWeek(); if (model.Dashboard == "Team") { model.Tasks = TaskService.TaskFetchInfoList( new TaskCriteria { IsArchived = false }); model.Hours = HourService.HourFetchInfoList(model.StartDate, model.EndDate); model.Feeds = FeedService.FeedFetchInfoList(5); } else { model.Tasks = MyService.TaskFetchInfoList(); model.Hours = MyService.HourFetchInfoList(model.StartDate, model.EndDate); model.Feeds = MyService.FeedFetchInfoList(5); } return(this.View(model)); }
public async Task <SurveyModel> GetSurvey(string userId, string creationDate, string authenticationToken) { try { FeedService feedService = new FeedService(); var response = await feedService.GetSurvey(userId, creationDate, authenticationToken); if (response.IsSuccessStatusCode) { var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <SurveyModel>(json)); } else { if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { throw new Exception("Unauthorized"); } else { throw new Exception(response.StatusCode.ToString() + " - " + response.ReasonPhrase); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task SaveSurvey(SurveyModel surveyModel, string authenticationToken, Stream questionImage, List <KeyValuePair <string, byte[]> > optionImages) { try { FeedService feedService = new FeedService(); var response = await feedService.SaveSurvey(surveyModel, authenticationToken, questionImage, optionImages); if (!response.IsSuccessStatusCode) { if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { throw new Exception("Unauthorized"); } else { throw new Exception(response.StatusCode.ToString() + " - " + response.ReasonPhrase); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task ReportSurvey(string userId, string surveyId, string authenticationToken) { try { FeedService feedService = new FeedService(); var response = await feedService.ReportSurvey(userId, surveyId, authenticationToken); if (!response.IsSuccessStatusCode) { if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { throw new Exception("Unauthorized"); } else { throw new Exception(response.StatusCode.ToString() + " - " + response.ReasonPhrase); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public LocalUser(LogService logger, LocalStorageService localStorage, ApiService api, FeedService feedService) { _logger = logger; _localStorage = localStorage; _api = api; _feedService = feedService; }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); var items = await FeedService.SendRequst <NewsFeed>(ServiceType.Home, new NewsData { PageIndex = 1, PageSize = 10 }); if (items != null) { Items.ReplaceRange(items.Items); } } catch (Exception ex) { Debug.WriteLine(ex); MessagingCenter.Send(new MessagingCenterAlert { Title = "Error", Message = "Unable to load items.", Cancel = "OK" }, "message"); } finally { IsBusy = false; } }
public async Task WordsAreDifferent() { var word = await FeedService.GetWordAsync(Language.Italian); word.EnglishWord.Should().Be(expected.EnglishWord); word.TodaysWord.Should().Be(expected.TodaysWord); }
public bool ValidateUser(string tag) { var fs = new FeedService(); return fs.GamerExists(tag); }
// public ActionResult Compare(string tag1, string tag2) { ViewBag.ReturnUrl = string.Format("~/home/compare/{0}/{1}", tag1, tag2); var fs = new FeedService(); var c = new Compare {Player1 = {Name = tag1}, Player2 = {Name = tag2}}; c.Player1.Valid = fs.GamerExists(tag1); c.Player2.Valid = fs.GamerExists(tag2); if (c.Player1.Valid && c.Player2.Valid) { c.Player1.Valid = true; c.Player2.Valid = true; var tag1Games = fs.GamesPlayed(tag1); var tag2Games = fs.GamesPlayed(tag2); c.Player1.TotalScore = tag1Games.Games.Sum(a => a.currentgs); c.Player2.TotalScore = tag2Games.Games.Sum(a => a.currentgs); var common = tag1Games.Games.Join(tag2Games.Games, a => a.id, b => b.id, (a, b) => new CommonGames { Player1 = a, Player2 = b }) .Where(a => a.Player1.currentgs > 0 && a.Player2.currentgs > 0) .OrderByDescending(a => Convert.ToDateTime(a.Player1.lastplayed)); var twoyearsago = DateTime.Now.AddYears(-2); var twoYear = common.Where(a => Convert.ToDateTime(a.Player1.lastplayed) >= twoyearsago && Convert.ToDateTime(a.Player2.lastplayed) >= twoyearsago); c.TwoYear = CompareSummary.Map(twoYear, "Two Year"); c.TwoYearGames = twoYear.ToList().ConvertAll(a => new GameCompare { Name = a.Player1.name, Id = a.Player1.id, Tile = a.Player1.tile, Tile64 = a.Player1.tile64, Tag1Score = a.Player1.currentgs, Tag2Score = a.Player2.currentgs, Genre = a.Player1.genre, Difference = a.Player1.currentgs - a.Player2.currentgs, LastPayed = DateTime.Parse(a.Player1.lastplayed) }); var genres = common.Select(a => a.Player1.genre).Distinct(); var totalWins = 0; var totalTies = 0; var totalLoses = 0; var totalTag1Score = 0; var totalTag2Score = 0; foreach (var genreSummary in from genre1 in genres let genreGames = common.Where(a => a.Player1.genre == genre1).ToList() select CompareSummary.Map(genreGames, genre1)) { c.Genre.Add(genreSummary); totalWins += genreSummary.Wins; totalLoses += genreSummary.Loses; totalTies += genreSummary.Ties; totalTag1Score += genreSummary.Tag1Score; totalTag2Score += genreSummary.Tag2Score; } c.Genre.Add(new CompareSummary { Label = "All", Wins = totalWins, Ties = totalTies, Loses = totalLoses, Tag1Score = totalTag1Score, Tag2Score = totalTag2Score }); c.Genre = c.Genre.OrderByDescending(a => a.Tag1Score) .ToList(); c.Games = common.ToList().ConvertAll(a => new GameCompare { Name = a.Player1.name, Id = a.Player1.id, Tile = a.Player1.tile, Tile64 = a.Player1.tile64, Tag1Score = a.Player1.currentgs, Tag2Score = a.Player2.currentgs, Genre = a.Player1.genre, Difference = a.Player1.currentgs - a.Player2.currentgs, LastPayed = DateTime.Parse(a.Player1.lastplayed) }); } return View("Compare",c); }