Esempio n. 1
0
        private static void SetPageItemsDownloaded(IEnumerable <Objects.LatestPageIndexItem> items, string languageCode)
        {
            string fileName          = string.Format("AgilityPageIndex_{0}.bin", languageCode);
            string pageIndexFilePath = Path.Combine(BaseCache.GetLocalContentFilePath(), fileName);

            lock (_pageIndexLock)
            {
                Objects.LatestPageIndex index = GetLatestPageItemIndex(languageCode);
                if (index == null)
                {
                    return;
                }

                Objects.LatestPageIndexItem indexItem = null;
                foreach (var item in items)
                {
                    if (index.Index.TryGetValue(item.PageID, out indexItem))
                    {
                        indexItem.Downloaded = item.Downloaded;
                    }
                }

                BaseCache.WriteFile(index, pageIndexFilePath);
                AgilityContext.HttpContext.Items[fileName] = index;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Returns true if the version of the page is out of date
        /// </summary>
        /// <param name="latestVersionID"></param>
        /// <param name="pageID"></param>
        /// <param name="languageCode"></param>
        /// <returns></returns>
        private static bool CheckPageIndex(int latestVersionID, int pageID, string languageCode)
        {
            Objects.LatestPageIndex index = GetLatestPageItemIndex(languageCode);

            //return true to indicate that we need to check again...
            if (pageID > 0)
            {
                //checking for a specific page
                Objects.LatestPageIndexItem indexItem = null;
                if (index.Index.TryGetValue(pageID, out indexItem))
                {
                    return(latestVersionID < indexItem.MaxVersionID);
                }
            }
            else
            {
                //if we don't have a page to check for
                return(latestVersionID < index.MaxVersionID);
            }


            return(true);
        }