public void SiteFeedList( SiteFeedListHeadFootTemplate head , SiteFeedListHeadFootTemplate foot , SiteFeedListItemTemplate item) { FeedCollection feeds = FeedBO.Instance.GetAllSiteFeeds(); int total = feeds.Count; int i = 0; AuthUser user = User.Current; int loginUserID = user.UserID; bool canManageSiteFeed = FeedBO.Instance.ManagePermission.Can(user, BackendPermissions.Action.Manage_Feed_SiteFeed); head(total > 0, total, canManageSiteFeed); float timeDiffrence = UserBO.Instance.GetUserTimeDiffrence(user); foreach (Feed feed in feeds) { string title = FeedBO.Instance.FormatFeedTitle(loginUserID, timeDiffrence, FeedType.AllUserFeed, feed); string description = FeedBO.Instance.FormatFeedDescription(loginUserID, feed); item(i++, feed, canManageSiteFeed, canManageSiteFeed, title, description); } foot(total > 0, total, canManageSiteFeed); }
private void GetFeeds() { bool haveMore; m_FeedList = FeedBO.Instance.GetUserFeeds(MyUserID, UserID, int.MaxValue, CurrentGetCount, FeedAppID, FeedAction, out haveMore); m_HaveMoreFeeds = haveMore; }
public void AddRSSFeedTest() { Arrange(); var mockFeedCollectionRepository = kernel.Get <IGenericRepository <FeedCollection> >(); var rss = new RSS() { Id = 1, Name = "Before", RssUrl = "urlurl" }; var feeds = new List <Feed>() { rss }; var feedColl = new FeedCollection() { Id = 1, Feeds = feeds }; var mockFeedCollection = new List <FeedCollection>() { feedColl }; uow.FeedCollectionRepository.Returns(mockFeedCollectionRepository); mockFeedCollectionRepository.Get().Returns(mockFeedCollection); ess.AddRSSFeed(1, "Test", "www.test"); Assert.AreEqual(feeds.Count, 2); }
protected override async Task OnParametersSetAsync() { Collection = await Service.GetFeedCollection(FeedCollectionId) .ConfigureAwait(false); Feed = Collection?.Feeds?.FirstOrDefault(feed => feed.Id == FeedId); }
public void Test_FeedCollection_Constructor_Feed_Int() { // ReSharper disable once CollectionNeverUpdated.Local var sut = new FeedCollection(20); Assert.True(sut.Count == 0); }
public void Test_FeedCollection_Constructor_Feed() { var sut = new FeedCollection(); var expectedFeedCollection = new List <Feed> { new Feed("TestName1", "TestType1", "TestSettingsGroup1"), new Feed("TestName2", "TestType2", "TestSettingsGroup2"), new Feed("TestName3", "TestType3", "TestSettingsGroup3"), new Feed("TestName4", "TestType4", "TestSettingsGroup4") }; var newFeed = new Feed("TestName5", "TestType5", "TestSettingsGroup5"); foreach (var feed in expectedFeedCollection) { sut.Add(feed); } sut.Add(newFeed); sut.Remove(newFeed); Assert.True(sut.Count == 4); foreach (var feed in expectedFeedCollection) { Assert.Contains(feed, sut); } Assert.DoesNotContain(newFeed, sut); }
public int Create() { var item = new FeedCollection(); uow.FeedCollectionRepository.Insert(item); uow.Save(); return(item.Id); }
/* InvalidateRequerySuggested tvingar kommandohanteraren * att prioritera händelse . */ private void automationTimer_Tick(object sender, EventArgs e) { if (mainCollection != null && mainCollection.Count > 0) { mainCollection = TimeLogic.IntervalHandler(mainCollection); CommandManager.InvalidateRequerySuggested(); UpdateFeedItemList(); } }
public void AnalizeFeed() { var feedCollection = new FeedCollection(_feedReader); foreach (var feed in feedCollection) { _action.OnExecuteFinished = (T results) => OnArticleFinish(feed, results); _action.Execute(feed); } }
public IActionResult CreateFeedCollection([FromBody] FeedCollection request) { try { int id = repository.CreateFeedCollection(request); return(StatusCode((int)HttpStatusCode.Created, id)); } catch (Exception e) { Log.Error(e, nameof(CreateFeedCollection)); return(StatusCode((int)HttpStatusCode.InternalServerError, $"Create Feed Collection unexpected error. {e.Message}")); } }
protected override void Seed(NewsModel context) { var rss1 = new RSS("Sport news", "http://fakty.ua/rss_feed/sport"); var rss2 = new RSS("Society news", " http://fakty.ua/rss_feed/society"); var collection = new FeedCollection(); var feeds = new List <Feed>(); feeds.Add(rss1); feeds.Add(rss2); collection.Feeds = feeds; context.FeedCollections.Add(collection); context.SaveChanges(); }
public async Task UpdateFeed(FeedCollection collection, Feed feed) { if (collection is null) { throw new ArgumentNullException(nameof(collection)); } if (feed is null) { throw new ArgumentNullException(nameof(feed)); } await _http .PutJsonAsync($"api/feedcollections/{collection.Id}/feed", feed) .ConfigureAwait(false); }
// GET: JobSearch public ActionResult Search() { var model = new SearchModel(); var filter = new PredicateExpression(); filter.Add(FeedFields.PersonGuid == Common.PersonGuid); var sorter = new SortExpression(FeedFields.Name | SortOperator.Ascending); var feeds = new FeedCollection(); feeds.GetMulti(filter, 0, sorter); model.Feeds = feeds.ToList(); return(View(model)); }
public async Task DeleteFeed(FeedCollection collection, Feed feed) { if (collection is null) { throw new ArgumentNullException(nameof(collection)); } if (feed is null) { throw new ArgumentNullException(nameof(feed)); } await _http .DeleteAsync($"api/feedcollections/{collection.Id}/feed/{feed.Id}") .ConfigureAwait(false); }
public async Task <IEnumerable <Article> > GetArticles(FeedCollection collection, Feed feed) { if (collection is null) { return(null); } var url = $"api/feedcollections/{collection.Id}/articles"; if (feed is object) { url = $"api/feedcollections/{collection.Id}/feed/{feed.Id}/articles"; } return(await _http.GetJsonAsync <Article[]>(url) .ConfigureAwait(false)); }
public void Download_Success() { var rawFile = File.ReadAllText(Util.GetFullPath("FeedCollection.xml")); var xmlDocument = XDocument.Parse(rawFile); var xmlMockFeedReader = new Moq.Mock <IFeedReader>(); xmlMockFeedReader .Setup(x => x.GetFeed()) .Returns(xmlDocument); var feedCollection = new FeedCollection(xmlMockFeedReader.Object); Assert.True(feedCollection != null); Assert.Equal(10, feedCollection.Count); xmlMockFeedReader.Verify(x => x.GetFeed(), Moq.Times.Once); }
public void FeedSearchList(string filter, int page, int defaultPageSize , FeedSearchListHeadFootTemplate head , FeedSearchListHeadFootTemplate foot , FeedSearchListItemTemplate item) { FeedSearchFilter feedSearchFilter = FeedSearchFilter.GetFromFilter(filter); int totalCount; FeedCollection feeds = new FeedCollection(); //int pageSize; FeedSearchFilter tempFilter; if (feedSearchFilter.IsNull) { tempFilter = new FeedSearchFilter(); tempFilter.PageSize = defaultPageSize; tempFilter.Order = FeedSearchFilter.OrderBy.ID; tempFilter.IsDesc = true; } else { tempFilter = feedSearchFilter; } feeds = FeedBO.Instance.SearchFeeds(page, tempFilter, out totalCount); head(feedSearchFilter, totalCount > 0, totalCount, tempFilter.PageSize); int loginUserID = UserBO.Instance.GetCurrentUserID(); int i = 0; float timeDiffrence = UserBO.Instance.GetUserTimeDiffrence(User.Current); foreach (Feed feed in feeds) { string title = FeedBO.Instance.FormatFeedTitle(loginUserID, timeDiffrence, FeedType.AllUserFeed, feed); string description = FeedBO.Instance.FormatFeedDescription(loginUserID, feed); item(i++, feed, title, description, true); } foot(feedSearchFilter, totalCount > 0, totalCount, tempFilter.PageSize); }
public override bool BeforeExecute(int operatorUserID, string param, ref long offset, ref int totalCount, out string title) { FeedSearchFilter filter = FeedSearchFilter.Parse(param); int tempTotalCount; FeedCollection feeds = FeedBO.Instance.SearchFeeds(1, filter, out tempTotalCount); if (feeds == null || feeds.Count == 0) { title = "没有数据可以删除"; return(false); } totalCount = tempTotalCount; title = "将删除 " + totalCount + " 条动态"; return(true); }
public void Process(DataTable data) { FeedCollection feeds = FeedBO.Instance.GetAllCachedFeed(); if (feeds == null || feeds.Count == 0) { return; } foreach (DataRow row in data.Rows) { int feedID = (int)row["FeedID"]; Feed feed = feeds.GetValue(feedID); if (feed != null) { feed.CommentInfo = row["CommentInfo"].ToString(); } } }
private void GetFeeds() { bool haveMore; if (FeedType == FeedType.AllUserFeed) { m_FeedList = FeedBO.Instance.GetAllUserFeeds(MyUserID, int.MaxValue, GetFeedCount, FeedAppID, FeedAction, out haveMore); } else if (FeedType == FeedType.FriendFeed) { m_FeedList = FeedBO.Instance.GetFriendFeeds(MyUserID, int.MaxValue, GetFeedCount, FeedAppID, FeedAction, out haveMore); } else { m_FeedList = FeedBO.Instance.GetUserFeeds(MyUserID, MyUserID, int.MaxValue, GetFeedCount, FeedAppID, FeedAction, out haveMore); } m_HaveMoreFeeds = haveMore; }
public void Test_FeedCollection_Constructor_FeedIEnumerable() { var expectedFeedCollection = new List <Feed> { new Feed("TestName1", "TestType1", "TestSettingsGroup1"), new Feed("TestName2", "TestType2", "TestSettingsGroup2"), new Feed("TestName3", "TestType3", "TestSettingsGroup3"), new Feed("TestName4", "TestType4", "TestSettingsGroup4") }; var newFeed = new Feed("TestName5", "TestType5", "TestSettingsGroup5"); var feedCollection = new FeedCollection(expectedFeedCollection); Assert.True(feedCollection.Count == 4); foreach (var feed in expectedFeedCollection) { Assert.Contains(feed, feedCollection); } Assert.DoesNotContain(newFeed, feedCollection); }
public void AddRSSFeedTest() { var mockFeedCollRepository = Substitute.For <IGenericRepository <FeedCollection> >(); var feed = new RSS() { Id = 1, Name = "Zero", RssUrl = "123" }; var listoffeeds = new List <Feed>() { feed }; FeedCollection coll = new FeedCollection() { Feeds = listoffeeds, Id = 0 }; mockFeedCollRepository.Get().Returns(coll); editSubSys.AddRSSFeed(0, "test", "www.test"); }
public int CreateFeedCollection(CreateFeedCollectionRequest request) { _logger.LogInformation("User " + request.UserId + " called method CreateFeedCollection(string)"); if (request.Title == "" || request.Title == null) { _logger.LogWarning("CreateFeedCollection threw ArgumentException: User #" + request.UserId + " gave improper title for Feed Collection."); throw new ArgumentException("Improper title for Feed Collection."); } if (_newsRepository.Contains(request.Title, request.UserId)) { _logger.LogError("CreateFeedCollection threw ArgumentException: User #" + request.UserId + " has already created Feed Collection with title \"" + request.Title + "\""); throw new DuplicateWaitObjectException("This user has already created Feed Collection with this title."); } var feedCollection = new FeedCollection { Title = request.Title, UserID = request.UserId }; _newsRepository.Add(feedCollection); var n = _newsRepository.SaveChanges(); if (n > 0) { _cache.Set("fc_" + feedCollection.ID, feedCollection, new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) }); } return(feedCollection.ID); }
public override FeedCollection GetUserFeeds(int userID, int feedID, int getCount, Guid appID, int? actionType) { using (SqlQuery query = new SqlQuery()) { query.CommandText = @" DECLARE @FeedIDs table(FeedID int); INSERT INTO @FeedIDs SELECT DISTINCT TOP (@TopCount) [FeedID] FROM [bx_UserFeeds] WHERE [UserID]=@UserID AND [FeedID]<@FeedID " + (actionType == null ? "" : (" AND [FeedID] IN(SELECT [ID] FROM [bx_Feeds] WHERE [AppID] = @AppID AND [ActionType] = @ActionType)")) + @" ORDER BY [FeedID] DESC; SELECT * FROM [bx_Feeds] WHERE [ID] IN(SELECT [FeedID] FROM @FeedIDs) ORDER BY [ID] DESC; SELECT * FROM [bx_UserFeeds] WHERE [UserID] = @UserID AND [FeedID] IN(SELECT [FeedID] FROM @FeedIDs) ORDER BY [FeedID] DESC,[CreateDate] DESC; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(SELECT [FeedID] FROM [bx_UserFeeds] UF INNER JOIN [bx_Feeds] F ON UF.[FeedID]=F.[ID] WHERE F.[ID] IN(SELECT [FeedID] FROM @FeedIDs) AND UF.[UserID]=F.[TargetUserID] AND F.[TargetUserID]=@UserID) ORDER BY [CreateDate] DESC; "; query.CreateTopParameter("@TopCount", getCount); query.CreateParameter<int>("@UserID", userID, SqlDbType.Int); query.CreateParameter<int>("@FeedID", feedID, SqlDbType.Int); query.CreateParameter<Guid>("@AppID", appID, SqlDbType.UniqueIdentifier); query.CreateParameter<int?>("@ActionType", actionType, SqlDbType.Int); using (XSqlDataReader reader = query.ExecuteReader()) { FeedCollection feeds = new FeedCollection(reader); if (reader.NextResult()) { Feed currentFeed = null; while (reader.Read()) { UserFeed userFeed = new UserFeed(reader); currentFeed = ProcessFeed(feeds, currentFeed, userFeed, false); } } if (reader.NextResult())// 这一组是特殊的 处理类似加好友的 如果TargetUserID 是好友 需要把UserFeeds 表里与该动态有关的用户都取出来 { Feed currentFeed = null; while (reader.Read()) { UserFeed userFeed = new UserFeed(reader); currentFeed = ProcessFeed(feeds, currentFeed, userFeed, true); } } return feeds; } } #region /* string condition = string.Empty; if (appID != Guid.Empty && actionType != null) condition = " AND [AppID]=@AppID AND [ActionType]=@ActionType "; using (DbSession db = new DbSession()) { using (IDataReader reader = db.ExecuteReader(@" DECLARE @FeedIDs table(FeedID int); INSERT INTO @FeedIDs SELECT TOP "+ getCount + @" DISTINCT [FeedID] FROM [bx_UserFeeds] WHERE [UserID]=@UserID AND [FeedID]<@FeedID "+ condition +@" ; SELECT * FROM [bx_Feeds] WHERE [ID] IN(SELECT [FeedID] FROM @FeedIDs) ORDER BY [FeedID] DESC; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(SELECT [FeedID] FROM @FeedIDs) GROUP BY [FeedID] ORDER BY [FeedID] DESC,[CreateDate] DESC; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(SELECT [FeedID] FROM [bx_UserFeeds] UF INNER JOIN [bx_Feeds] F ON UF.[FeedID]=F.[ID] WHERE F.[ID] IN(SELECT [FeedID] FROM @FeedIDs) AND UF.[UserID]=F.[TargetUserID] AND F.[TargetUserID]=@UserID) ORDER BY [CreateDate] DESC; " , db.Param<int>("@UserID", userID) , db.Param<int>("@FeedID", feedID) , db.Param<Guid>("@AppID", appID) , db.Param<int?>("@ActionType", actionType) ) ) { FeedCollection feeds = new FeedCollection(reader); if (reader.NextResult()) { Feed currentFeed = null; DataReaderWrap readerWrap = new DataReaderWrap(reader); while (readerWrap.Next) { UserFeed userFeed = new UserFeed(readerWrap); if (currentFeed == null || userFeed.FeedID != currentFeed.ID) { currentFeed = feeds.GetValue(userFeed.FeedID); if (currentFeed != null) currentFeed.Users = new UserFeedCollection(); } if (currentFeed != null) { if (userFeed.UserID != currentFeed.TargetUserID) currentFeed.Users.Add(userFeed); else currentFeed.IsSpecial = true; } } } if (reader.NextResult())// 这一组是特殊的 处理类似加好友的 如果TargetUserID 是好友 需要把UserFeeds 表里与该动态有关的用户都取出来 { Feed currentFeed = null; DataReaderWrap readerWrap = new DataReaderWrap(reader); while (readerWrap.Next) { UserFeed userFeed = new UserFeed(readerWrap); if (currentFeed == null || userFeed.FeedID != currentFeed.ID) { currentFeed = feeds.GetValue(userFeed.FeedID); if(currentFeed!=null) currentFeed.Users = new UserFeedCollection(); } if (currentFeed != null) { if (userFeed.UserID != userID && userFeed.UserID != currentFeed.TargetUserID) currentFeed.Users.Add(userFeed); } } } return feeds; } } */ #endregion }
private Feed ProcessFeed(FeedCollection feeds, Feed currentFeed, UserFeed userFeed, bool checkUser) { if (currentFeed == null || userFeed.FeedID != currentFeed.ID) { currentFeed = feeds.GetValue(userFeed.FeedID); if (currentFeed != null && currentFeed.Users == null) currentFeed.Users = new UserFeedCollection(); } if (currentFeed != null) { if (userFeed.UserID == currentFeed.TargetUserID) currentFeed.IsSpecial = true; if (!checkUser) currentFeed.Users.Add(userFeed); else { foreach (UserFeed tempUserFeed in currentFeed.Users) { if (tempUserFeed.UserID == userFeed.UserID) return currentFeed; } currentFeed.Users.Add(userFeed); } //if (userFeed.UserID != userID && userFeed.UserID != currentFeed.TargetUserID) //currentFeed.Users.Add(userFeed); } return currentFeed; }
public override FeedCollection GetFeeds(IEnumerable<int> feedIDs) { using (SqlQuery query = new SqlQuery()) { query.CommandText = @" SELECT * FROM [bx_Feeds] WHERE [ID] IN(@FeedIDs) ORDER BY [CreateDate] DESC; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(@FeedIDs) ORDER BY [FeedID] DESC,[CreateDate] DESC; "; query.CreateInParameter("@FeedIDs", feedIDs); using (XSqlDataReader reader = query.ExecuteReader()) { FeedCollection feeds = new FeedCollection(reader); if (reader.NextResult()) { Feed currentFeed = null; while (reader.Read()) { UserFeed userFeed = new UserFeed(reader); currentFeed = ProcessFeed(feeds, currentFeed, userFeed, false); } } return feeds; } } }
public override FeedCollection GetAllUserFeeds(int feedID, int getCount, Guid appID, int? actionType) { using (SqlQuery query = new SqlQuery()) { //--INSERT INTO @FeedIDs SELECT TOP (@TopCount) [ID] FROM [bx_Feeds] WITH(NOLOCK) WHERE [ID]<@FeedID //-- AND (@ActionType IS NULL OR ([AppID] = @AppID AND [ActionType] = @ActionType)) //-- OR ([AppID] = @BasicAppID AND [ActionType] = @SiteFeedActionID AND [CreateDate] < @MaxDateTime) //--ORDER BY [CreateDate] DESC; query.CommandText = @" DECLARE @MaxDateTime datetime; SELECT @MaxDateTime = ISNULL([CreateDate],'9999-12-31') FROM [bx_Feeds] WITH(NOLOCK) WHERE [ID] = @FeedID; DECLARE @FeedIDs table(FeedID int); IF @ActionType IS NULL INSERT INTO @FeedIDs SELECT TOP (@TopCount) [ID] FROM [bx_Feeds] WITH(NOLOCK) WHERE [ID]<@FeedID OR ([AppID] = @BasicAppID AND [ActionType] = @SiteFeedActionID AND [CreateDate] < @MaxDateTime) ORDER BY [CreateDate] DESC; ELSE INSERT INTO @FeedIDs SELECT TOP (@TopCount) [ID] FROM [bx_Feeds] WITH(NOLOCK) WHERE [ID]<@FeedID AND ([AppID] = @AppID AND [ActionType] = @ActionType) OR ([AppID] = @BasicAppID AND [ActionType] = @SiteFeedActionID AND [CreateDate] < @MaxDateTime) ORDER BY [CreateDate] DESC; SELECT * FROM [bx_Feeds] WITH(NOLOCK) WHERE [ID] IN(SELECT [FeedID] FROM @FeedIDs) ORDER BY [CreateDate] DESC; SELECT * FROM [bx_UserFeeds] WITH(NOLOCK) WHERE [FeedID] IN(SELECT [FeedID] FROM @FeedIDs) ORDER BY [FeedID] DESC,[CreateDate] DESC; "; query.CreateTopParameter("@TopCount", getCount); query.CreateParameter<int>("@FeedID", feedID, SqlDbType.Int); query.CreateParameter<Guid>("@AppID", appID, SqlDbType.UniqueIdentifier); query.CreateParameter<Guid>("@BasicAppID", Consts.App_BasicAppID, SqlDbType.UniqueIdentifier); query.CreateParameter<int>("@SiteFeedActionID", (int)AppActionType.SiteFeed, SqlDbType.Int); query.CreateParameter<int?>("@ActionType", actionType, SqlDbType.Int); using (XSqlDataReader reader = query.ExecuteReader()) { FeedCollection feeds = new FeedCollection(reader); if (reader.NextResult()) { Feed currentFeed = null; while (reader.Read()) { UserFeed userFeed = new UserFeed(reader); currentFeed = ProcessFeed(feeds, currentFeed, userFeed, false); } } return feeds; } } #region /* string condition = string.Empty; if (appID != Guid.Empty && actionType != null) condition = "AND [AppID]=@AppID AND [ActionType]=@ActionType "; using (DbSession db = new DbSession()) { using (IDataReader reader = db.ExecuteReader(@" DECLARE @FeedIDs table(FeedID int); INSERT INTO @FeedIDs SELECT TOP " + getCount + @" [ID] FROM [bx_Feeds] WHERE [ID]<@FeedID "+ condition +@" ORDER BY [ID] DESC; SELECT * FROM [bx_Feeds] WHERE [ID] IN(SELECT [FeedID] FROM @FeedIDs) ORDER BY [ID] DESC; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(SELECT [FeedID] FROM @FeedIDs) ORDER BY [FeedID] DESC,[CreateDate] DESC; " , db.Param<int>("@FeedID",feedID) , db.Param<Guid>("@AppID",appID) , db.Param<int?>("@ActionType",actionType) )) { FeedCollection feeds = new FeedCollection(reader); if (reader.NextResult()) { Feed currentFeed = null; DataReaderWrap readerWrap = new DataReaderWrap(reader); while (readerWrap.Next) { UserFeed userFeed = new UserFeed(readerWrap); if (currentFeed == null || userFeed.FeedID != currentFeed.ID) { currentFeed = feeds.GetValue(userFeed.FeedID); if(currentFeed!=null) currentFeed.Users = new UserFeedCollection(); } if (currentFeed != null) { if (userFeed.UserID != currentFeed.TargetUserID) currentFeed.Users.Add(userFeed); else currentFeed.IsSpecial = true; } } } return feeds; } } */ #endregion }
public override FeedCollection GetFriendFeeds(int userID, IEnumerable<int> friendUserIDs, int feedID, int getCount, Guid appID, int? actionType) { using (SqlQuery query = new SqlQuery()) { query.CommandText = @" DECLARE @MaxDateTime datetime; SELECT @MaxDateTime = [CreateDate] FROM [bx_Feeds] WHERE [ID] = @FeedID; SELECT @MaxDateTime = ISNULL(@MaxDateTime,'9999-12-31') IF '@FriendUserIDs' = N'' BEGIN SELECT * FROM [bx_Feeds] WHERE [AppID] = @BasicAppID AND [ActionType] = @SiteFeedActionID AND [CreateDate] < @MaxDateTime ORDER BY [CreateDate] DESC; RETURN; END"; if (ValidateUtil.HasItems<int>(friendUserIDs)) { query.CommandText = query.CommandText + @" DECLARE @TempFeedIDs table(FeedID int,CDate DateTime); INSERT INTO @TempFeedIDs(FeedID) SELECT TOP (@TopCount) [FeedID] FROM [bx_UserFeeds] UF INNER JOIN [bx_Feeds] F ON UF.[FeedID] = F.[ID] WHERE [UserID] IN(@FriendUserIDs) AND F.[CreateDate] < @MaxDateTime --[FeedID]<@FeedID " + (actionType == null ? "" : (" AND [AppID] = @AppID AND [ActionType] = @ActionType")) + @" AND F.[TargetUserID] <> @UserID --OR ([AppID] = @BasicAppID AND [ActionType] = @SiteFeedActionID AND F.[CreateDate] < @MaxDateTime) GROUP BY [FeedID] ORDER BY MAX(F.[CreateDate]) DESC; UPDATE @TempFeedIDs SET CDate=[CreateDate] FROM [bx_Feeds] WHERE FeedID=[ID]; INSERT INTO @TempFeedIDs SELECT TOP (@TopCount) [ID],[CreateDate] FROM [bx_Feeds] WHERE ([AppID] = @BasicAppID AND [ActionType] = @SiteFeedActionID AND [CreateDate] < @MaxDateTime) ORDER BY [CreateDate] DESC; DECLARE @FeedIDs table(FeedID int); INSERT INTO @FeedIDs SELECT TOP (@TopCount) [FeedID] FROM @TempFeedIDs ORDER BY [CDate]; SELECT * FROM [bx_Feeds] WHERE [ID] IN(SELECT [FeedID] FROM @FeedIDs) ORDER BY [ID] DESC; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(SELECT [FeedID] FROM @FeedIDs) AND [UserID] IN(@FriendUserIDs) ORDER BY [FeedID] DESC,[CreateDate] DESC; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(SELECT [FeedID] FROM [bx_UserFeeds] UF INNER JOIN [bx_Feeds] F ON UF.[FeedID]=F.[ID] WHERE F.[ID] IN(SELECT [FeedID] FROM @FeedIDs) AND UF.[UserID]=F.[TargetUserID] AND F.[TargetUserID] IN(@FriendUserIDs)) ORDER BY [CreateDate] DESC; "; query.CreateTopParameter("@TopCount", getCount); } query.CreateParameter<int>("@UserID", userID, SqlDbType.Int); query.CreateParameter<int>("@FeedID", feedID, SqlDbType.Int); query.CreateParameter<Guid>("@AppID", appID, SqlDbType.UniqueIdentifier); query.CreateParameter<Guid>("@BasicAppID", Consts.App_BasicAppID, SqlDbType.UniqueIdentifier); query.CreateParameter<int>("@SiteFeedActionID", (int)AppActionType.SiteFeed, SqlDbType.Int); query.CreateParameter<int?>("@ActionType", actionType, SqlDbType.Int); //, query.CreateParameter<string>("@FriendUserIDs", StringUtil.JoinForSql(friendUserIDs, false), SqlDbType.VarChar, 8000) query.CreateInParameter("@FriendUserIDs", friendUserIDs); using (XSqlDataReader reader = query.ExecuteReader()) { FeedCollection feeds = new FeedCollection(reader); if (reader.NextResult()) { Feed currentFeed = null; while (reader.Read()) { UserFeed userFeed = new UserFeed(reader); currentFeed = ProcessFeed(feeds, currentFeed, userFeed, false); } } if (reader.NextResult())// 这一组是特殊的 处理类似加好友的 如果TargetUserID 是好友 需要把UserFeeds 表里与该动态有关的用户都取出来 { Feed currentFeed = null; while (reader.Read()) { UserFeed userFeed = new UserFeed(reader); currentFeed = ProcessFeed(feeds, currentFeed, userFeed, true); } } return feeds; } } #region /* string condition = string.Empty; if (appID != Guid.Empty && actionType != null) condition = " AND [AppID]=@AppID AND [ActionType]=@ActionType "; using (DbSession db = new DbSession()) { using (IDataReader reader = db.ExecuteReader(@" DECLARE @FeedIDs table(FeedID int); INSERT INTO @FeedIDs SELECT TOP " + getCount + @" UF.[FeedID] FROM [bx_UserFeeds] UF INNER JOIN [bx_Feeds] F ON UF.[FeedID]=F.[ID] WHERE UF.[UserID] IN(@FriendUserIDs) AND UF.[FeedID]<@FeedID "+condition+@" AND F.[TargetUserID]<>@UserID GROUP BY UF.[FeedID] ORDER BY UF.[FeedID] DESC; SELECT * FROM [bx_Feeds] WHERE [ID] IN(SELECT [FeedID] FROM @FeedIDs) ORDER BY [ID] DESC; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(SELECT [FeedID] FROM @FeedIDs) AND [UserID] IN(@FriendUserIDs) ORDER BY [FeedID] DESC,[CreateDate] DESC; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(SELECT [FeedID] FROM [bx_UserFeeds] UF INNER JOIN [bx_Feeds] F ON UF.[FeedID]=F.[ID] WHERE F.[ID] IN(SELECT [FeedID] FROM @FeedIDs) AND UF.[UserID]=F.[TargetUserID] AND F.[TargetUserID] IN(@FriendUserIDs)) ORDER BY [CreateDate] DESC; " , db.ParamReplace("@FriendUserIDs", StringUtil.Join(friendUserIDs)) , db.Param<int>("@UserID", userID) , db.Param<int>("@FeedID", feedID) , db.Param<Guid>("@AppID", appID) , db.Param<int?>("@ActionType", actionType) ) ) { FeedCollection feeds = new FeedCollection(reader); if (reader.NextResult()) { Feed currentFeed = null; DataReaderWrap readerWrap = new DataReaderWrap(reader); while (readerWrap.Next) { UserFeed userFeed = new UserFeed(readerWrap); if (currentFeed == null || userFeed.FeedID != currentFeed.ID) { currentFeed = feeds.GetValue(userFeed.FeedID); if(currentFeed!=null) currentFeed.Users = new UserFeedCollection(); } if (currentFeed != null) { if (userFeed.UserID != currentFeed.TargetUserID) currentFeed.Users.Add(userFeed); else currentFeed.IsSpecial = true; } } } if (reader.NextResult())// 这一组是特殊的 处理类似加好友的 如果TargetUserID 是好友 需要把UserFeeds 表里与该动态有关的用户都取出来 { Feed currentFeed = null; DataReaderWrap readerWrap = new DataReaderWrap(reader); while (readerWrap.Next) { UserFeed userFeed = new UserFeed(readerWrap); if (currentFeed == null || userFeed.FeedID != currentFeed.ID) { currentFeed = feeds.GetValue(userFeed.FeedID); if (currentFeed != null) currentFeed.Users = new UserFeedCollection(); } if (currentFeed != null) { if (userFeed.UserID!=userID && userFeed.UserID != currentFeed.TargetUserID) currentFeed.Users.Add(userFeed); } } } return feeds; } } */ #endregion }
public async Task Post([FromBody] FeedCollection collection) { await _collections.Add(collection); }
public async Task Put([FromBody] FeedCollection collection) { await _collections.Update(collection); }
private void GetFeeds() { bool haveMore; if (FeedType == FeedType.AllUserFeed) { m_FeedList = FeedBO.Instance.GetAllUserFeeds(MyUserID, int.MaxValue, GetFeedCount, FeedAppID, FeedAction, out haveMore); } else if (FeedType == FeedType.FriendFeed) { m_FeedList = FeedBO.Instance.GetFriendFeeds(MyUserID, int.MaxValue, GetFeedCount, FeedAppID, FeedAction, out haveMore); } else m_FeedList = FeedBO.Instance.GetUserFeeds(MyUserID, MyUserID, int.MaxValue, GetFeedCount, FeedAppID, FeedAction, out haveMore); m_HaveMoreFeeds = haveMore; }
private void LoadMyCollection() { var Collection = TransferInterface.LoadMyCollection(); mainCollection = Collection; }
public void FeedSearchList(string filter, int page, int defaultPageSize , FeedSearchListHeadFootTemplate head , FeedSearchListHeadFootTemplate foot , FeedSearchListItemTemplate item) { FeedSearchFilter feedSearchFilter = FeedSearchFilter.GetFromFilter(filter); int totalCount; FeedCollection feeds = new FeedCollection(); //int pageSize; FeedSearchFilter tempFilter; if (feedSearchFilter.IsNull) { tempFilter = new FeedSearchFilter(); tempFilter.PageSize = defaultPageSize; tempFilter.Order = FeedSearchFilter.OrderBy.ID; tempFilter.IsDesc = true; } else tempFilter = feedSearchFilter; feeds = FeedBO.Instance.SearchFeeds(page, tempFilter, out totalCount); head(feedSearchFilter, totalCount > 0, totalCount, tempFilter.PageSize); int loginUserID = UserBO.Instance.GetCurrentUserID(); int i = 0; float timeDiffrence = UserBO.Instance.GetUserTimeDiffrence(User.Current); foreach (Feed feed in feeds) { string title = FeedBO.Instance.FormatFeedTitle(loginUserID, timeDiffrence, FeedType.AllUserFeed, feed); string description = FeedBO.Instance.FormatFeedDescription(loginUserID, feed); item(i++, feed, title, description, true); } foot(feedSearchFilter, totalCount > 0, totalCount, tempFilter.PageSize); }
public override FeedCollection SearchFeeds(int pageNumber, FeedSearchFilter filter, ref int totalCount) { using (SqlSession db = new SqlSession()) { List<int> feedIDs = new List<int>(); using (SqlQuery query = db.CreateQuery()) { query.Pager.IsDesc = filter.IsDesc; if (filter.UserID != null) { query.Pager.ResultFields = "[FeedID]"; if (filter.Order == FeedSearchFilter.OrderBy.ID) query.Pager.SortField = "[ID]"; else { query.Pager.SortField = "[CreateDate]"; query.Pager.PrimaryKey = "[ID]"; } query.Pager.TableName = "[bx_UserFeeds]"; query.Pager.Condition = @" UserID = @UserID " + (filter.AppID == null ? "" : (@" AND [FeedID] IN(SELECT [ID] FROM [bx_Feeds] WHERE [AppID]=@AppID " + (filter.AppActionType == null ? "" : (" AND [ActionType] = @ActionType)")))) + (filter.BeginDate == null ? "" : (" AND [CreateDate] > @BeginDate")) + (filter.EndDate == null ? "" : (" AND [CreateDate] < @EndDate")); } else { query.Pager.ResultFields = "[ID]"; if (filter.Order == FeedSearchFilter.OrderBy.ID) query.Pager.SortField = "[ID]"; else { query.Pager.SortField = "[CreateDate]"; query.Pager.PrimaryKey = "[ID]"; } query.Pager.TableName = "[bx_Feeds]"; query.Pager.Condition = @" 1 = 1 " + (filter.AppID == null ? "" : (@" AND [AppID]=@AppID ") + (filter.AppActionType == null ? "" : (" AND [ActionType] = @ActionType"))) + (filter.BeginDate == null ? "" : (" AND [CreateDate] > @BeginDate")) + (filter.EndDate == null ? "" : (" AND [CreateDate] < @EndDate")); } query.Pager.PageNumber = pageNumber; query.Pager.PageSize = filter.PageSize; query.Pager.TotalRecords = totalCount; query.Pager.SelectCount = true; query.CreateParameter<int?>("@UserID", filter.UserID, SqlDbType.Int); query.CreateParameter<Guid?>("@AppID", filter.AppID, SqlDbType.UniqueIdentifier); query.CreateParameter<int?>("@ActionType", filter.AppActionType, SqlDbType.Int); query.CreateParameter<DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime); query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime); using (XSqlDataReader reader = query.ExecuteReader()) { while (reader.Read()) { feedIDs.Add(reader.GetInt32(0)); } if (reader.NextResult()) { while (reader.Read()) { totalCount = reader.GetInt32(0); } } } } if (feedIDs.Count == 0) return new FeedCollection(); string sql; string sortField = (filter.Order == FeedSearchFilter.OrderBy.ID ? "[ID]" : "[CreateDate]"); string order = (filter.IsDesc ? " DESC " : " ASC "); if (filter.UserID == null) { sql = @" SELECT * FROM [bx_Feeds] WHERE [ID] IN(@FeedIDs) ORDER BY " + sortField + order + @"; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(@FeedIDs) ORDER BY [FeedID] DESC,[CreateDate] DESC; "; } else { sql = @" SELECT * FROM [bx_Feeds] WHERE [ID] IN(@FeedIDs) ORDER BY " + sortField + order + @"; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(@FeedIDs) ORDER BY [FeedID] DESC,[CreateDate] DESC; SELECT * FROM [bx_UserFeeds] WHERE [FeedID] IN(SELECT [FeedID] FROM [bx_UserFeeds] UF INNER JOIN [bx_Feeds] F ON UF.[FeedID]=F.[ID] WHERE F.[ID] IN(@FeedIDs) AND UF.[UserID]=F.[TargetUserID] AND F.[TargetUserID]=@UserID) ORDER BY [CreateDate] DESC; "; } using (SqlQuery query = db.CreateQuery()) { query.CommandText = sql; query.CreateParameter<int?>("@UserID", filter.UserID, SqlDbType.Int); query.CreateInParameter<int>("@FeedIDs", feedIDs); using (XSqlDataReader reader = query.ExecuteReader()) { FeedCollection feeds = new FeedCollection(reader); if (reader.NextResult()) { Feed currentFeed = null; while (reader.Read()) { UserFeed userFeed = new UserFeed(reader); currentFeed = ProcessFeed(feeds, currentFeed, userFeed, false); } } if (reader.NextResult())// 这一组是特殊的 处理类似加好友的 如果TargetUserID 是好友 需要把UserFeeds 表里与该动态有关的用户都取出来 { Feed currentFeed = null; while (reader.Read()) { UserFeed userFeed = new UserFeed(reader); currentFeed = ProcessFeed(feeds, currentFeed, userFeed, true); } } return feeds; } } } }
private void GetFeeds() { bool haveMore; m_FeedList = FeedBO.Instance.GetUserFeeds(MyUserID, UserID, int.MaxValue, CurrentGetCount, FeedAppID, FeedAction, out haveMore); m_HaveMoreFeeds = haveMore; }