/// <summary>
        /// Reads the JSON representation of the object.
        /// </summary>
        public override object ReadJson( Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer )
        {
            var configuration = new Configuration();

            while( reader.Read() && reader.TokenType == Newtonsoft.Json.JsonToken.PropertyName )
            {
                switch( reader.Value.ToString() )
                {
                    case "partAttributes":
                        reader.Read();
                        configuration.PartAttributes = serializer.Deserialize<AbstractAttributeDefinition[]>( reader );
                        break;
                    case "characteristicAttributes":
                        reader.Read();
                        configuration.CharacteristicAttributes = serializer.Deserialize<AbstractAttributeDefinition[]>( reader );
                        break;
                    case "measurementAttributes":
                        reader.Read();
                        configuration.MeasurementAttributes = serializer.Deserialize<AbstractAttributeDefinition[]>( reader );
                        break;
                    case "valueAttributes":
                        reader.Read();
                        configuration.ValueAttributes = serializer.Deserialize<AbstractAttributeDefinition[]>( reader );
                        break;
                    case "catalogAttributes":
                        reader.Read();
                        configuration.CatalogAttributes = serializer.Deserialize<AttributeDefinition[]>( reader );
                        break;
                }
            }
            return configuration;
        }
Example #2
0
		public async void InitializeControl( Uri serverUri, Configuration configuration, CatalogCollection catalogs )
		{
			_Configuration = configuration;
			_Catalogs = catalogs;
			_RestDataServiceClient = new DataServiceRestClient( serverUri );
			_RestRawDataServiceClient = new RawDataServiceRestClient( serverUri );

			await FetchAllParts();
		}
		public async void InitializeControl( Uri serverUri, Configuration configuration, CatalogCollection catalogs )
		{
			_Configuration = configuration;
			_Catalogs = catalogs;
			_RestDataServiceClient = new DataServiceRestClient( serverUri );
			_RestRawDataServiceClient = new RawDataServiceRestClient( serverUri );

			var partPath = PathHelper.String2PartPathInformation( _PartTextBox.Text );
			var parts = await _RestDataServiceClient.GetParts( partPath );
			var partsArray = parts as InspectionPlanPart[] ?? parts.ToArray();
			if( partsArray.Any() )
				_CurrentPart = partsArray.First();

			var chars = await _RestDataServiceClient.GetCharacteristics( partPath );
			var charsArray = chars as InspectionPlanCharacteristic[] ?? chars.ToArray();
			if( charsArray.Any() )
				_CurrentCharacteristics = charsArray;

			FillRawDataListView();
		}
        /// <summary>
        /// Returns the attribute's value of the attribute with the key <paramref name="key"/> If the attribute consists of a catalog entry the entry
        /// is returned, otherwise the attribute's value (string, int, double or DateTime) is returned.
        /// </summary>
        public static object GetRawAttributeValue(
			this IAttributeItem item,
			ushort key,
			Configuration configuration,
			CatalogCollection catalogs )
        {
            var value = item.GetAttribute( key );
            if( value == null )
                return null;

            if( value.RawValue != null )
                return value.RawValue;

            return configuration.ParseValue( key, value.Value, catalogs );
        }
Example #5
0
		/// <summary>
		/// This method fetches the configuration from the data service. The configuration contains definitions about all
		/// attributes that might be present for part, characteristics, measurements, values and catalog. Each attribute
		/// definition defines a data type for the attribute value.
		/// </summary>
		private async Task FetchConfiguration()
		{
			try
			{
				LogMessage( "Fetching configuration from data service." );

				var sw = System.Diagnostics.Stopwatch.StartNew();
				_Configuration = await _RestDataServiceClient.GetConfiguration();
				sw.Stop();

				LogMessage( "Successfully fetched configuration with {1} attribute definitions from data service in {0} ms.\r\n", sw.ElapsedMilliseconds, _Configuration.AllAttributes.Length );
			}
			catch( Exception ex )
			{
				LogMessage( "Error fetching configuration from data service: '{0}'.\r\n", ex.Message );
			}
		}