/// <summary> /// 获取一页与好友的聊天记录。 /// </summary> /// <param name="myID">自己的UserID</param> /// <param name="friendID">好友的ID</param> /// <param name="pageSize">页大小</param> /// <param name="pageIndex">页索引</param> /// <returns>聊天记录页</returns> public ChatRecordPage GetChatRecordPage(ChatRecordTimeScope chatRecordTimeScope, string myID, string friendID, int pageSize, int pageIndex) { if (this.transactionScopeFactory == null) { return(new ChatRecordPage(0, 0, new List <ChatMessageRecord>())); } DateTimeScope timeScope = null; DateTime now = DateTime.Now; if (chatRecordTimeScope == ChatRecordTimeScope.RecentWeek) //一周 { timeScope = new DateTimeScope(now.AddDays(-7), now); } else if (chatRecordTimeScope == ChatRecordTimeScope.RecentMonth)//一月 { timeScope = new DateTimeScope(now.AddDays(-31), now); } else if (chatRecordTimeScope == ChatRecordTimeScope.Recent3Month)//三月 { timeScope = new DateTimeScope(now.AddDays(-91), now); } else //全部 { } IFilterTree tree1 = new SimpleFilterTree(new Filter(ChatMessageRecord._SpeakerID, myID), new Filter(ChatMessageRecord._AudienceID, friendID)); IFilterTree tree2 = new SimpleFilterTree(new Filter(ChatMessageRecord._SpeakerID, friendID), new Filter(ChatMessageRecord._AudienceID, myID)); IFilterTree tree = new ComplexFilterTree(LogicType.Or, tree1, tree2); if (timeScope != null) { tree = new ComplexFilterTree(LogicType.And, tree, new Filter(ChatMessageRecord._OccureTime, new DateTime[] { timeScope.StartDate, timeScope.EndDate }, ComparisonOperators.BetweenAnd)); } //最后一页 if (pageIndex == int.MaxValue) { int total = 0; using (TransactionScope scope = this.transactionScopeFactory.NewTransactionScope()) { IOrmAccesser <ChatMessageRecord> accesser = scope.NewOrmAccesser <ChatMessageRecord>(); total = (int)accesser.GetCount(tree); scope.Commit(); } int pageCount = total / pageSize; if (total % pageSize > 0) { pageCount += 1; } pageIndex = pageCount - 1; } int totalCount = 0; ChatMessageRecord[] page = null; using (TransactionScope scope = this.transactionScopeFactory.NewTransactionScope()) { IOrmAccesser <ChatMessageRecord> accesser = scope.NewOrmAccesser <ChatMessageRecord>(); page = accesser.GetPage(tree, pageSize, pageIndex, ChatMessageRecord._AutoID, true, out totalCount); scope.Commit(); } return(new ChatRecordPage(totalCount, pageIndex, new List <ChatMessageRecord>(page))); }
protected override async Task PrepareAsync() { await base.PrepareAsync(); AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => new RecordingItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) }; _defaultScreen = new RecordingsShowItemsScreenData(picd); _availableScreens = new List <AbstractScreenData> { _defaultScreen, new RecordingsFilterByChannelScreenData(), //new VideosFilterByActorScreenData(), //new VideosFilterByDirectorScreenData(), //new VideosFilterByWriterScreenData(), //new VideosFilterByGenreScreenData(), //new VideosFilterByYearScreenData(), //new VideosFilterBySystemScreenData(), new RecordingsSimpleSearchScreenData(picd), }; _defaultSorting = new SortByRecordingDateDesc(); _availableSortings = new List <Sorting> { _defaultSorting, new SortByTitle(), //new VideoSortByFirstGenre(), //new VideoSortByDuration(), //new VideoSortByFirstActor(), //new VideoSortByFirstDirector(), //new VideoSortByFirstWriter(), //new VideoSortBySize(), //new VideoSortByAspectRatio(), //new SortBySystem(), }; var optionalMias = new[] { MovieAspect.ASPECT_ID, EpisodeAspect.ASPECT_ID, AudioAspect.ASPECT_ID, VideoAspect.ASPECT_ID, VideoStreamAspect.ASPECT_ID, VideoAudioStreamAspect.ASPECT_ID, ImageAspect.ASPECT_ID, GenreAspect.ASPECT_ID }.Union(MediaNavigationModel.GetMediaSkinOptionalMIATypes(MediaNavigationMode)); IFilterTree filterTree = new SimpleFilterTree(); if (_filter != null) { filterTree.AddFilter(_filter); } if (_applyUserFilter) { var userFilter = UserHelper.GetUserRestrictionFilter(_necessaryMias.ToList()); if (userFilter != null) { filterTree.AddFilter(userFilter); } } _customRootViewSpecification = new StackingViewSpecification(_viewName, filterTree, _necessaryMias, optionalMias, true) { MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE }; }
/// <summary> /// 获取一页群聊天记录。 /// </summary> /// <param name="groupID">群ID</param> /// <param name="pageSize">页大小</param> /// <param name="pageIndex">页索引</param> /// <returns>聊天记录页</returns> public ChatRecordPage GetGroupChatRecordPage(ChatRecordTimeScope chatRecordTimeScope, string groupID, int pageSize, int pageIndex) { if (this.transactionScopeFactory == null) { return(new ChatRecordPage(0, 0, new List <ChatMessageRecord>())); } DateTimeScope timeScope = null; var now = DateTime.Now; if (chatRecordTimeScope == ChatRecordTimeScope.RecentWeek) //一周 { timeScope = new DateTimeScope(now.AddDays(-7), now); } else if (chatRecordTimeScope == ChatRecordTimeScope.RecentMonth)//一月 { timeScope = new DateTimeScope(now.AddDays(-31), now); } else if (chatRecordTimeScope == ChatRecordTimeScope.Recent3Month)//三月 { timeScope = new DateTimeScope(now.AddDays(-91), now); } else //全部 { } var filterList = new List <Filter>(); filterList.Add(new Filter(ChatMessageRecord._AudienceID, groupID)); filterList.Add(new Filter(ChatMessageRecord._IsGroupChat, true)); if (timeScope != null) { filterList.Add(new Filter(ChatMessageRecord._OccureTime, new DateTime[] { timeScope.StartDate, timeScope.EndDate }, ComparisonOperators.BetweenAnd)); } var tree = new SimpleFilterTree(filterList); //最后一页 if (pageIndex == int.MaxValue) { var total = 0; using (var scope = this.transactionScopeFactory.NewTransactionScope()) { var accesser = scope.NewOrmAccesser <ChatMessageRecord>(); total = (int)accesser.GetCount(tree); scope.Commit(); } var pageCount = total / pageSize; if (total % pageSize > 0) { pageCount += 1; } pageIndex = pageCount - 1; } var totalCount = 0; ChatMessageRecord[] page = null; using (var scope = this.transactionScopeFactory.NewTransactionScope()) { var accesser = scope.NewOrmAccesser <ChatMessageRecord>(); page = accesser.GetPage(tree, pageSize, pageIndex, ChatMessageRecord._AutoID, true, out totalCount); scope.Commit(); } return(new ChatRecordPage(totalCount, pageIndex, new List <ChatMessageRecord>(page))); }
/// <summary> /// 获取一页群聊天记录。 /// </summary> /// <param name="groupID">群ID</param> /// <param name="pageSize">页大小</param> /// <param name="pageIndex">页索引</param> /// <returns>聊天记录页</returns> public ChatRecordPage GetGroupChatRecordPage(ChatRecordTimeScope chatRecordTimeScope, string groupID, int pageSize, int pageIndex) { if (this.transactionScopeFactory == null) { return new ChatRecordPage(0, 0, new List<ChatMessageRecord>()); } DateTimeScope timeScope = null; DateTime now = DateTime.Now; if (chatRecordTimeScope == ChatRecordTimeScope.RecentWeek) //一周 { timeScope = new DateTimeScope(now.AddDays(-7), now); } else if (chatRecordTimeScope == ChatRecordTimeScope.RecentMonth)//一月 { timeScope = new DateTimeScope(now.AddDays(-31), now); } else if (chatRecordTimeScope == ChatRecordTimeScope.Recent3Month)//三月 { timeScope = new DateTimeScope(now.AddDays(-91), now); } else //全部 { } List<Filter> filterList = new List<Filter>(); filterList.Add(new Filter(ChatMessageRecord._AudienceID, groupID)); filterList.Add(new Filter(ChatMessageRecord._IsGroupChat, true)); if (timeScope != null) { filterList.Add(new Filter(ChatMessageRecord._OccureTime, new DateTime[] { timeScope.StartDate, timeScope.EndDate }, ComparisonOperators.BetweenAnd)); } SimpleFilterTree tree = new SimpleFilterTree(filterList); //最后一页 if (pageIndex == int.MaxValue) { int total = 0; using (TransactionScope scope = this.transactionScopeFactory.NewTransactionScope()) { IOrmAccesser<ChatMessageRecord> accesser = scope.NewOrmAccesser<ChatMessageRecord>(); total = (int)accesser.GetCount(tree); scope.Commit(); } int pageCount = total / pageSize; if (total % pageSize > 0) { pageCount += 1; } pageIndex = pageCount - 1; } int totalCount = 0; ChatMessageRecord[] page = null; using (TransactionScope scope = this.transactionScopeFactory.NewTransactionScope()) { IOrmAccesser<ChatMessageRecord> accesser = scope.NewOrmAccesser<ChatMessageRecord>(); page = accesser.GetPage(tree, pageSize, pageIndex, ChatMessageRecord._AutoID, true, out totalCount); scope.Commit(); } return new ChatRecordPage(totalCount, pageIndex, new List<ChatMessageRecord>(page)); }