コード例 #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.Xiakes.Clear();
            }

            try
            {

                XiakeType[] xiakeTypes =
                    mCacheSearchForm.Types.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(a => (XiakeType)Enum.Parse(typeof(XiakeType), a)).ToArray();
                XiakeLevel[] xiakeLevels = mCacheSearchForm.Levels.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(a => (XiakeLevel)Enum.Parse(typeof(XiakeLevel), a)).ToArray();
                XiakeStatus[] xiakeStatus = mCacheSearchForm.Status.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(a => (XiakeStatus)Enum.Parse(typeof(XiakeStatus), a)).ToArray();


                var rv = await Task.Run(() =>
                {
                    return mXiakeMgmtService.SearchXiakesByMengzhu(xiakeTypes,xiakeLevels, xiakeStatus,
                        mCacheSearchForm.XiakeName,isFirst ? 0 : mLastId,mCacheSearchForm.IsTimeRangeRequired, mCacheSearchForm.SearchTimeType, mCacheSearchForm.StartDate,
                        mCacheSearchForm.EndDate, mCacheSearchForm.IsOnline);
                });
                foreach(var xk in rv.Items)
                { 
                    var x = new UIXiake()
                    {
                        ID = xk.ID,
                        Name = xk.Name,
                        QQ = xk.QQ,
                        Mail = xk.Mail,
                        Type = xk.Type,
                        Level = xk.Level,
                        Status = xk.Status,
                        JoinTime = xk.JoinTime,
                        LastLoginTime = xk.LastLoginTime,
                        LoginCount = xk.LoginCount,
                        Credits = xk.Credits,
                        IsOnline = xk.IsOnline
                    };
                    this.Xiakes.Add(x);
                }

                if (rv.Items.Count > 0)
                {
                    mLastId = rv.Items[rv.Items.Count - 1].ID;
                }
                mIsLoadedAllData = rv.IsLoadedAllData;
                if (isFirst)
                {
                    XiakeView.View.MoveCurrentToFirst();
                    TotalCount = rv.TotalCount;
                }
            } catch(Exception)
            {
                throw;
            }
            finally
            {
                mIsSeaching = false;
                IsPageDataLoading = false;
            }
            
        }
コード例 #2
0
 public XiakeMgmtViewModel(   ) 
 { 
     //BindingOperations.EnableCollectionSynchronization(Servers,LockObject);
     Form = new SearchForm();
 }