/// <summary> /// Parses HealthRecordInfo member data from the specified XPathNavigator. /// </summary> /// /// <param name="navigator"> /// The XML containing the record information. /// </param> /// internal override void ParseXml(XPathNavigator navigator) { base.ParseXml(navigator); _custodian = XPathHelper.ParseAttributeAsBoolean(navigator, "record-custodian", false); long? relationshipNumber = null; relationshipNumber = XPathHelper.ParseAttributeAsLong(navigator, "rel-type", 0); if (relationshipNumber.HasValue && (relationshipNumber <= (int)RelationshipType.Daughter)) { _relationshipType = (RelationshipType)relationshipNumber; } _relationshipName = navigator.GetAttribute("rel-name", String.Empty); _dateAuthorizationExpires = XPathHelper.ParseAttributeAsDateTime(navigator, "auth-expires", DateTime.MinValue); _authExpired = XPathHelper.ParseAttributeAsBoolean(navigator, "auth-expired", false); _name = navigator.Value; _displayName = navigator.GetAttribute("display-name", String.Empty); _state = XPathHelper.ParseAttributeAsEnum<HealthRecordState>(navigator, "state", HealthRecordState.Unknown); if (_state > HealthRecordState.Deleted) { _state = HealthRecordState.Unknown; } _dateCreated = XPathHelper.ParseAttributeAsDateTime(navigator, "date-created", DateTime.MinValue); _quotaInBytes = XPathHelper.ParseAttributeAsLong(navigator, "max-size-bytes", null); _quotaUsedInBytes = XPathHelper.ParseAttributeAsLong(navigator, "size-bytes", null); _authorizationStatus = XPathHelper.ParseAttributeAsEnum<HealthRecordAuthorizationStatus>( navigator, "app-record-auth-action", HealthRecordAuthorizationStatus.Unknown); _applicationSpecificRecordId = navigator.GetAttribute("app-specific-record-id", String.Empty); _updated = true; }
/// <summary> /// Updates the <see cref="HealthRecordInfo"/> instance with data from /// the server using the <see cref="HealthRecordAccessor.Id"/>. /// </summary> /// /// <remarks> /// This method accesses the HealthVault service across the network. /// </remarks> /// /// <exception cref="InvalidOperationException"> /// This method is called and the /// <see cref="HealthRecordAccessor.Connection"/> /// object of the <see cref="HealthRecordInfo"/> is not an /// <see cref="AuthenticatedConnection"/>. /// </exception> /// public void Refresh() { AuthenticatedConnection connection = Connection as AuthenticatedConnection; if (connection == null) { OfflineWebApplicationConnection offlineAuthConnection = Connection as OfflineWebApplicationConnection; Validator.ThrowInvalidIfNull(offlineAuthConnection, "ConnectionIsNeitherAuthenticatedNorOffline"); } Collection<HealthRecordInfo> records = HealthVaultPlatform.GetAuthorizedRecords(Connection, new Guid[] { this.Id }); if (records.Count == 0) { HealthServiceResponseError error = new HealthServiceResponseError(); error.Message = ResourceRetriever.FormatResourceString( "RecordNotFoundException", this.Id); HealthServiceException e = HealthServiceExceptionHelper.GetHealthServiceException( HealthServiceStatusCode.RecordNotFound, error); throw e; } HealthRecordInfo thisRecord = records[0]; this._custodian = thisRecord.IsCustodian; this._name = thisRecord.Name; this._relationshipName = thisRecord.RelationshipName; this._relationshipType = thisRecord.RelationshipType; this._dateAuthorizationExpires = thisRecord.DateAuthorizationExpires; this._quotaInBytes = thisRecord.QuotaInBytes; this._quotaUsedInBytes = thisRecord.QuotaUsedInBytes; this._state = thisRecord.State; this._dateCreated = thisRecord.DateCreated; this._displayName = thisRecord.DisplayName; this._authExpired = thisRecord.HasAuthorizationExpired; this._updated = true; }