Пример #1
0
        public HealthVaultApp(HealthVaultAppSettings appSettings)
        {
            m_lock = new object();

            m_appSettings = appSettings;
            m_serviceInfo = new ServiceInfoProxy()
            {
                ShellUrl   = appSettings.ShellUrl,
                ServiceUrl = appSettings.ServiceUrl
            };
            m_startupStatus = AppStartupStatus.Cancelled;
            m_appInfo       = new AppInfoProxy(appSettings.MasterAppId, appSettings.IsMultiInstanceAware);

            m_client = new HealthVaultClient(
                m_appInfo,
                m_serviceInfo,
                appSettings.IsFirstParty,
                appSettings.WebAuthorizer != null ? (IWebAuthorizer)appSettings.WebAuthorizer : null);

            if (appSettings.IsFirstParty)
            {
                m_liveIdHostName        = appSettings.LiveIdHostName;
                m_client.LiveIdHostName = appSettings.LiveIdHostName;
            }

            m_localVault = new LocalVault(this, appSettings.Folder, appSettings.Folder);
            m_vocabs     = new Vocabs(this);

            UIThreadDispatcher.Current.Init();
        }
Пример #2
0
        private async Task <AppStartupStatus> ProvisionAppForOnlineAuthModel(CancellationToken cancelToken)
        {
            PersonInfo personInfo = null;

            try
            {
                personInfo = await BatchCallsForOnlinePersonInfoAsync(cancelToken);
            }
            catch (ServerException ex)
            {
                if (ex.IsStatusCode(ServerStatusCode.CredentialNotFound))
                {
                    m_startupStatus = AppStartupStatus.CredentialNotFound;
                }

                throw;
            }
            catch (TaskCanceledException)
            {
                m_startupStatus = AppStartupStatus.Cancelled;
                throw;
            }

            HandleEncryptionSetCache();

            UserInfo = personInfo != null ? new UserInfo(personInfo) : null;

            m_localVault.RecordStores.ResetRecordObjects(UserInfo);
            await SaveUserInfoAsync(cancelToken);

            return(AppStartupStatus.Success);
        }
Пример #3
0
        public HealthVaultApp(HealthVaultAppSettings appSettings)
        {
            m_lock = new object();

            m_appSettings = appSettings;
            m_serviceInfo = new ServiceInfoProxy()
            {
                ShellUrl = appSettings.ShellUrl,
                ServiceUrl = appSettings.ServiceUrl
            };
            m_startupStatus = AppStartupStatus.Cancelled;
            m_appInfo = new AppInfoProxy(appSettings.MasterAppId, appSettings.IsMultiInstanceAware);

            m_client = new CHBaseClient(
                m_appInfo,
                m_serviceInfo,
                appSettings.IsFirstParty,
                appSettings.WebAuthorizer != null ? (IWebAuthorizer)appSettings.WebAuthorizer : null);

            if (appSettings.IsFirstParty)
            {
                m_liveIdHostName = appSettings.LiveIdHostName;
                m_client.LiveIdHostName = appSettings.LiveIdHostName;
            }

            m_localVault = new LocalVault(this, appSettings.Folder, appSettings.Folder);
            m_vocabs = new Vocabs(this);
            
            UIThreadDispatcher.Current.Init();
        }
Пример #4
0
        private async Task EnsureProvisionedAsync(CancellationToken cancelToken)
        {
            m_startupStatus = AppStartupStatus.Pending;

            if (m_client.UseOnlineAuthModel)
            {
                m_startupStatus = await ProvisionAppForOnlineAuthModel(cancelToken);
            }
            else
            {
                m_startupStatus = await ProvisionAppForSODAAuthModel(cancelToken);
            }
        }
Пример #5
0
 public IAsyncOperation <IsValidHealthVaultAccountResponse> HasAccountAsync()
 {
     return(AsyncInfo.Run(
                async cancelToken => {
         try {
             return await m_client.IsValidHealthVaultAccount <IsValidHealthVaultAccountResponse>(
                 cancelToken);
         }
         catch (TaskCanceledException)
         {
             m_startupStatus = AppStartupStatus.Cancelled;
             throw;
         }
     }));
 }
Пример #6
0
 public IAsyncOperation <bool> CreateAccountAsync(CreateAccountPersonInfo createAccountPersonInfo)
 {
     return(AsyncInfo.Run(
                async cancelToken => {
         try
         {
             return await CreateAccountAsync(
                 createAccountPersonInfo,
                 cancelToken);
         }
         catch (TaskCanceledException)
         {
             m_startupStatus = AppStartupStatus.Cancelled;
             throw;
         }
     }));
 }
Пример #7
0
        public HealthVaultApp(HealthVaultAppSettings appSettings)
        {
            m_lock = new object();

            m_appSettings = appSettings;
            m_serviceInfo = new ServiceInfoProxy()
            {
                ShellUrl = appSettings.ShellUrl,
                ServiceUrl = appSettings.ServiceUrl
            };
            m_startupStatus = AppStartupStatus.Cancelled;
            m_appInfo = new AppInfoProxy(appSettings.MasterAppId);

            m_client = new HealthVaultClient(m_appInfo, m_serviceInfo, m_appSettings.UseWebAuthBroker);
            m_localVault = new LocalVault(this, appSettings.Folder, appSettings.Folder);
            m_vocabs = new Vocabs(this);
        }
Пример #8
0
        private async Task <AppStartupStatus> ProvisionAppForSODAAuthModel(CancellationToken cancelToken)
        {
            bool             isNewApp         = !IsAppCreated;
            AppStartupStatus appStartupStatus = AppStartupStatus.Pending;

            try
            {
                appStartupStatus = await EnsureAppCreatedAsync(cancelToken);
            }
            catch
            {
                appStartupStatus = AppStartupStatus.Failed;
                throw;
            }

            if (appStartupStatus != AppStartupStatus.Success)
            {
                await SetUserAndSaveAsync(null, cancelToken);

                return(appStartupStatus);
            }

            HandleEncryptionSetCache();

            if (!isNewApp)
            {
                await LoadUserInfoAsync(cancelToken);
            }

            if (!HasUserInfo)
            {
                //
                // Download updated Person Information
                //
                await UpdateUserInfoAsync(cancelToken);
            }

            return(AppStartupStatus.Success);
        }
Пример #9
0
 public IAsyncAction StartAsync()
 {
     m_startupStatus = AppStartupStatus.Pending;
     return(AsyncInfo.Run(EnsureProvisionedAsync));
 }
Пример #10
0
        private async Task EnsureProvisionedAsync(CancellationToken cancelToken)
        {
            m_startupStatus = AppStartupStatus.Pending;

            bool isNewApp = !IsAppCreated;
            try
            {
                m_startupStatus = await EnsureAppCreatedAsync(cancelToken);
            }
            catch
            {
                m_startupStatus = AppStartupStatus.Failed;
                throw;
            }

            if (m_startupStatus != AppStartupStatus.Success)
            {
                await SetUserAndSaveAsync(null, cancelToken);
                return;
            }

            // Set up the encrypted local vault
            if (m_appSettings.UseEncryption)
            {
                var encryptedStore = new EncryptedObjectStore(
                    FolderObjectStore.CreateRoot(m_appSettings.Folder),
                    Client.Cryptographer,
                    Client.State.ProvisioningInfo.SharedSecret);
                m_localVault = new LocalVault(this, FolderObjectStore.CreateRoot(m_appSettings.Folder), encryptedStore);
            }

            // Set the cache setting
            m_localVault.RecordStores.MaxCachedItems = m_appSettings.MaxCachedItems;

            if (!isNewApp)
            {
                await LoadUserInfoAsync(cancelToken);
            }

            if (!HasUserInfo)
            {
                //
                // Download updated Person Information
                //
                await UpdateUserInfoAsync(cancelToken);
            }
        }
Пример #11
0
 public IAsyncAction StartAsync()
 {
     m_startupStatus = AppStartupStatus.Pending;
     return AsyncInfo.Run(cancelToken => EnsureProvisionedAsync(cancelToken));
 }
Пример #12
0
        private async Task<AppStartupStatus> ProvisionAppForOnlineAuthModel(CancellationToken cancelToken)
        {
            PersonInfo personInfo = null;

            try
            {
                personInfo = await BatchCallsForOnlinePersonInfoAsync(cancelToken);
            }
            catch (ServerException ex)
            {
                if (ex.IsStatusCode(ServerStatusCode.CredentialNotFound))
                {
                    m_startupStatus = AppStartupStatus.CredentialNotFound;
                }

                throw;
            }
            catch (TaskCanceledException)
            {
                m_startupStatus = AppStartupStatus.Cancelled;
                throw;
            }

            HandleEncryptionSetCache();

            UserInfo = personInfo != null ? new UserInfo(personInfo) : null;
            
            m_localVault.RecordStores.ResetRecordObjects(UserInfo);
            await SaveUserInfoAsync(cancelToken);

            return AppStartupStatus.Success;
        }
Пример #13
0
        private async Task EnsureProvisionedAsync(CancellationToken cancelToken)
        {
            m_startupStatus = AppStartupStatus.Pending;

            if (m_client.UseOnlineAuthModel)
            {
               m_startupStatus = await ProvisionAppForOnlineAuthModel(cancelToken);
            }
            else
            {
                m_startupStatus = await ProvisionAppForSODAAuthModel(cancelToken);
            }
        }
Пример #14
0
 public IAsyncOperation<bool> CreateAccountAsync(CreateAccountPersonInfo createAccountPersonInfo)
 {
     return AsyncInfo.Run(
         async cancelToken => {
             try
             {
                 return await CreateAccountAsync(
                     createAccountPersonInfo,
                     cancelToken);
             }
             catch (TaskCanceledException)
             {
                 m_startupStatus = AppStartupStatus.Cancelled;
                 throw;
             }
         });
 }
Пример #15
0
 public IAsyncOperation<IsValidHealthVaultAccountResponse> HasAccountAsync()
 {
     return AsyncInfo.Run(
         async cancelToken => { 
             try {
                     return await m_client.IsValidHealthVaultAccount<IsValidHealthVaultAccountResponse>(
                             cancelToken);
                 }
                 catch (TaskCanceledException)
                 {
                     m_startupStatus = AppStartupStatus.Cancelled;
                     throw;
                 }
             });
 }
Пример #16
0
 public IAsyncAction StartAsync()
 {
     m_startupStatus = AppStartupStatus.Pending;
     return AsyncInfo.Run(EnsureProvisionedAsync);
 }