コード例 #1
0
        protected override void ProcessRecord()
        {
            HealthClientApplication clientApp = HealthClientApplication.Create(
                Guid.NewGuid(), HVPowerShellGuid, HVShell, HVPlatform);

            // Verify the application instance.
            //   Create a new instance if necessary.

            if (clientApp.GetApplicationInfo() == null)
            {
                // Create a new client instance.
                clientApp.StartApplicationCreationProcess();

                // A new client instance always requests authorization from the
                //   current user using the default browser.

                // Wait for the user to return from the shell.
                if (ShouldContinue("Is Auth done - (Y)?", "Is auth done?",
                                   ref _yesToAll, ref _noToAll))
                {
                    // Store the SODA client details
                    StringBuilder data = new StringBuilder();
                    data.Append(clientApp.ApplicationId.ToString());
                    using (StreamWriter sw = new StreamWriter(HvShellUtilities.GetClientAppAuthFileNameFullPath()))
                    {
                        sw.Write((data));
                    }
                    List <PersonInfo> authorizedPeople =
                        new List <PersonInfo>(clientApp.ApplicationConnection.GetAuthorizedPeople());
                    WriteObject(authorizedPeople);
                }
            }
        }
コード例 #2
0
ファイル: HVClient.cs プロジェクト: gcarboni1/swsi-health
        /// <summary>
        /// Provisions the application.
        /// If application does not exist, it launches the application
        /// creation process.
        /// </summary>
        public void ProvisionApplication()
        {
            // generate a GUID that will be used for the application creation.
            _applicationId = Guid.NewGuid();

            HealthClientApplication client = HealthClientApplication.Create(_applicationId, _masterApplicationId);

            client.StartApplicationCreationProcess();



            // launch dialog box to wait
            MessageBox.Show("After completing application setup in browser, click OK");

            // check if the app is provisioned now
            HealthServiceInstance instance = FindProvisionedServiceInstance();

            if (instance == null)
            {
                MessageBox.Show("The application setup in your browser did not complete.");
                return;
            }

            _serviceInstance         = instance;
            _healthClientApplication = client;

            // the app was provisioned
            _healthClientApplication = HealthClientApplication.Create(
                _applicationId,
                _masterApplicationId,
                _serviceInstance);

            // Get list of authorized people
            ApplicationConnection connection       = HealthClientApplication.ApplicationConnection;
            List <PersonInfo>     authorizedPeople = new List <PersonInfo>(connection.GetAuthorizedPeople());

            if (authorizedPeople.Count == 0)
            {
                MessageBox.Show("No records were authorized.  Application setup process did not complete.");
                return;
            }

            // save person ID, record ID, and service instance ID
            // assumption is the first person is the current person ID and there is only
            // one recordid for the person. For more persons and records, a selection
            // UI would need to be shown
            PersonInfo personInfo = authorizedPeople[0];

            _personId      = personInfo.PersonId;
            _recordId      = personInfo.SelectedRecord.Id;
            _isProvisioned = true;

            SaveUserSettings();

            MessageBox.Show("Application + " + _applicationId + " is now provisioned");
        }