Exemple #1
0
        private async Task <ThingCollection> GetPartialThingsAsync(
            IList <ThingKey> partialThings)
        {
            IThingClient thingClient = Connection.CreateThingClient();

            ThingQuery query = new ThingQuery();

            foreach (ThingKey key in partialThings)
            {
                query.ItemKeys.Add(key);
            }

            // Need to copy the view from the original filter
            query.View               = Query.View;
            query.States             = Query.States;
            query.CurrentVersionOnly = Query.CurrentVersionOnly;
            if (Query.OrderByClauses.Count > 0)
            {
                foreach (var orderByClause in Query.OrderByClauses)
                {
                    query.OrderByClauses.Add(orderByClause);
                }
            }

            ThingCollection results = await thingClient.GetThingsAsync(Record.Id, query).ConfigureAwait(false);

            return(results);
        }
 private static void ValidateItem(ThingQuery item)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
 }
Exemple #3
0
        private static void ParseOrderByClauses(XPathNavigator groupNav, ThingQuery filter)
        {
            XPathNavigator orderByNav = groupNav.SelectSingleNode("order-by");

            if (orderByNav != null)
            {
                XPathNodeIterator orderByIterator = orderByNav.Select("order-by-property");
                foreach (XPathNavigator orderByPropertyNav in orderByIterator)
                {
                    var orderByClause = new ThingOrderByClause
                    {
                        ThingTypeId = new Guid(orderByPropertyNav.GetAttribute("type-id", string.Empty)),
                        Name        = orderByPropertyNav.GetAttribute("property-name", string.Empty)
                    };

                    string direction = orderByPropertyNav.GetAttribute("direction", string.Empty);
                    if (!string.IsNullOrEmpty(direction))
                    {
                        orderByClause.Direction = (OrderByDirection)Enum.Parse(typeof(OrderByDirection), direction);
                    }
                    else
                    {
                        orderByClause.Direction = OrderByDirection.Asc;
                    }

                    filter.OrderByClauses.Add(orderByClause);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Creates a new HealthRecordSearcher for a list of specific types.
        /// </summary>
        ///
        /// <returns>
        /// A <see cref="HealthRecordSearcher"/> that searches for items with specific type IDs
        /// within this record.
        /// </returns>
        ///
        /// <remarks>
        /// The method adds a filter to the <see cref="HealthRecordSearcher"/> that only returns
        /// items of the specified type IDs. That filter may be accessed through the
        /// returned searcher using searcher.Filters[0].
        ///
        /// You can also call the <see cref="HealthRecordSearcher"/> constructor
        /// directly and pass in a reference to this
        /// <see cref="HealthRecordAccessor"/>.
        /// </remarks>
        ///
        /// <param name="typeIds">
        /// A list of unique type ids to filter on.
        /// </param>
        ///
        public HealthRecordSearcher CreateSearcher(params Guid[] typeIds)
        {
            HealthRecordSearcher searcher = new HealthRecordSearcher(this);
            ThingQuery           query    = new ThingQuery(typeIds);

            searcher.Filters.Add(query);

            return(searcher);
        }
Exemple #5
0
        internal static ThingQuery CreateFromXml(XPathNavigator nav, HealthVaultConfiguration configuration)
        {
            ThingQuery filter = new ThingQuery();

            XPathNavigator groupNav = nav.SelectSingleNode("group");
            string         name     = groupNav.GetAttribute("name", string.Empty);

            if (!string.IsNullOrEmpty(name))
            {
                filter.Name = name;
            }

            string maxString = groupNav.GetAttribute("max", string.Empty);

            filter.MaxItemsReturned = TryGetXmlInt32Value(maxString);

            string maxFullString = groupNav.GetAttribute("max-full", string.Empty);

            filter.MaxFullItemsReturnedPerRequest = TryGetXmlInt32Value(maxFullString);

            XPathNodeIterator thingIdIterator = groupNav.Select("id");

            foreach (XPathNavigator thingIdNav in thingIdIterator)
            {
                string versionStamp
                    = thingIdNav.GetAttribute("version-stamp", string.Empty);
                filter.ItemKeys.Add(
                    new ThingKey(
                        new Guid(thingIdNav.Value),
                        new Guid(versionStamp)));
            }

            XPathNodeIterator clientIdIterator = groupNav.Select("client-thing-id");

            foreach (XPathNavigator clientIdNav in clientIdIterator)
            {
                filter.ClientItemIds.Add(clientIdNav.Value);
            }

            ParseOrderByClauses(groupNav, filter);

            XPathNavigator filterNav = groupNav.SelectSingleNode("filter");

            ParseFilterNavValue(filterNav, filter);

            XPathNavigator currentVersionNav = groupNav.SelectSingleNode("current-version-only");

            if (currentVersionNav != null)
            {
                filter.CurrentVersionOnly = currentVersionNav.ValueAsBoolean;
            }

            XPathNavigator viewNav = groupNav.SelectSingleNode("format");

            filter.View = HealthRecordView.CreateFromXml(viewNav, configuration);
            return(filter);
        }
Exemple #6
0
 internal ThingCollection(
     string name,
     HealthRecordAccessor record,
     ThingQuery query,
     IHealthVaultConnection healthVaultConnection)
 {
     Name       = name;
     Record     = record;
     Query      = query;
     Connection = healthVaultConnection;
 }
Exemple #7
0
        private static void ParseFilterNavValue(XPathNavigator filterNav, ThingQuery filter)
        {
            if (filterNav != null)
            {
                XPathNodeIterator typeIdIterator = filterNav.Select("type-id");
                foreach (XPathNavigator typeIdNav in typeIdIterator)
                {
                    filter.TypeIds.Add(new Guid(typeIdNav.Value));
                }

                XPathNavigator effDateMinNav =
                    filterNav.SelectSingleNode("eff-date-min");
                if (effDateMinNav != null)
                {
                    filter.EffectiveDateMin = SDKHelper.LocalDateTimeFromXml(effDateMinNav.Value);
                }

                XPathNavigator effDateMaxNav =
                    filterNav.SelectSingleNode("eff-date-max");
                if (effDateMaxNav != null)
                {
                    filter.EffectiveDateMax = SDKHelper.LocalDateTimeFromXml(effDateMaxNav.Value);
                }

                XPathNavigator createdAppIdNav =
                    filterNav.SelectSingleNode("created-app-id");
                if (createdAppIdNav != null)
                {
                    filter.CreatedApplication = new Guid(createdAppIdNav.Value);
                }

                XPathNavigator createdPersonIdNav =
                    filterNav.SelectSingleNode("created-person-id");
                if (createdPersonIdNav != null)
                {
                    filter.CreatedPerson = new Guid(createdPersonIdNav.Value);
                }

                XPathNavigator updatedAppIdNav =
                    filterNav.SelectSingleNode("updated-app-id");
                if (updatedAppIdNav != null)
                {
                    filter.UpdatedApplication = new Guid(updatedAppIdNav.Value);
                }

                XPathNavigator updatedPersonIdNav =
                    filterNav.SelectSingleNode("updated-person-id");
                if (updatedPersonIdNav != null)
                {
                    filter.UpdatedPerson = new Guid(updatedPersonIdNav.Value);
                }

                XPathNavigator createdDateMinNav =
                    filterNav.SelectSingleNode("created-date-min");
                if (createdDateMinNav != null)
                {
                    filter.CreatedDateMin = InstantPattern.ExtendedIso.Parse(createdDateMinNav.Value).Value;
                }

                XPathNavigator createdDateMaxNav =
                    filterNav.SelectSingleNode("created-date-min");
                if (createdDateMaxNav != null)
                {
                    filter.CreatedDateMax = InstantPattern.ExtendedIso.Parse(createdDateMaxNav.Value).Value;
                }

                XPathNavigator updatedDateMinNav =
                    filterNav.SelectSingleNode("updated-date-min");
                if (updatedDateMinNav != null)
                {
                    filter.UpdatedDateMin = InstantPattern.ExtendedIso.Parse(updatedDateMinNav.Value).Value;
                }

                XPathNavigator updatedDateMaxNav =
                    filterNav.SelectSingleNode("updated-date-min");
                if (updatedDateMaxNav != null)
                {
                    filter.UpdatedDateMax = InstantPattern.ExtendedIso.Parse(updatedDateMaxNav.Value).Value;
                }

                XPathNavigator updatedEndDateMinNav =
                    filterNav.SelectSingleNode("updated-end-date-min");
                if (updatedEndDateMinNav != null)
                {
                    filter.UpdatedEndDateMin = SDKHelper.LocalDateTimeFromXml(updatedEndDateMinNav.Value);
                }

                XPathNavigator updatedEndDateMaxNav =
                    filterNav.SelectSingleNode("updated-end-date-max");
                if (updatedEndDateMaxNav != null)
                {
                    filter.UpdatedEndDateMax = SDKHelper.LocalDateTimeFromXml(updatedEndDateMaxNav.Value);
                }

                XPathNavigator xpathNav =
                    filterNav.SelectSingleNode("xpath");
                if (xpathNav != null)
                {
                    filter.XPath = xpathNav.Value;
                }
            }
        }
 public bool Remove(ThingQuery item)
 {
     return(_items.Remove(item));
 }
 public void Insert(int index, ThingQuery item)
 {
     ValidateItem(item);
     _items.Insert(index, item);
 }
 public int IndexOf(ThingQuery item)
 {
     return(_items.IndexOf(item));
 }
 public bool Contains(ThingQuery item)
 {
     return(_items.Contains(item));
 }
 public void Add(ThingQuery item)
 {
     ValidateItem(item);
     _items.Add(item);
 }