Ejemplo n.º 1
0
		/// <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();
		}
Ejemplo n.º 2
0
		private ListViewItem CreateListViewItem( SimpleMeasurement measurement )
		{
			var subItems = new[]
			{
				measurement.Time.ToLocalTime().ToString( CultureInfo.CurrentCulture ),
				measurement.LastModified.ToLocalTime().ToString( CultureInfo.CurrentCulture ),
				string.Format( "{0} attributes", measurement.Attributes.Length )
			};

			return new ListViewItem( subItems )
			{
				Tag = measurement,
				ToolTipText = CreateAttributeTooltip( measurement )
			};
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Updates the specified measurements in the database.
		/// </summary>
		/// <param name="measurements">The measurements to update.</param>
		/// <param name="cancellationToken">A token to cancel the asynchronous operation.</param>
		public Task UpdateMeasurements( SimpleMeasurement[] measurements, CancellationToken cancellationToken = default(CancellationToken) )
		{
			return Put( "measurements", measurements, cancellationToken );
		}