Example #1
0
        //------------------------------------------------------------------------------------
        /// <summary>
        ///  If any changes were detected during the last refresh, update all the in-memory
        ///  store items with the changes.
        /// </summary>
        //------------------------------------------------------------------------------------
        public void UndeferRefreshStoreItems()
        {
            if (m_deferredStoreItems == null)
            {
                return;
            }

            RefreshInProgress = true;
            Planner.Instance.ClearEventLog();

            // First pass
            foreach (DeferredStoreItem deferredItem in m_deferredStoreItems)
            {
                string storeKey = deferredItem.StoreKey;
                Planner.Instance.WriteToEventLog("Item to refresh found: " + storeKey);

                // If the item is in our cache, check whether refresh indicates the item has
                // been deleted since the last refresh.
                if (m_items.ContainsKey(storeKey))
                {
                    StoreItem existingItem = m_items[storeKey];
                    existingItem.DSItem = deferredItem.DSItem;
                    if (existingItem.IsDeletedOnRefresh)
                    {
                        BackgroundRemoveFromCache(existingItem);
                    }
                    else
                    {
                        // Not deleted, so update any properties we haven't changed with any
                        // new values from the backing store.
                        List <ItemProperty> itemProperties = existingItem.GetItemProperties();
                        foreach (ItemProperty itemProperty in itemProperties)
                        {
                            if (!itemProperty.IsValueChanged())
                            {
                                BackgroundSyncRefreshedProperty(existingItem, itemProperty);
                            }
                        }
                    }
                }

                // Not in the cache - if active or fixed, the item was added since the last refresh.
                else
                {
                    StoreItem storeItem = deferredItem.ItemStore.CreateAndInitializeItemFromDS(deferredItem.DSItem);
                    if (storeItem.IsActive || storeItem.IsFixed)
                    {
                        BackgroundAddToCache(storeItem);
                    }
                }
            }

            RefreshInProgress = false;
        }