Exemplo n.º 1
0
        private async Task <AppStartupStatus> EnsureAppCreatedAsync(CancellationToken cancelToken)
        {
            if (m_client.UseOnlineAuthModel &&
                !await m_client.EnsureUserIdentityAsync(cancelToken,
                                                        HealthVaultClient.HBIAuthPolicy))
            {
                return(AppStartupStatus.Failed);
            }

            // See if we have a cached ServiceInfo.
            ServiceInfo cachedInfo = await HealthVault.Foundation.ServiceInfo.Load();

            if (cachedInfo != null)
            {
                UpdateServiceInfo(cachedInfo);
            }

            WebAuthenticationStatus authStatus = await m_client.EnsureAppProvisionedAsync(cancelToken);

            if (cachedInfo == null || m_client.ServiceInfo.ServiceUrl != ServiceInfo.ServiceUrl)
            {
                UpdateServiceInfo(m_client.ServiceInfo);
                await m_client.ServiceInfo.Save();
            }

            return(WebAuthenticationStatusToStartupStatus(authStatus));
        }