private async void LoadCommonData () { Charges.Clear(); ShowBusyBox(); try { var rev = await Task.Run(()=>mChargeMgmtService.GetXiakeChargesByMengzhu(XiakeId)); foreach(var item in rev) { var ch = new UICharge() { ChargeMode = item.ChargeMode, ChargeTime = item.ChargeTime, Comments = item.Comments, Handler = item.Handler, Id = item.ID, PayType = item.PayType, Value = item.Value }; this.Charges.Add(ch); } } catch (Exception e) { e.Show(); } CloseBusyBox(); }
private async Task Search(bool isFirst) { if (Form.HasError || mIsSeaching) { return; } if (isFirst != true && mIsLoadedAllData) { return; } IsPageDataLoading = !isFirst; mIsSeaching = true; if (isFirst) { mIsLoadedAllData = false; mCacheSearchForm = Form.Clone() as SearchForm; this.Charges.Clear(); } try { var payTypes = mCacheSearchForm.PayTypes.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) .Select(a => (PayType)Enum.Parse(typeof(PayType), a)).ToArray(); var modes = mCacheSearchForm.ChargeModes.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) .Select(a => (ChargeMode)Enum.Parse(typeof(ChargeMode), a)).ToArray(); var rv = await Task.Run<CombinationChargeData>(() => { return mChargeMgmtService.SearchChargesByMengzhu( payTypes,modes, mCacheSearchForm.StartDate, mCacheSearchForm.EndDate, mCacheSearchForm.IsTimeRangeRequired, isFirst ? 0 : mLastId); }); foreach (var item in rv.Items ) { var ch = new UICharge() { ChargeMode = item.ChargeMode, ChargeTime = item.ChargeTime, Comments = item.Comments, Handler = item.Handler, Id = item.ID, PayType = item.PayType, Value = item.Value }; this.Charges.Add(ch); } if (rv.Items.Count > 0) { mLastId = rv.Items[rv.Items.Count - 1].ID; } mIsLoadedAllData = rv.IsLoadedAllData; if (isFirst) { ChargeView.View.MoveCurrentToFirst(); TotalCount = rv.TotalCount; } } catch (Exception) { throw; } finally { mIsSeaching = false; IsPageDataLoading = false; } }