public void GetCatalogShots(ShotCatalog shotCatalog, int pageIndex=0, int perPage=0) { string requestUrl = base.MegerRequestCatalogUrl(shotCatalog, pageIndex, perPage); DataRequestHelper requestHelper = new DataRequestHelper(); requestHelper.ExcuteAsyncRequest(requestUrl, Method.GET, base._postArgumentList); requestHelper.AsyncResponseComplated += (responseData, ex) => { if (!string.IsNullOrEmpty(responseData.ToString())) { if (!base.IsRateLimitedRequest(responseData.ToString())) { try { CatalogShots catalogShots = JsonConvert.DeserializeObject<CatalogShots>(responseData.ToString()); if (AsyncCatalogShotsComplated != null) AsyncCatalogShotsComplated(catalogShots, null); } catch (Exception se) { if (AsyncCatalogShotsComplated != null) AsyncCatalogShotsComplated("Json format error.try later", se); } } else { if (AsyncCatalogShotsComplated != null) AsyncCatalogShotsComplated("Rate limited for a minute.", new Exception()); } } }; }
public string MegerRequestCatalogUrl(ShotCatalog catalogType, int pageIndex, int prePage) { _basicRequestUrl += "shots/"; switch (catalogType) { case ShotCatalog.Everyone: _basicRequestUrl += ShotCatalog.Everyone.ToString().ToLower(); break; case ShotCatalog.Debuts: _basicRequestUrl += ShotCatalog.Debuts.ToString().ToLower(); break; case ShotCatalog.Popular: _basicRequestUrl += ShotCatalog.Popular.ToString().ToLower(); break; } if (_postArgumentList == null) _postArgumentList = new List<KeyValuePair<string, object>>(); if (pageIndex != 0) _postArgumentList.Add(new KeyValuePair<string, object>("page", pageIndex)); if (prePage > 0 && prePage <= 30) _postArgumentList.Add(new KeyValuePair<string, object>("per_page", prePage)); return _basicRequestUrl; }
public void GetCatalogShots(ShotCatalog shotCatalog, int pageIndex = 0, int perPage = 0) { string requestUrl = base.MegerRequestCatalogUrl(shotCatalog, pageIndex, perPage); DataRequestHelper requestHelper = new DataRequestHelper(); requestHelper.ExcuteAsyncRequest(requestUrl, Method.GET, base._postArgumentList); requestHelper.AsyncResponseComplated += (responseData, ex) => { if (!string.IsNullOrEmpty(responseData.ToString())) { if (!base.IsRateLimitedRequest(responseData.ToString())) { try { CatalogShots catalogShots = JsonConvert.DeserializeObject <CatalogShots>(responseData.ToString()); if (AsyncCatalogShotsComplated != null) { AsyncCatalogShotsComplated(catalogShots, null); } } catch (Exception se) { if (AsyncCatalogShotsComplated != null) { AsyncCatalogShotsComplated("Json format error.try later", se); } } } else { if (AsyncCatalogShotsComplated != null) { AsyncCatalogShotsComplated("Rate limited for a minute.", new Exception()); } } } }; }
public int GetCurrentPage(ShotCatalog catalogType) { int currentPage = 0; if (this.PageControlList == null) { return(0); } PaginationInfo pageInfo = new EntityModels.PaginationInfo(); switch (catalogType) { #region format tiem add page infor case Common.ShotCatalog.Popular: pageInfo.PageType = PagintaionType.CatalogPopular; break; case Common.ShotCatalog.Everyone: pageInfo.PageType = PagintaionType.CatalogEveryOne; break; case Common.ShotCatalog.Debuts: pageInfo.PageType = PagintaionType.CatalogDebuts; break; #endregion } this.PageControlList.ForEach(queryEntity => { if (queryEntity.PageType.Equals(pageInfo.PageType)) { currentPage = queryEntity.CurrentIndex; return; } }); return(currentPage); }
public string MegerRequestCatalogUrl(ShotCatalog catalogType, int pageIndex, int prePage) { _basicRequestUrl += "shots/"; switch (catalogType) { case ShotCatalog.Everyone: _basicRequestUrl += ShotCatalog.Everyone.ToString().ToLower(); break; case ShotCatalog.Debuts: _basicRequestUrl += ShotCatalog.Debuts.ToString().ToLower(); break; case ShotCatalog.Popular: _basicRequestUrl += ShotCatalog.Popular.ToString().ToLower(); break; } if (_postArgumentList == null) { _postArgumentList = new List <KeyValuePair <string, object> >(); } if (pageIndex != 0) { _postArgumentList.Add(new KeyValuePair <string, object>("page", pageIndex)); } if (prePage > 0 && prePage <= 30) { _postArgumentList.Add(new KeyValuePair <string, object>("per_page", prePage)); } return(_basicRequestUrl); }
public int GetCurrentPage(ShotCatalog catalogType) { int currentPage = 0; if (this.PageControlList == null) return 0; PaginationInfo pageInfo = new EntityModels.PaginationInfo(); switch (catalogType) { #region format tiem add page infor case Common.ShotCatalog.Popular: pageInfo.PageType = PagintaionType.CatalogPopular; break; case Common.ShotCatalog.Everyone: pageInfo.PageType = PagintaionType.CatalogEveryOne; break; case Common.ShotCatalog.Debuts: pageInfo.PageType = PagintaionType.CatalogDebuts; break; #endregion } this.PageControlList.ForEach(queryEntity => { if (queryEntity.PageType.Equals(pageInfo.PageType)) { currentPage = queryEntity.CurrentIndex; return; } }); return currentPage; }