private async Task fetchMeasurements(PathInformation partPath, string serialNumber) { SimpleMeasurement[] _Measurements = new SimpleMeasurement[0]; try { var sw = System.Diagnostics.Stopwatch.StartNew(); _Measurements = (await _RestDataServiceClient.GetMeasurements(partPath, new MeasurementFilterAttributes { SearchCondition = new GenericSearchAttributeCondition { Attribute = (ushort)14, Operation = Operation.Equal, Value = serialNumber } })).ToArray();// sw.Stop(); foreach (var mes in _Measurements) { if (mes.GetAttribute((ushort)20041).Value == "1") { demoType = mes.GetAttribute((ushort)20043).Value; customer = mes.GetAttribute((ushort)1062).Value; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private InMemoryFileSystemTestContext() { // Since we want to test certain behaviors, e.g. that the DefaultInMemoryStoragePath validates // invalid characters, we require custom PathInformation. var testPathInformation = new PathInformation( invalidPathChars: new[] { '\0' }, invalidFileNameChars: new[] { '\0' }, '/', '\\', '.', '/', ".", "..", StringComparison.OrdinalIgnoreCase ); var options = new InMemoryFileSystemOptions() { PathProvider = new DefaultInMemoryStoragePathProvider(testPathInformation), }; FileSystem = new InMemoryFileSystem(options); Default.Setup(FileSystem); }
public string pathGeometry; // figure information // public string pathComment; // figure information public PathInformation Copy() { PathInformation n = new PathInformation(); n.CopyData(this); return(n); }
public bool IsSameAs(PathInformation tmp) { if (id != tmp.id) { return(false); } if (penColorId != tmp.penColorId) { return(false); } if (pathId != tmp.pathId) { return(false); } if (pathGeometry != tmp.pathGeometry) { return(false); } // if (pathComment != tmp.pathComment) return false; if (groupAttributes.SequenceEqual(tmp.groupAttributes)) { return(true); } return(false); }
private bool CanRequestBeHandled(string path, PathInformation pathInformation, Link link) { if (link == null) { _logger?.Information("Link for path {RequestPath} not found", path); return(false); } if (link.IsDisabled) { _logger?.Information("Link {LinkName} is disabled", link.SymbolicName); return(false); } if (String.IsNullOrWhiteSpace(pathInformation.PathWithoutUserName)) { _logger?.Information("Path {RequestPath} for link {LinkName} without user name is not found", path, link.SymbolicName); return(false); } if (link.AllowLocalClientRequestsOnly && !Request.IsLocal()) { _logger?.Information("Link {LinkName} only allows local requests", link.SymbolicName); return(false); } return(true); }
/// <summary> /// This method fetches the most recent 100 measurements for the selected part. Please have a look at the other properties inside /// the filter class to understand all possibilities of filtering. /// </summary> private async Task updateMeasurements2CheckDemoReport(PathInformation partPath, string serialNumber) { SimpleMeasurement[] _Measurements = new SimpleMeasurement[0]; try { var sw = System.Diagnostics.Stopwatch.StartNew(); _Measurements = (await _RestDataServiceClient.GetMeasurements(partPath, new MeasurementFilterAttributes { SearchCondition = new GenericSearchAttributeCondition { Attribute = (ushort)14, Operation = Operation.Equal, Value = serialNumber } })).ToArray();// sw.Stop(); foreach (var mes in _Measurements) { mes.SetAttribute((ushort)20057, "已完成"); } if (_Measurements.Count() > 0) { await _RestDataServiceClient.UpdateMeasurements(_Measurements); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void Constructor_StandardParameters_SetsProperties() { var info = new PathInformation( InvalidPathChars, InvalidFileNameChars, DirectorySeparator, AltDirectorySeparator, ExtensionSeparator, VolumeSeparator, CurrentDirectorySegment, ParentDirectorySegment, DefaultStringComparison ); info.InvalidPathChars.ShouldBe(InvalidPathChars); info.InvalidFileNameChars.ShouldBe(InvalidFileNameChars); info.DirectorySeparatorChar.ShouldBe(DirectorySeparator); info.AltDirectorySeparatorChar.ShouldBe(AltDirectorySeparator); info.ExtensionSeparatorChar.ShouldBe(ExtensionSeparator); info.VolumeSeparatorChar.ShouldBe(VolumeSeparator); info.CurrentDirectorySegment.ShouldBe(CurrentDirectorySegment); info.ParentDirectorySegment.ShouldBe(ParentDirectorySegment); info.DefaultStringComparison.ShouldBe(DefaultStringComparison); info.InvalidPathChars.ShouldBeOfType <ReadOnlyCollection <char> >(); info.InvalidFileNameChars.ShouldBeOfType <ReadOnlyCollection <char> >(); info.DirectorySeparatorChars.ShouldBeOfType <ReadOnlyCollection <char> >(); info.DirectorySeparatorChars.ShouldBe(new[] { '/' }); }
internal PublishInformation(PathInformation pathInfo, DateTime startTime, Template template, int?publishPosition = null) { PathInfo = pathInfo; LastVideoPublishTime = startTime; Template = template; if (publishPosition == null || publishPosition < 0) { publishPosition = -1; DateTime saveTime = startTime; for (int i = 0; i < Template.PublishTimes.Count; i++) { var nextSaveTime = startTime; if (startTime.TimeOfDay > Template.PublishTimes[i].Time) { // Heute ist nicht mehr möglich => Tag hinzufügen nextSaveTime += new TimeSpan(1, 0, 0, 0); } int daysUntilPublishDay = ((int)Template.PublishTimes[i].DayOfWeek - (int)nextSaveTime.DayOfWeek + 7) % 7; nextSaveTime = nextSaveTime.AddDays(daysUntilPublishDay); nextSaveTime = nextSaveTime.Date.Add(Template.PublishTimes[i].Time); if (saveTime - nextSaveTime > new TimeSpan(0, 0, 0) || publishPosition < 0) { // Zeit liegt näher saveTime = nextSaveTime; publishPosition = i; } } } PublishTimePosition = publishPosition.Value; }
public static void Init() { logFlags = (uint)Properties.Settings.Default.importLoggerSettings; logEnable = Properties.Settings.Default.guiExtendedLoggingEnabled && ((logFlags & (uint)LogEnable.Level3) > 0); logDetailed = logEnable && ((logFlags & (uint)LogEnable.Detailed) > 0); logCoordinates = logEnable && ((logFlags & (uint)LogEnable.Coordinates) > 0); Logger.Trace("Init Graphic2GCode loggerTrace:{0}", Convert.ToString(logFlags, 2)); pauseBeforePath = Properties.Settings.Default.importPauseElement; pauseBeforePenDown = Properties.Settings.Default.importPausePenDown; comments = Properties.Settings.Default.importSVGAddComments; penIsDown = false; gcodeString.Clear(); finalGcodeString.Clear(); PathCount = 0; FigureEndTagWasSet = true; gcode.setup(); // initialize GCode creation (get stored settings for export) pathInfo = new PathInformation(); if (!Properties.Settings.Default.importGroupObjects) // Load initial tool { toolProp tmpTool = toolTable.getToolProperties((int)Properties.Settings.Default.importGCToolDefNr); gcode.Tool(gcodeString, tmpTool.toolnr, tmpTool.name); // add tool change commands (if enabled) and set XYFeed etc. } }
public async Task <Stream> OpenReadAsync(string fullPath, CancellationToken cancellationToken = default) { GenericValidation.CheckBlobFullPath(fullPath); var info = new PathInformation(fullPath); return(await TryGetPropertiesAsync(info.Filesystem, info.Path, cancellationToken) == null ? null : Client.OpenRead(info.Filesystem, info.Path)); }
/// <summary> Returns the structure of the <paramref name="path"/>. </summary> public static string GetStructure( PathInformation path ) { var sb = new StringBuilder( path.Count ); foreach( var elem in path ) { sb.Append( elem.Type == InspectionPlanEntity.Part ? 'P' : 'C' ); } return sb.ToString(); }
/// <summary> Returns the structure of the <paramref name="path"/>. </summary> public static string GetStructure(PathInformation path) { var sb = new StringBuilder(path.Count); foreach (var elem in path) { sb.Append(elem.Type == InspectionPlanEntity.Part ? 'P' : 'C'); } return(sb.ToString()); }
internal static string NewNameContainsInvalidChar(PathInformation pathInformation) => $"The specified name contains one or more invalid characters. " + $"Invalid characters are:\n" + $"- The directory separator character '{pathInformation.DirectorySeparatorChar}'\n" + $"- The alternative directory separator character '{pathInformation.AltDirectorySeparatorChar}'\n" + $"- The volume separator character '{pathInformation.VolumeSeparatorChar}'\n" + $"\n" + $"You can use the {nameof(Files.FileSystem)}.{nameof(Files.FileSystem.PathInformation)} property " + $"of this folder's {nameof(Files.StorageFolder.FileSystem)} property to determine which characters" + $"are allowed.";
public PathObject() { info = new PathInformation(); start = new Point(); end = new Point(); distance = startAngle = pathLength = 0; dimension = new Dimensions(); options = CreationOptions.none; figureId = -1; }
public async Task <IReadOnlyCollection <Blob> > ListAsync(ListOptions options = null, CancellationToken cancellationToken = default) { if (options == null) { options = new ListOptions() { FolderPath = "/", Recurse = true }; } GenericValidation.CheckBlobFullPath(options.FolderPath); var info = new PathInformation(options.FolderPath); int maxResults = options.MaxResults ?? ListBatchSize; var blobs = new List <Blob>(); FilesystemList filesystemList = await Client.ListFilesystemsAsync(cancellationToken : cancellationToken); IEnumerable <FilesystemItem> filesystems = filesystemList.Filesystems .Where(x => info.Filesystem == "" || x.Name == info.Filesystem) .OrderBy(x => x.Name); foreach (FilesystemItem filesystem in filesystems) { try { DirectoryList directoryList = await Client.ListDirectoryAsync( filesystem.Name, info.Path, options.Recurse, cancellationToken : cancellationToken); IEnumerable <Blob> results = directoryList.Paths .Where(x => options.FilePrefix == null || x.Name.StartsWith(options.FilePrefix)) .Select(x => new Blob($"{filesystem.Name}/{x.Name}", x.IsDirectory ? BlobItemKind.Folder : BlobItemKind.File)) .Where(x => options.BrowseFilter == null || options.BrowseFilter(x)) .OrderBy(x => x.FullPath); blobs.AddRange(results); } catch (DataLakeGen2Exception e) when(e.StatusCode == HttpStatusCode.NotFound) { } if (blobs.Count >= maxResults) { return(blobs.Take(maxResults).ToList()); } } return(blobs.ToList()); }
public void CopyData(PathInformation tmp) { id = tmp.id; //groupId = tmp.groupId; penColorId = tmp.penColorId; pathId = tmp.pathId; pathGeometry = tmp.pathGeometry; //pathComment = tmp.pathComment; // groupAttributes = tmp.groupAttributes.ToList(); for (int i = 0; i < groupAttributes.Count; i++) { groupAttributes[i] = tmp.groupAttributes[i]; } }
/// <summary> /// Parses inspection plan filter criterias to a <see cref="ParameterDefinition"/> list. /// </summary> /// <param name="partPath">Path of the part the query should be restricted by.</param> /// <param name="partUuids">Uuids of the parts the query should be restricted by.</param> /// <param name="charUuids">Uuids of the parts the query should be restricted by.</param> /// <param name="depth">The depth determines how deep the response should be.</param> /// <param name="requestedPartAttributes">Restricts the part attributes that are returned.</param> /// <param name="requestedCharacteristicAttributes">Restricts the characteristic attributes that are returned.</param> /// <param name="withHistory">Determines if the history should be returned.</param> /// <returns></returns> public static List <ParameterDefinition> ParseToParameter(PathInformation partPath = null, Guid[] partUuids = null, Guid[] charUuids = null, ushort?depth = null, AttributeSelector requestedPartAttributes = null, AttributeSelector requestedCharacteristicAttributes = null, bool withHistory = false) { var parameter = new List <ParameterDefinition>(); if (partPath != null) { parameter.Add(ParameterDefinition.Create("partPath", PathHelper.PathInformation2DatabaseString(partPath))); } if (depth.HasValue) { parameter.Add(ParameterDefinition.Create("depth", depth.ToString())); } if (withHistory) { parameter.Add(ParameterDefinition.Create("withHistory", true.ToString())); } if (partUuids != null && partUuids.Length > 0) { parameter.Add(ParameterDefinition.Create("partUuids", ConvertGuidListToString(partUuids))); } if (charUuids != null && charUuids.Length > 0) { parameter.Add(ParameterDefinition.Create("charUuids", ConvertGuidListToString(charUuids))); } if (requestedPartAttributes != null) { if (requestedPartAttributes.AllAttributes != AllAttributeSelection.True && requestedPartAttributes.Attributes != null) { parameter.Add(ParameterDefinition.Create("requestedPartAttributes", ConvertUshortArrayToString(requestedPartAttributes.Attributes))); } else if (requestedPartAttributes.AllAttributes == AllAttributeSelection.False) { parameter.Add(ParameterDefinition.Create("requestedPartAttributes", "None")); } } if (requestedCharacteristicAttributes != null) { if (requestedCharacteristicAttributes.AllAttributes != AllAttributeSelection.True && requestedCharacteristicAttributes.Attributes != null) { parameter.Add(ParameterDefinition.Create("requestedCharacteristicAttributes", ConvertUshortArrayToString(requestedCharacteristicAttributes.Attributes))); } else if (requestedCharacteristicAttributes.AllAttributes == AllAttributeSelection.False) { parameter.Add(ParameterDefinition.Create("requestedCharacteristicAttributes", "None")); } } return(parameter); }
public async Task <Stream> OpenWriteAsync(string fullPath, bool append = false, CancellationToken cancellationToken = default) { GenericValidation.CheckBlobFullPath(fullPath); var info = new PathInformation(fullPath); if (!append) { await Client.CreateFileAsync(info.Filesystem, info.Path, cancellationToken); } return(await Client.OpenWriteAsync(info.Filesystem, info.Path, cancellationToken)); }
public static double SurfacePathDistance(this WoWObject objectTo) { PathInformation info = Navigator.LookupPathInfo(objectTo); if (info.Navigability == PathNavigability.Navigable) { // Don't care about whether this is a min distance or exact one... return(info.Distance); } return(double.NaN); }
public static int StartPath(PathObject pathObject)//string cmt) { Point coordxy = pathObject.Start; double angle = 0; angle = pathObject.StartAngle; PenUp(); // Don't set xmlMarker.figureEnd if (!pathInfo.IsSameAs(pathObject.Info) || FigureEndTagWasSet) { if (!FigureEndTagWasSet) { SetFigureEndTag(); } FigureEndTagWasSet = true; string xml = string.Format("{0} Id=\"{1}\"{2}> ", xmlMarker.figureStart, (++PathCount), getFigureAttributes(pathObject).ToString()); //attributeGeometry, attributeId, attributeColor, attributeToolNr); if (figureEnable) { Comment(xml); } if (logCoordinates) { Logger.Trace(" StartPath Option:{0} {1}", pathObject.Options, xml); } FigureEndTagWasSet = false; pathInfo = pathObject.Info.Copy(); if ((pathObject.Options & CreationOptions.AddPause) > 0) { gcode.Pause(gcodeString); } } double setangle = 180 * angle / Math.PI; gcode.setTangential(gcodeString, setangle); gcode.MoveToRapid(gcodeString, coordxy); PenDown(""); if (logCoordinates) { Logger.Trace(" StartPath at x{0:0.000} y{1:0.000} a={2:0.00}", coordxy.X, coordxy.Y, setangle); } lastGC = coordxy; return(PathCount); }
/// <summary> Converts <paramref name="path"/> to a string which can be stored in the database. </summary> public static string PathInformation2String( PathInformation path ) { var sb = new StringBuilder(); sb.Append( Delimiter ); var count = path.Count; for( var i = 0; i < count; i++ ) { sb.Append( path[ i ].Value.Replace( @"\", @"\\" ).Replace( DelimiterString, EscapedDelimiter ) ); sb.Append( Delimiter ); } return sb.ToString(); }
/// <summary> Converts <paramref name="path"/> to a string which can be stored in the database. </summary> public static string PathInformation2String(PathInformation path) { var sb = new StringBuilder(); sb.Append(Delimiter); var count = path.Count; for (var i = 0; i < count; i++) { sb.Append(path[i].Value.Replace(@"\", @"\\").Replace(DelimiterString, EscapedDelimiter)); sb.Append(Delimiter); } return(sb.ToString()); }
public static string GetStructure([NotNull] PathInformation path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } var result = new char[path.Count]; for (var i = 0; i < path.Count; i++) { result[i] = path[i].Type == InspectionPlanEntity.Part ? 'P' : 'C'; } return(new string( result )); }
private async Task DeleteAsync(string fullPath, CancellationToken cancellationToken) { GenericValidation.CheckBlobFullPath(fullPath); var info = new PathInformation(fullPath); Properties properties = await Client.GetPropertiesAsync(info.Filesystem, info.Path, cancellationToken); if (properties.IsDirectory) { await Client.DeleteDirectoryAsync(info.Filesystem, info.Path, true, cancellationToken); return; } await Client.DeleteFileAsync(info.Filesystem, info.Path, cancellationToken); }
public async Task <IReadOnlyCollection <Blob> > GetBlobsAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken = default) { var fullPathsList = fullPaths.ToList(); GenericValidation.CheckBlobFullPaths(fullPathsList); return(await Task.WhenAll(fullPathsList.Select(async x => { var info = new PathInformation(x); Properties properties = await TryGetPropertiesAsync(info.Filesystem, info.Path, cancellationToken); return properties == null ? null : new Blob(x, properties.IsDirectory ? BlobItemKind.Folder : BlobItemKind.File) { LastModificationTime = properties.LastModified, Size = properties.Length }; }))); }
public DefaultInMemoryStoragePath(InMemoryFileSystem fileSystem, string path) : base(fileSystem, path) { _pathInformation = fileSystem.PathInformation; if (path.Contains(_pathInformation.InvalidPathChars.ToArray()) || path.Contains(_pathInformation.InvalidFileNameChars.ToArray())) { throw new ArgumentException(ExceptionStrings.StoragePath.InvalidFormat(), nameof(path)); } Kind = GetKind(); Name = GetName(); NameWithoutExtension = GetNameWithoutExtension(); Extension = GetExtension(); _rootLazy = new Lazy <StoragePath?>(() => GetRoot()); _parentLazy = new Lazy <StoragePath?>(() => GetParent()); _fullPathLazy = new Lazy <StoragePath>(() => GetFullPath()); }
public static string PathInformation2String([NotNull] PathInformation path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } // fast code path for root path if (path.IsRoot) { return(DelimiterString); } var sb = new StringBuilder(25); PathInformation2StringInternal(sb, path); return(sb.ToString()); }
public static Mock <FileSystem> Create(PathInformation pathInformation) { var fsMock = new Mock <FileSystem>(pathInformation) { CallBase = true }; fsMock .Setup(x => x.GetPath(It.IsAny <string>())) .Returns((string path) => StoragePathMocks.Create(fsMock.Object, path).Object); fsMock .Setup(x => x.GetFile(It.IsAny <StoragePath>())) .Returns((StoragePath path) => StorageFileMocks.Create(fsMock.Object, path).Object); fsMock .Setup(x => x.GetFolder(It.IsAny <StoragePath>())) .Returns((StoragePath path) => StorageFolderMocks.Create(fsMock.Object, path).Object); return(fsMock); }
public static string PathInformation2RoundtripString([NotNull] PathInformation path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } // fast code path for root path if (path.IsRoot) { return(DelimiterString); } var sb = new StringBuilder(25); sb.Append(GetStructure(path)); sb.Append(":"); sb.Append(PathInformation2DatabaseString(path)); return(sb.ToString()); }
public static void Init() { logFlags = (uint)Properties.Settings.Default.importLoggerSettings; logEnable = Properties.Settings.Default.guiExtendedLoggingEnabled && ((logFlags & (uint)LogEnable.Level3) > 0); logDetailed = logEnable && ((logFlags & (uint)LogEnable.Detailed) > 0); logCoordinates = logEnable && ((logFlags & (uint)LogEnable.Coordinates) > 0); Logger.Trace("Init Graphic2GCode loggerTrace:{0}", Convert.ToString(logFlags, 2)); pauseBeforePath = Properties.Settings.Default.importPauseElement; pauseBeforePenDown = Properties.Settings.Default.importPausePenDown; comments = Properties.Settings.Default.importSVGAddComments; penIsDown = false; gcodeString.Clear(); finalGcodeString.Clear(); PathCount = 0; FigureEndTagWasSet = true; gcode.setup(); // initialize GCode creation (get stored settings for export) pathInfo = new PathInformation(); }
private void AddPathButtonClick(object sender, EventArgs e) { var result = folderBrowserDialog.ShowDialog(this); if (result == DialogResult.OK) { if (Directory.Exists(folderBrowserDialog.SelectedPath) && !uploader.Paths.Any(path => path.Path == folderBrowserDialog.SelectedPath)) { var newPath = new PathInformation() { Path = folderBrowserDialog.SelectedPath, Filter = "*.mp4;*.mkv", SelectedTemplateId = 0, SearchRecursively = false, Inactive = false, SearchHidden = false }; uploader.Paths.Add(newPath); RefillListView(); lvPaths.SelectedIndices.Add(lvPaths.Items.Count - 1); } } }
private static void PathInformation2StringInternal([NotNull] StringBuilder sb, [NotNull] PathInformation path) { var count = path.Count; for (var i = 0; i < path.Count; i++) { sb.Append(path[i].Value.Replace(@"\", @"\\").Replace(DelimiterString, EscapedDelimiter)); if ((i + 1) < count) { sb.Append(Delimiter); } } }
/// <summary> Internal method to create a <see cref="PathInformation"/> object from <paramref name="path"/>. </summary> private static PathInformation String2PathInformationInternal( string path, string structure, InspectionPlanEntity? entity ) { var resultPath = PathInformation.Root; if( !string.IsNullOrEmpty( path ) && !( path == Delimiter.ToString() && string.IsNullOrEmpty( structure ) ) ) { var result = new List<PathElement>( structure != null ? structure.Length : 10 ); int i = 0; var startIndex = path[ 0 ] == Delimiter ? 1 : 0; var sb = new StringBuilder( path.Length ); for( int j = startIndex; j < path.Length; j++ ) // ersten Slash überlesen { char current = path[ j ]; if( current == '\\' ) { current = path[ ++j ]; sb.Append( current ); } else if( current == Delimiter ) { if( structure == null ) result.Add( new PathElement( entity.GetValueOrDefault( InspectionPlanEntity.Part ), sb.ToString() ) ); else if (structure.Length <= i) throw new ArgumentException( string.Format( "The path structure does not match the actual path: The path is '{0}' but structure is '{1}' ({2} segements).", path, structure, structure.Length ), "structure" ); else if( structure[ i++ ] == 'P' ) result.Add( new PathElement( InspectionPlanEntity.Part, sb.ToString() ) ); else result.Add( new PathElement( InspectionPlanEntity.Characteristic, sb.ToString() ) ); sb = new StringBuilder( path.Length ); } else { sb.Append( current ); } } if( sb.Length > 0 ) { if( structure == null ) result.Add( new PathElement( entity.GetValueOrDefault( InspectionPlanEntity.Part ), sb.ToString() ) ); else if( structure.Length <= i ) throw new ArgumentException( string.Format( "The path structure does not match the actual path: The path is '{0}' but structure is '{1}' ({2} segements).", path, structure, structure.Length ), "structure" ); else if( structure[ i++ ] == 'P' ) result.Add( new PathElement( InspectionPlanEntity.Part, sb.ToString() ) ); else result.Add( new PathElement( InspectionPlanEntity.Characteristic, sb.ToString() ) ); } resultPath = new PathInformation( result ); } return resultPath; }
/// <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> /// Fetches a list of characteristics below <paramref name="partPath"/>. If the parent part is <code>null</code> the characteristics below /// the root part will be returned. The search can be restricted using the various filter parameters. 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 characteristic.</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="requestedCharacteristicAttributes">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<InspectionPlanCharacteristic>> GetCharacteristics( PathInformation partPath = null, Guid[] partUuids = null, ushort? depth = null, AttributeSelector requestedCharacteristicAttributes = null, bool withHistory = false, bool streamed = false, CancellationToken cancellationToken = default(CancellationToken) ) { var parameter = RestClientHelper.ParseToParameter( partPath, partUuids, depth, requestedCharacteristicAttributes, withHistory: withHistory ); if( streamed ) return await GetEnumerated<InspectionPlanCharacteristic>( "characteristics", cancellationToken, parameter.ToArray() ).ConfigureAwait( false ); return await Get<InspectionPlanCharacteristic[]>( "characteristics", cancellationToken, parameter.ToArray() ).ConfigureAwait( false ); }
/// <summary> /// This method fetches all characteristics and child characteristics of the selected part. Characteristics from child parts /// are not fetched though. This behavior - fetching all characteristics for one part with one call - is the best practice /// and the most efficient way of fetching characteristics. /// </summary> private async Task FetchAllCharacteristicsForPart( PathInformation partPath ) { _CharacteristicsListView.Items.Clear(); try { LogMessage( "Fetching all characteristics for part '{0}' from data service.", partPath ); var sw = System.Diagnostics.Stopwatch.StartNew(); var characteristics = await _RestDataServiceClient.GetCharacteristics( partPath ); _Characteristics = characteristics.ToDictionary( c => c.Uuid ); sw.Stop(); LogMessage( "Successfully fetched {1} characteristics from data service in {0} ms.\r\n", sw.ElapsedMilliseconds, _Characteristics.Count ); } catch( Exception ex ) { LogMessage( "Error fetching all characteristics for part '{0}' from data service: '{1}'.\r\n", partPath, ex.Message ); } _CharacteristicsListView.BeginUpdate(); foreach( var part in _Characteristics.Values.OrderBy( p => p.Path.ToString() ) ) { _CharacteristicsListView.Items.Add( await CreateListViewItem( part ) ); } _CharacteristicsListView.EndUpdate(); }
/// <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> /// This method fetches the most recent 100 measurements for the selected part. Please have a look at the other properties inside /// the filter class to understand all possibilities of filtering. /// </summary> private async Task FetchMeasurements( PathInformation partPath ) { _MeasurementsListView.Items.Clear(); SimpleMeasurement[] _Measurements = new SimpleMeasurement[0]; try { LogMessage( "Fetching all last 100 measurements for part '{0}' from data service.", partPath ); var sw = System.Diagnostics.Stopwatch.StartNew(); _Measurements = ( await _RestDataServiceClient.GetMeasurements( partPath, new MeasurementFilterAttributes { LimitResult = 100 } ) ).ToArray(); sw.Stop(); LogMessage( "Successfully fetched {1} measurements from data service in {0} ms.\r\n", sw.ElapsedMilliseconds, _Measurements.Length ); } catch( Exception ex ) { LogMessage( "Error fetching measurements for part '{0}' from data service: '{1}'.\r\n", partPath, ex.Message ); } _MeasurementsListView.BeginUpdate(); foreach( var meas in _Measurements.OrderByDescending( p => p.Time ) ) { _MeasurementsListView.Items.Add( CreateListViewItem( meas ) ); } _MeasurementsListView.EndUpdate(); }
/// <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> /// 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 ); }