예제 #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);
 }