internal async Task <StoredQuery> GetStoredQueryAsyncImpl(string queryKey) { using (await CrossThreadLockScope.Enter(m_metadataLock)) { return((StoredQuery)await m_metadataStore.Store.GetAsync(queryKey, typeof(StoredQuery))); } }
// Get ids of items that changed for a given type ID public IAsyncOperation <IList <string> > GetIDsOfChangedItemsForTypeAsync(string typeID) { if (string.IsNullOrEmpty(typeID)) { throw new ArgumentException("typeID"); } return(AsyncInfo.Run(async cancelToken => { List <string> ids = new List <string>(); using (await CrossThreadLockScope.Enter(m_lock)) { await this.EnsureIndexAsync(); foreach (string itemID in m_itemIDIndex) { RecordItemChange change = await this.GetChangeAsync(itemID); if (change != null && change.IsChangeForType(typeID)) { ids.Add(itemID); } } return (IList <string>)ids; } })); }
async Task <SynchronizedType> Ensure(string typeID, CancellationToken cancelToken) { using (await CrossThreadLockScope.Enter(m_lock)) { WeakReference <SynchronizedType> viewRef = null; SynchronizedType view = null; if (m_views.TryGetValue(typeID, out viewRef)) { viewRef.TryGetTarget(out view); } if (view != null) { return(view); } view = new SynchronizedType(this, typeID); await view.Load(); if (viewRef == null) { viewRef = new WeakReference <SynchronizedType>(view); } else { viewRef.SetTarget(view); } m_views[typeID] = viewRef; return(view); } }
// Are there any changes for the given type ID? public IAsyncOperation <bool> HasChangesForTypeAsync(string typeID) { if (string.IsNullOrEmpty(typeID)) { throw new ArgumentException("typeID"); } return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { await this.EnsureIndexAsync(); foreach (string itemID in m_itemIDIndex) { RecordItemChange change = await this.GetChangeAsync(itemID); if (change != null && change.IsChangeForType(typeID)) { return true; } } return false; } })); }
internal async Task PutViewAsync(SynchronizedView view, CancellationToken cancelToken) { using (await CrossThreadLockScope.Enter(m_metadataLock)) { await m_metadataStore.PutAsync(MakeViewKey(view.Name), view.Data); } }
internal async Task <RecordItem> GetItemByIDAsyncImpl(string itemID) { using (await CrossThreadLockScope.Enter(m_lock)) { return(await this.GetItemFromStore(itemID)); } }
async Task RemoveKeyAsync(ItemKey key) { using (await CrossThreadLockScope.Enter(m_lock)) { m_items.Keys.RemoveByItemKey(key); await this.SaveView(); } }
async Task DeleteStorageForRecordAsync(string recordID) { using (await CrossThreadLockScope.Enter(m_storageLock)) { System.Diagnostics.Debug.WriteLine("Deleting storage for {0}", recordID); await m_root.DeleteChildStoreAsync(recordID); } }
public IAsyncAction SaveAsync() { return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { await this.SaveView(); } })); }
internal async Task PutItemsAsyncImpl(IEnumerable <RecordItem> items) { using (await CrossThreadLockScope.Enter(m_lock)) { foreach (RecordItem item in items) { await this.PutItemInStore(item); } } }
// Returns all changes registered with the change table public IAsyncOperation <IList <RecordItemChange> > GetChangesAsync() { return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { return (IList <RecordItemChange>)await this.GetAllChangesAsync(); } })); }
async Task UpdateKeyAsync(string itemID, RecordItem updatedItem) { ViewKey viewKey = ViewKey.FromItem(updatedItem); using (await CrossThreadLockScope.Enter(m_lock)) { m_items.Keys.UpdateKey(itemID, viewKey); await this.SaveView(); } }
async Task AddKeyAsync(RecordItem addedItem) { ViewKey viewKey = ViewKey.FromItem(addedItem); using (await CrossThreadLockScope.Enter(m_lock)) { m_items.Keys.Add(viewKey); await this.SaveView(); } }
public IAsyncOperation <IList <IItemDataTyped> > EnsureItemsAvailableAndGetAsync(int startAt, int count) { return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { return await m_items.GetItemsAsync(startAt, count, true, cancelToken); } })); }
public IAsyncOperation <IList <string> > GetItemIDsAsync() { return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { return await m_objectStore.GetAllKeysAsync(); } })); }
public IAsyncOperation <IItemDataTyped> EnsureItemAvailableAndGetAsync(int index) { return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { return await m_items.GetItemAsync(index, true, cancelToken); } })); }
public IAsyncOperation <IList <ItemKey> > GetKeysForItemsNeedingDownload(int startAt, int count) { return(AsyncInfo.Run <IList <ItemKey> >(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { return await m_items.GetKeysForItemsNeedingDownload(startAt, count); } })); }
public IAsyncOperation <IItemDataTyped> GetLocalItemByKeyAsync(ItemKey key) { return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { return await m_items.GetLocalItemByKeyAsync(key); } })); }
public IAsyncAction DeleteStoredQueryAsync(string name) { return(AsyncInfo.Run( async cancelToken => { using (await CrossThreadLockScope.Enter(m_metadataLock)) { await m_metadataStore.DeleteAsync(MakeStoredQueryKey(name)); } })); }
// Return the # of pending changes public IAsyncOperation <int> GetChangeCountAsync() { return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { await this.EnsureIndexAsync(); return (m_itemIDIndex.Count); } })); }
public IAsyncAction RemoveItemAsync(ItemKey key) { key.ValidateRequired("key"); return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { await m_objectStore.DeleteAsync(key.ID); } })); }
// Return Ids of items that changed public IAsyncOperation <IList <string> > GetIDsOfChangedItemsAsync() { return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { await this.EnsureIndexAsync(); List <string> itemIDs = m_itemIDIndex.ToList(); return (IList <string>)itemIDs; } })); }
// PredicateDelegate is passed IItemDataTyped objects public IAsyncOperation <IList <IItemDataTyped> > SelectAsync(PredicateDelegate predicate) { if (predicate == null) { throw new ArgumentNullException("predicate"); } return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { return await m_items.SelectAsync(predicate, cancelToken); } })); }
// Gets the current change information for the given itemID public IAsyncOperation <RecordItemChange> GetChangeForItemAsync(string itemID) { if (string.IsNullOrEmpty(itemID)) { throw new ArgumentException("itemID"); } return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { return await this.GetChangeAsync(itemID); } })); }
public IAsyncOperation <IItemDataTyped> EnsureItemAvailableAndGetByKeyAsync(ItemKey key) { if (key == null) { throw new ArgumentNullException("key"); } return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { return await m_items.GetItemByKeyAsync(key, true, cancelToken); } })); }
// Remove changes for the given item ID public IAsyncAction RemoveChangeAsync(string itemID) { if (string.IsNullOrEmpty(itemID)) { throw new ArgumentException("itemID"); } return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { await this.DeleteChangeAsync(itemID); } })); }
public IAsyncOperation <DateTimeOffset> UpdateDateForAsync(ItemKey key) { if (key == null) { throw new ArgumentNullException("key"); } return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { return await m_objectStore.GetUpdateDateAsync(key.ID); } })); }
// Remove all changes public IAsyncAction RemoveAllChangesAsync() { return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { await this.EnsureIndexAsync(); string[] allIDs = m_itemIDIndex.ToArray(); foreach (string itemID in allIDs) { await this.DeleteChangeAsync(itemID); } } })); }
/// <summary> /// Synchronize --> update the list of known Items by fetching a fresh list of ItemKeys from HealthVault /// /// If there are pending changes (writes, removes) that have not been committed to HealthVault yet, synchronize will do nothing /// and return false. /// /// </summary> /// <returns>FALSE if there are pending changes that have not yet been committed to HealthVault</returns> public IAsyncOperation <bool> SynchronizeAsync() { return(AsyncInfo.Run <bool>(async cancelToken => { if (await this.Data.Changes.HasChangesForTypeAsync(m_typeID)) { return false; } using (await CrossThreadLockScope.Enter(m_lock)) { await m_items.SynchronizeAsyncImpl(cancelToken); await this.SaveView(); return true; } })); }
// Are there any changes pending for the given item ID public IAsyncOperation <bool> HasChangesForItemAsync(string itemID) { if (string.IsNullOrEmpty(itemID)) { throw new ArgumentException("itemID"); } return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { await this.EnsureIndexAsync(); return m_itemIDIndex.Contains(itemID); } })); }