/// <summary> Checks if this path is below <paramref name="path"/> or is equal to <paramref name="path"/>. /// Also checks the path elements type! /// </summary> public bool IsBelow(PathInformation path) { if (path == null || path.Count > Count) { return(false); } return(!path.Where((t, i) => !this[i].Equals(t)).Any()); }
/// <summary> /// Deletes the measurements including the measurement values for part <paramref name="partPath"/>. The <paramref name="filter"/> can be used /// to restrict the measurements. If the filter is empty, all measurements for the specified part will be deleted. If the partPath is empty, /// all measurements from the whole database will be deleted. /// </summary> /// <param name="partPath">The part path to delete the measurements from.</param> /// <param name="filter">A filter to restruct the delete operation.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public Task DeleteMeasurements(PathInformation partPath = null, GenericSearchCondition filter = null, CancellationToken cancellationToken = default(CancellationToken)) { if (filter != null) { return(Delete(string.Format("measurements?partPath={0}&searchCondition={1}", PathHelper.PathInformation2String(partPath), SearchConditionParser.GenericConditionToString(filter)), cancellationToken)); } return(Delete(string.Format("measurements?partPath={0}", PathHelper.PathInformation2String(partPath)), cancellationToken)); }
/// <summary> /// Fetches a list of parts below <paramref name="partPath"/>. The result list always contains the specified parent part too. If the parent part /// is <code>null</code>, a server wide search is performed. If the <see paramref="depth"/> is <code>0</code>, only the specified part will be returned. /// </summary> /// <param name="partPath">The parent part to fetch the children for.</param> /// <param name="withHistory">Determines whether to return the version history for each part.</param> /// <param name="depth">The depth for the inspection plan search.</param> /// <param name="partUuids">The list of part uuids to restrict the search to.</param> /// <param name="requestedPartAttributes">The attribute selector to determine which attributes to return.</param> /// <param name="streamed"> /// This controls whether to choose a streamed transfer mode or not. Using streamed mode has the side effect, that the result is transfered /// using http/s when the caller enumerates the result. The caller should be aware of because then enumerating might take longer than expected. /// Non streamed transfer mode first reads the whole result inside the task and then returns an enumerator over the buffered result. This is /// the preferred way when calling the task from UI code or when enumerating the whole result. The streamed mode would be preferred when the /// result is processed in blocks on non UI code or when not the complete result set is used. /// </param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public async Task <IEnumerable <InspectionPlanPart> > GetParts(PathInformation partPath = null, Guid[] partUuids = null, ushort?depth = null, AttributeSelector requestedPartAttributes = null, bool withHistory = false, bool streamed = false, CancellationToken cancellationToken = default(CancellationToken)) { var parameter = RestClientHelper.ParseToParameter(partPath, partUuids, depth, requestedPartAttributes, withHistory: withHistory); if (streamed) { return(await GetEnumerated <InspectionPlanPart>("parts", cancellationToken, parameter.ToArray()).ConfigureAwait(false)); } return(await Get <InspectionPlanPart[]>("parts", cancellationToken, parameter.ToArray()).ConfigureAwait(false)); }
/// <summary> /// Combines the path <paramref name="path"/> and the path element <paramref name="elem"/> to a new <see cref="PathInformation"/> instance. /// </summary> public static PathInformation Combine(PathInformation path, PathElement elem) { if (elem == null || elem.IsEmpty) { return(path); } if (path == null) { return(new PathInformation(elem)); } var newpath = new List <PathElement>(path.Count + 1); newpath.AddRange(path); newpath.Add(elem); return(new PathInformation(newpath)); }
/// <summary> /// Combines the path <paramref name="p1"/> and the path <paramref name="p2"/> to a new <see cref="PathInformation"/> instance. /// </summary> public static PathInformation Combine(PathInformation p1, PathInformation p2) { if (p1 == null || p1.IsRoot) { return(p2); } if (p2 == null || p2.IsRoot) { return(p1); } var newpath = new List <PathElement>(p1.Count + p2.Count); newpath.AddRange(p1); newpath.AddRange(p2); return(new PathInformation(newpath)); }
/// <summary> /// Fetches a list of measurements and measurement values for the <paramref name="partPath"/>. The search operation /// can be parameterized using the specified <paramref name="filter"/>. If the filter is empty, all measurements for /// the specified part will be fetched. /// </summary> /// <param name="partPath">The part path to fetch the measurements and values for.</param> /// <param name="filter">A filter that can be used to further restrict the search operation.</param> /// <param name="streamed"> /// This controls whether to choose a streamed transfer mode or not. Using streamed mode has the side effect, that the result is transfered /// using http/s when the caller enumerates the result. The caller should be aware of because then enumerating might take longer than expected. /// Non streamed transfer mode first reads the whole result inside the task and then returns an enumerator over the buffered result. This is /// the preferred way when calling the task from UI code or when enumerating the whole result. The streamed mode would be preferred when the /// result is processed in blocks on non UI code or when not the complete result set is used. /// </param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public async Task <IEnumerable <DataMeasurement> > GetMeasurementValues(PathInformation partPath = null, MeasurementValueFilterAttributes filter = null, bool streamed = false, CancellationToken cancellationToken = default(CancellationToken)) { var parameter = new List <ParameterDefinition>(); if (filter != null) { parameter.AddRange(filter.ToParameterDefinition()); } if (partPath != null) { parameter.Add(ParameterDefinition.Create("partPath", PathHelper.PathInformation2String(partPath))); } if (streamed) { return(await GetEnumerated <DataMeasurement>("values", cancellationToken, parameter.ToArray()).ConfigureAwait(false)); } return(await Get <DataMeasurement[]>("values", cancellationToken, parameter.ToArray()).ConfigureAwait(false)); }
/// <summary>Constructor. Initialies the path as a view on the given <paramref name="path"/> with an offset and a length.</summary> public PathInformation(PathInformation path, int offset, int length = -1) { var currentPathElements = path._PathElements; if (offset < 0 || offset > currentPathElements.Count) { throw new ArgumentException("Parameter offset must be greater or equal 0 and less than or equal to the path element count of path."); } if (length > currentPathElements.Count - offset) { throw new ArgumentException("Parameter length cannot be greater than the path element count of path minus offset."); } if (length < 0) { length = currentPathElements.Count - offset; } _PathElements = new ArraySegment <PathElement>(currentPathElements.Array, currentPathElements.Offset + offset, length); }
/// <summary> /// Deletes the characteristic <paramref name="charPath"/> and its sub characteristics from the database. /// </summary> /// <param name="charPath">The characteristic path for the delete operation.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public Task DeleteCharacteristics(PathInformation charPath, CancellationToken cancellationToken = default(CancellationToken)) { return(Delete(string.Format("characteristics?charPath={0}", PathHelper.PathInformation2String(charPath)), cancellationToken)); }
/// <summary> /// Deletes all parts and child parts below <paramref name="partPath"/> from the database. Since parts act as the parent /// of characteristics and measurements, this call will delete all characteristics and measurements including the measurement /// values that are a child of the specified parent part. /// </summary> /// <param name="partPath">The parent part for the delete operation.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public Task DeleteParts(PathInformation partPath, CancellationToken cancellationToken = default(CancellationToken)) { return(Delete(string.Format("parts?partPath={0}", PathHelper.PathInformation2String(partPath)), cancellationToken)); }
/// <summary> Checks if the <paramref name="path"/> is <code>null</code> or the root part. </summary> /// <returns>True, if the <paramref name="path"/> is <code>null</code> or the root part otherwise false.</returns> public static bool IsNullOrRoot(PathInformation path) { return(path == null || path.IsRoot); }