public override async void LoadViewData () { this.mEventAggregator.GetEvent<ReceivedChatReconnectedEvent>().Subscribe(async b => { mBiaos.Clear(); mLastId = 0; ShowBusyBox(); await LoadBiaos(true); CloseBusyBox(); }, ThreadOption.UIThread); this.mEventAggregator.GetEvent<ReceivedBiaoCancelEvent>().Subscribe(b => { lock(mLockObject) { var biao = this.Biaos.FirstOrDefault(a => a.ID == b); if (biao != null) { biao.IsEnable = false; biao.DisableReason = "已取消"; } } }, ThreadOption.UIThread); this.mEventAggregator.GetEvent<ReceivedBiaoActiveEvent>().Subscribe(item => { lock(mLockObject) { var b = this.Biaos.FirstOrDefault(a => a.ID == item); if(b != null) b.IsEnable = true; } }, ThreadOption.UIThread); this.mEventAggregator.GetEvent<ReceivedBiaoEvent>().Subscribe(item => { lock(mLockObject) { var uibiao = new UiBaio2 { ID = item.ID, Price = item.Price, SearchWord = item.SearchWord, ShopType = item.BangpaiType, Salary = item.Salary, IsSaleOver = item.IsSaleOver, YqBindSfz = item.YqBindSfz, YqBindPhone = item.YqBindPhone, YqManualCheck = item.YqManualCheck, YqMonthCount = item.YqMonthCount, YqRegisterDate = item.YqRegisterDate, YqUserLevel = item.YqUserLevel, YqWeekCount = item.YqWeekCount, Details = item.Details, IsEnable = true }; mBiaos.Insert(0,uibiao); } }, ThreadOption.UIThread); ShowBusyBox(); await LoadBiaos(true); CloseBusyBox(); }
public async Task LoadBiaos (bool isFirst) { if(isFirst) { mIsLoadedAllData = false; } if(mIsSeaching || mIsLoadedAllData) { return; } IsPageDataLoading = !isFirst; mIsSeaching = true; try { var rv = await Task.Run<CombinationBiaoData>(() => { return mBiaoService.GetBiaosByBiaoju(isFirst ? 0 : mLastId); }); lock(mLockObject) { foreach(var item in rv.Items) { var uibiao = new UiBaio2() { ID = item.ID, Price = item.Price, SearchWord = item.SearchWord, ShopType = item.BangpaiType, CreateTime = item.CreateTime, Salary = item.Salary, IsSaleOver = item.IsSaleOver, YqBindSfz = item.YqBindSfz, YqBindPhone = item.YqBindPhone, YqManualCheck = item.YqManualCheck, YqMonthCount = item.YqMonthCount, YqRegisterDate = item.YqRegisterDate, YqUserLevel = item.YqUserLevel, YqWeekCount = item.YqWeekCount, YqCheckRegDate = item.YqCheckRegDate, Details = item.Details, Steps = RunningStepsData.MakeDataWithString( item.Steps), IsEnable = item.IsEnable == true && item.Finished < item.PlanCount, MaxFinishDaysForOldCustomer = item.MaxFinishDaysForOldCustomer, AllowType = item.AllowXiakeType, RejectOneBiaoju = item.RejectOneBiaoju, }; if(item.IsEnable == false) { uibiao.DisableReason = "已关闭"; } if(item.Finished >= item.PlanCount) { uibiao.DisableReason = "抢光了"; } mBiaos.Add(uibiao); } } mLastId = rv.Items.Count > 0 ? rv.Items.Min(a=>a.ID ) : 0; mIsLoadedAllData = rv.IsLoadedAllData; mLastRefreshTime = DateTime.Now; } catch(Exception e) { e.Show(); } finally { IsPageDataLoading = false; mIsSeaching = false; } }