protected override async void SetById(long id) { var innerMvdataResult = await this._netWorkServices.GetAsync <Mv>("Common", "GetMvById", new { id }); if (!innerMvdataResult.Successed) { //todo 网络连接四百 return; } _innerMv = innerMvdataResult.Data; var task1 = _netWorkServices.GetAsync <CommentCollection>("Common", "GetCommentById", new { commentThreadId = _innerMv.CommendThreadId }); var task2 = _netWorkServices.GetAsync <Mv[]>("Common", "GetSimiMv", new { id }); await Task.WhenAll(task1, task2); if (task1.Result.Successed && task2.Result.Successed) { _innerComment = task1.Result.Data; await Task.WhenAll( NewComments.AddRangeAsync(_innerComment.Comments), HotComments.AddRangeAsync(_innerComment.HotComments), SimiMvs.AddRangeAsync(task2.Result.Data)); this._currentPage = 1; RaiseAllPropertyChanged(); RefreshCompleated?.Invoke(this, EventArgs.Empty); } else { //todo 网络连接四百 } }
async void INavigationAware.OnNavigatedTo(NavigationContext navigationContext) { if (_dataHasInit) { return; } var tasks = new List <Task <NetWorkDataResult <KeyValuePair <DateTime, Global.Model.Artist[]> > > >(4); for (int i = 1; i < 5; i++) { tasks.Add(_netWorkServices.GetAsync <KeyValuePair <DateTime, Global.Model.Artist[]> >("BillBoard", "GetTopArtist", new { type = i })); } await Task.WhenAll(tasks); if (tasks.All(x => x.Result.Successed)) { var temp = tasks.Select(x => x.Result.Data).ToArray(); this.LastUpdateDate = temp[0].Key; await Task.WhenAll(ChineseArtists.AddRangeAsync(temp[0].Value), EruoArtists.AddRangeAsync(temp[1].Value), KoreaArtists.AddRangeAsync(temp[2].Value), JapanArtists.AddRangeAsync(temp[3].Value)); RaisePropertyChanged(nameof(LastUpdateDate)); _dataHasInit = true; } else { //todo 网络连接失败 } }
private async void AlbumOffsetCommandExecute() { _albumOffsetCancellationToken?.Cancel(); var newCancel = new CancellationTokenSource(); _albumOffsetCancellationToken = newCancel; try { if (MoreAlbums) { var netWorkDataResult = await _netWorkServices.GetAsync <KeyValuePair <bool, List <Global.Model.Album> > >("Artist", "GetArtistAlbum", new { id = Id, offset = CurrentAlbumPageOffset * RequireCountPerPage, limit = RequireCountPerPage }, cancelToken : _albumOffsetCancellationToken.Token); if (netWorkDataResult.Successed) { var moreAndAlbums = netWorkDataResult.Data; MoreAlbums = moreAndAlbums.Key; Albums.AddRange(moreAndAlbums.Value); CurrentAlbumPageOffset++; } else { //todo 网络连接失败 } } } catch (OperationCanceledException) { } if (_albumOffsetCancellationToken == newCancel) { _albumOffsetCancellationToken = null; } }
protected override async void SetById(long id) { var detailTask = _netWorkServices.GetAsync <Global.Model.User>("User", "GetUserById", new { id }); var playListTask = _netWorkServices.GetAsync <Global.Model.PlayList[]>("User", "GetUserPlayList", new { id }); await Task.WhenAll(detailTask, playListTask); if (detailTask.Result.Successed && playListTask.Result.Successed) { _innerUser = detailTask.Result.Data; var playList = playListTask.Result.Data; this.UserCreatedPlayLists.Clear(); UserCreatedPlayLists.AddRange(playList.Where(x => x.CreateUser?.UserId == id)); this.UserCollectionPlayLists.Clear(); UserCollectionPlayLists.AddRange(playList.Where(x => x.CreateUser?.UserId != id)); RaiseAllPropertyChanged(); } else { //todo 网络连接失败 } }
private async void InitData() { if (_dataHasInit) { return; } var task1 = _netWorkServices.GetAsync <Global.Model.AnchorRadioCatalogue[]>("FindMusic", "GetAnchorRadioCategories"); var task2 = _netWorkServices.GetAsync <Global.Model.Program[]>("FindMusic", "GetRecommendProgram"); await Task.WhenAll(task1, task2); if (task1.Result.Successed && task2.Result.Successed) { await Task.WhenAll(AnchorRadioCatalogues.AddRangeAsync(task1.Result.Data), WonderfulRadioRecommends.AddRangeAsync(task2.Result.Data)); } else { //todo 显示提示信息 } }
private async void InitData() { var netWorkDataResult = await _netWorkServices.GetAsync <Music[]>("FindMusic", "GetEveryDayMusicRecommend"); if (netWorkDataResult.Successed) { var temp = netWorkDataResult.Data; await RecommendMusics.AddRangeAsync(temp); } else { //todo 网络失败 } }
public override async void OnNavigatedTo(NavigationContext navigationContext) { if (SelectedIndex == 0 && !_dataIsInit) { var netWorkDataResult = await _netWorkServices.GetAsync <Global.Model.Mv[]>("Mv", "GetNetMv", new { limit = Settings.Default.LimitPerPage }); if (netWorkDataResult.Successed) { FeaturedViewModel.NewMvs.AddRange(netWorkDataResult.Data); _dataIsInit = true; } else { //todo 网络连接失败 } } base.OnNavigatedTo(navigationContext); }