/// <summary> /// Process the list of authorized people and continue the flow. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event arguments.</param> private static void GetAuthorizedPeopleCompleted(object sender, HealthVaultResponseEventArgs e) { AuthenticationCheckState state = (AuthenticationCheckState)e.Request.UserState; if (e.ErrorText != null) { state.AuthenticationCompletedHandler(state.Service, e); return; } XElement response = XElement.Parse(e.ResponseXml); XElement responseResults = response.Descendants("response-results").Single(); state.Service.Records.Clear(); foreach (XElement personInfo in responseResults.Elements("person-info")) { Guid personId = new Guid(personInfo.Element("person-id").Value); string personName = personInfo.Element("name").Value; // If we loaded our settings, the current record is incomplete. We will try // to match it to one that we got back... HealthVaultRecord currentRecord = state.Service.CurrentRecord; state.Service.CurrentRecord = null; foreach (XElement recordNode in personInfo.Elements("record")) { HealthVaultRecord record = HealthVaultRecord.Create(personId, personName, HealthVaultService.GetOuterXml(recordNode)); if (record != null) { state.Service.Records.Add(record); if ((currentRecord != null) && (currentRecord.PersonId == record.PersonId) && (currentRecord.RecordId == record.RecordId)) { state.Service.CurrentRecord = record; } } } } if (state.Service.Records.Count != 0) { // all done state.AuthenticationCompletedHandler(state.Service, null); } else { // unsuccessful, restart from scratch... state.Service.ClearProvisioningInformation(); BeginAuthenticationCheck(state); } }
/// <summary> /// Save the new application info and continue the process. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event arguments.</param> private static void NewApplicationCreationInfoCompleted(object sender, HealthVaultResponseEventArgs e) { AuthenticationCheckState state = (AuthenticationCheckState)e.Request.UserState; if (e.ErrorText != null) { state.AuthenticationCompletedHandler(state.Service, e); return; } XElement response = XElement.Parse(e.ResponseXml); XNamespace responseNamespace = "urn:com.microsoft.wc.methods.response.NewApplicationCreationInfo"; XElement info = response.Element(responseNamespace + "info"); state.Service.AppIdInstance = new Guid(info.Element("app-id").Value); state.Service.SharedSecret = info.Element("shared-secret").Value; state.Service.ApplicationCreationToken = info.Element("app-token").Value; state.ShellAuthRequiredHandler(state.Service, e); }