/// <summary>
        ///     Shows how to work with the attribute configuration.
        /// </summary>
        /// <param name="client">The client.</param>
        public static async Task Lesson(DataServiceRestClient client)
        {
            //Create attributes
            await client.CreateAttributeDefinition(Entity.Part, AttributeDefinition);

            //This will create an attribute which can be used by catalogs. Don't be confused, this is no catalog attribute
            await client.CreateAttributeDefinition(Entity.Catalog, CatalogColumnAttributeDefinition);

            //Create a catalog which we can use for our catalog attribute
            await client.CreateCatalogs(new[] { Catalog });

            //Create the catalog attribute definition.
            await client.CreateAttributeDefinition(Entity.Part, CatalogAttributeDefinition);

            //Notes: - you can't create catalog attributes for catalogs (Entity.Catalog)
            //Notes: - you must obey the shown order of commands!

            //You can update everything except the key, which is the identifier.
            //To change the key, you must delete and recreate the attribute, but be aware: all data stored for this attribute will be lost!
            CatalogAttributeDefinition.Description = "Characteristic catalog attribute";
            await client.UpdateAttributeDefinitions(Entity.Characteristic, new[] { CatalogAttributeDefinition });

            //Get all attributes
            var configuration = await client.GetConfiguration();

            //Attributes are assigned to an entity: part, characteristic, measurement, value or catalog.
            Console.WriteLine($"Attributes for part: {configuration.PartAttributes.Length}");
            Console.WriteLine($"Attributes for characteristic: {configuration.CharacteristicAttributes.Length}");
            Console.WriteLine($"Attributes for measurement: {configuration.MeasurementAttributes.Length}");
            Console.WriteLine($"Attributes for value: {configuration.ValueAttributes.Length}");
            Console.WriteLine($"Attributes for catalog: {configuration.CatalogAttributes.Length}");
        }
Exemple #2
0
        public static async Task Lesson(DataServiceRestClient client)
        {
            //A catalog must have at least one attribute.
            //Attributes with entity 'Catalog' must not be of type 'CatalogAttribute'
            await client.CreateAttributeDefinitions(EntityDto.Catalog, new[] { MachineName, MachineNumber, MachineVendor });

            //Create the catalog
            await client.CreateCatalogs(new[] { MachineCatalog });

            //Add an attribute
            MachineCatalog.ValidAttributes = MachineCatalog.ValidAttributes.Append(MachineVendor.Key);

            await client.UpdateCatalogs(new[] { MachineCatalog });

            //Add an entry
            await client.CreateCatalogEntries(MachineCatalog.Uuid, new[] { EntryXenos });

            //Update existing catalog entries
            EntryAccura.Attributes  = EntryAccura.Attributes.Append(new AttributeDto(MachineVendor.Key, "Zeiss"));
            EntryContura.Attributes = EntryContura.Attributes.Append(new AttributeDto(MachineVendor.Key, "Zeiss"));

            await client.UpdateCatalogs(new[] { MachineCatalog });
        }