Esempio n. 1
0
        private static bool CheckMediaGalleryIndex(int mediaGalleryID, DateTime lastModDate)
        {
            Objects.LatestIndex index = GetLatestMediaGalleryIndex();

            //return true to indicate that we need to check again...
            if (mediaGalleryID > 0)
            {
                //checking for a specific gallery
                Objects.LatestIndexItem indexItem = null;
                if (index.Index.TryGetValue(mediaGalleryID, out indexItem))
                {
                    //found it in the index... check it
                    return(lastModDate < indexItem.ModifiedOn);
                }
                else
                {
                    //not in the index, there are not items in this view anymore, only need to check latest if latestVersionID is not 0 (zero)
                    return(lastModDate > DateTime.MinValue);
                }
            }
            else
            {
                //if we don't have a page to check for
                return(lastModDate < index.MaxModDate);
            }
        }
Esempio n. 2
0
        private static bool CheckContentDefinitionIndex(int contentDefinitionID, DateTime lastModDate)
        {
            Objects.LatestIndex index = GetLatestContentDefinitionIndex();

            //return true to indicate that we need to check again...
            if (contentDefinitionID > 0)
            {
                //checking for a specific def
                Objects.LatestIndexItem indexItem = null;
                if (index.Index.TryGetValue(contentDefinitionID, out indexItem))
                {
                    //found it in the index... check it
                    return(lastModDate < indexItem.ModifiedOn);
                }
                else
                {
                    //not in the index
                    return(lastModDate > DateTime.MinValue);
                }
            }
            else
            {
                //if we don't have a page to check for
                return(lastModDate < index.MaxModDate);
            }
        }
Esempio n. 3
0
        private static Objects.LatestIndex GetLatestContentDefinitionIndex()
        {
            string fileName      = "AgilityContentDefinitionIndex.bin";
            string indexFilePath = Path.Combine(BaseCache.GetLocalContentFilePath(), fileName);

            Objects.LatestIndex index = AgilityContext.HttpContext.Items[fileName] as Objects.LatestIndex;
            if (index == null)
            {
                lock (_contentDefIndexLock)
                {
                    index = AgilityContext.HttpContext.Items[fileName] as Objects.LatestIndex;
                    if (index == null)
                    {
                        index = BaseCache.ReadFile <Objects.LatestIndex>(indexFilePath);
                        if (index == null)
                        {
                            index = new Objects.LatestIndex();
                        }

                        DateTime maxModDate = index.MaxModDate;

                        var indexDelta = ServerAPI.GetLatestContentDefinitionIndex(maxModDate);
                        if (indexDelta != null)
                        {
                            foreach (var item in indexDelta)
                            {
                                if (item.ModifiedOn > index.MaxModDate)
                                {
                                    index.MaxModDate = item.ModifiedOn;
                                }

                                index.Index[item.ID] = new Objects.LatestIndexItem()
                                {
                                    ID            = item.ID,
                                    ModifiedOnStr = item.ModifiedOnStr,
                                    Downloaded    = false
                                };
                            }

                            BaseCache.WriteFile(index, indexFilePath);
                            AgilityContext.HttpContext.Items[fileName] = index;
                        }
                    }
                }
            }
            return(index);
        }