private async void LoadItems () { ShowBusyBox(); lock(Lock) { mRenwus.Clear(); } try { var rv = await Task.Run<RenwuData[]>(() => { return mRenwuService.GetRenwusByBiaoju(); }); lock(Lock) { foreach (var item in rv) { var steps = RunningStepsData.MakeDataWithString(item.Steps); var rw = new UIRenwu() { BiaoshiName = item.BiaoshiName, Id = item.ID, BangpaiType = item.BangpaiType, Price = item.Price, RunningTime = item.RunningTime, SearchWord = item.SearchWord, NextStep = item.NextStep, Steps = steps, ProcessValue = GetStepProcessValue(steps, item.NextStep), IsDisabled = item.IsDisabled }; rw.IsLaunchable = GetEnableForRenwu(rw); Renwus.Add(rw); } } } catch (Exception e) { e.Show(); } CloseBusyBox(); }
public override async void LoadViewData () { mEventAggregator.GetEvent<ReceivedRenwuClosedEvent>().Subscribe(id => { lock(Lock) { var rw = this.Renwus.FirstOrDefault(c => c.Id == id); if(rw != null) { rw.IsDisabled = true; rw.IsLaunchable = false; } } }, ThreadOption.UIThread); mEventAggregator.GetEvent<ReceivedRenwuEvent>().Subscribe(a => { lock(Lock) { var renwu = new UIRenwu() { BiaoshiName = a.BiaoshiName, Id = a.ID, BangpaiType = a.BangpaiType, Price = a.Price, RunningTime = a.RunningTime, SearchWord = a.SearchWord, NextStep = JubenType.TaobaoPay, Steps = RunningStepsData.MakeDataWithString(a.Steps), }; Renwus.Insert(0,renwu); } }, ThreadOption.UIThread); mEventAggregator.GetEvent<ReceivedChatReconnectedEvent>().Subscribe(a => LoadItems(), ThreadOption.UIThread); LoadItems(); RenwuHandleProcess(); }
private bool GetEnableForRenwu (UIRenwu renwu) { return renwu.IsDisabled == false && renwu.RunningTime <= DateTime.Now && renwu.NextStep.HasValue; }