Exemplo n.º 1
0
        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.Dianpus.Clear();
            }

            try
            {

                var jhTypes = mCacheSearchForm.JianghuTypes.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(a => (BangpaiType)Enum.Parse(typeof(BangpaiType), a)).ToArray();
                var rv = await Task.Run<CombinationDianpuData>(() => {return mDianpuMgmtService.SearchDianpusByMengzhu( jhTypes,  mCacheSearchForm.StartDate,
                    mCacheSearchForm.EndDate,  mCacheSearchForm.IsTimeRangeRequired, isFirst ? 0 : mLastId); });
                
                foreach(var dp in rv.Items )
                { 
                    var x = new UIDianpu( )
                    {
                        ID = dp.ID,
                        BangpaiType = dp.BangpaiType,
                        Name=dp.Name ,
                        Url = dp.Url,
                        XiakeName = dp.XiakeName,
                        XiakeId = dp.XiakeId,
                        CreateTime = dp.CreateTime 
                    };
                    this.Dianpus.Add(x);
                }

                if (rv.Items .Count > 0)
                {
                    mLastId = rv.Items [rv.Items .Count - 1].ID;
                }
                mIsLoadedAllData = rv.IsLoadedAllData;
                if (isFirst)
                {
                    DianpuView.View.MoveCurrentToFirst();
                    TotalCount = rv.TotalCount;
                }
            } catch(Exception e)
            {
                e.Show();
            }
            finally
            {
                mIsSeaching = false;
                IsPageDataLoading = false;
            }
            
        }
Exemplo n.º 2
0
 public DianpuMgmtViewModel() 
 { 
     //BindingOperations.EnableCollectionSynchronization(Servers,LockObject);
     Form = new SearchForm();
 }