void OnNetworkStatusChanged(object sender)
        {
            try
            {
                bool hasNetwork = HealthVaultApp.HasInternetAccess();
                if (m_networkAvailable != null && m_networkAvailable.Value == hasNetwork)
                {
                    return;
                }

                Debug.WriteLine("Network status changed.");

                m_networkAvailable = hasNetwork;
                if (hasNetwork)
                {
                    this.CommitChanges();
                }
                else
                {
                    this.StopTimer();
                }
            }
            catch
            {
            }
        }
 internal LocalVault(HealthVaultApp app, IObjectStore vocabStore, IObjectStore recordStore)
 {
     m_app          = app;
     m_vocabRoot    = vocabStore;
     m_recordRoot   = recordStore;
     m_vocabStore   = new LocalVocabularyStore(m_app, m_vocabRoot);
     m_recordStores = new LocalRecordStoreTable(m_recordRoot);
 }
        public bool IsHaltingError(Exception ex)
        {
            if (this.IsServerError(ex) ||
                this.IsAccessDeniedError(ex) ||
                this.IsClientError(ex)
                )
            {
                return(true);
            }

            if (this.IsHttpError(ex) && !HealthVaultApp.HasInternetAccess())
            {
                return(true);
            }

            return(false);
        }
        void CommitChanges()
        {
            Task.Run(async() =>
            {
                try
                {
                    this.StopTimer();

                    // Change commit code is reentrant. If commits are already in progress, this call will
                    // be ignored
                    if (this.IsEnabled && HealthVaultApp.HasInternetAccess())
                    {
                        await m_recordStores.CommitChangesAsync();
                    }
                }
                catch
                {
                }
                finally
                {
                    this.StartTimer();
                }
            });
        }
        public static IAsyncOperation <IList <ItemTypeDefinition> > GetItemTypeDefinitions(HealthVaultApp app, ThingTypeGetParams getParams)
        {
            return(AsyncInfo.Run <IList <ItemTypeDefinition> >(
                       async cancelToken =>
            {
                string xml = getParams.ToXml();

                // Strip off the <ThingTypeGetParams> root node
                // because all of its properties should be nested under <info> (RequestBody)
                var doc = new XmlDocument();
                doc.LoadXml(xml);
                var innerXml = new StringBuilder();
                if (doc.ChildNodes != null && doc.ChildNodes.Length == 1)
                {
                    var innerNodes = doc.ChildNodes[0].ChildNodes;
                    foreach (IXmlNode node in innerNodes)
                    {
                        innerXml.Append(node.GetXml());
                    }
                }

                ThingTypeGetResults result =
                    await app.Client.ServiceMethods.GetThingType <ThingTypeGetResults>(innerXml.ToString(), cancelToken);
                return result.ItemTypeDefinitions;
            }));
        }
 internal LocalVault(HealthVaultApp app, StorageFolder vocabFolder, StorageFolder recordFolder)
     : this(app, FolderObjectStore.CreateRoot(vocabFolder), FolderObjectStore.CreateRoot(recordFolder))
 {
 }
 internal LocalVault(HealthVaultApp app)
     : this(app, FolderObjectStore.CreateRoot(), FolderObjectStore.CreateRoot())
 {
 }
コード例 #8
0
 internal LocalVocabularyStore(HealthVaultApp app, IObjectStore parentStore)
 {
     m_app  = app;
     m_root = new LocalStore(parentStore, "Vocab");
 }