Exemplo n.º 1
0
        /// <summary>
        /// 只有tmdb才需要,允許中斷後再重新從上次失敗的頁數開始抓; omdb目前不需要
        /// </summary>
        /// <returns></returns>
        public int GetStartPage()
        {
            var keyFilter = GetApiLatestUpdateModel(ApiName, "GetPopularMovie");

            var latestData = ApiLatestUpdateRepository.GetByFilter(keyFilter).FirstOrDefault();

            return(latestData == null ? 0 : latestData.CurrentPages);
        }
Exemplo n.º 2
0
        public bool IsLatest(ApiLatestUpdateModel latestData, int totalPages)
        {
            if (latestData.TotalPages == totalPages)
            {
                return(true);
            }

            ApiLatestUpdateRepository.UpdateTotalPage(latestData, totalPages);
            return(false);
        }
Exemplo n.º 3
0
        public bool IsDataEnd()
        {
            //先檢查是否為最新的,如果不是重新再爬
            var apiData = _GetPopularMovie();

            var keyFilter  = GetApiLatestUpdateModel(ApiName, "GetPopularMovie");
            var latestData = ApiLatestUpdateRepository.GetByFilter(keyFilter).FirstOrDefault();

            bool isLatest = IsLatest(latestData, apiData.Total_pages);

            if (isLatest)
            {
                //最新的還要再檢查是否current page > total pages
                return(latestData.CurrentPages > apiData.Total_pages);
            }
            else
            {
                return(false);
            }
        }