public void Run() { try { Console.WriteLine("\n\nGetSpaceTypes..."); IEnumerable <MetasysObjectType> spaceTypes = client.GetSpaceTypes(); foreach (var type in spaceTypes) { Console.WriteLine($"\nType {type.Id}: {type.Description}, "); } // Select a space type Console.WriteLine("\nPlease enter the Space Type ID to retrieve all related spaces:"); string spaceType = Console.ReadLine(); IEnumerable <MetasysObject> spaces = client.GetSpaces((SpaceTypeEnum)Enum.Parse(typeof(SpaceTypeEnum), spaceType)); Console.WriteLine($"Spaces found: {spaces.Count()}"); foreach (var space in spaces) { Console.WriteLine($"\n{space.Id}: {space.Name}, {space.ItemReference}"); } // Select a space Console.WriteLine("\nPlease enter the Space ID to retrieve all related equipment:"); string spaceID = Console.ReadLine(); IEnumerable <MetasysObject> spaceEquipment = client.GetSpaceEquipment(new Guid(spaceID)); Console.WriteLine($"Equipment found: {spaceEquipment.Count()}"); foreach (var o in spaceEquipment) { Console.WriteLine($"\n{o.Id}: {o.Name}, {o.ItemReference}"); } } catch (Exception exception) { log.Logger.Error(string.Format("An error occured while getting space information - {0}", exception.Message)); Console.WriteLine("\n \nAn Error occurred. Press Enter to return to Main Menu"); } Console.ReadLine(); }
private void GetSpaces() { /* SNIPPET 1: START */ // Retrieves the list of Buildings using SpaceTypeEnum helper List <MetasysObject> buildings = client.GetSpaces(SpaceTypeEnum.Building).ToList(); MetasysObject building = buildings.LastOrDefault(); Console.WriteLine(building); /* * { * "ItemReference": "Win2016-VM2:Win2016-VM2/JCI.Building 1", * "Id": "164aaba2-0fb3-5b5d-bfe9-49cf6b797c93", * "Name": "North America (BACnet)", * "Description": null, * "Type": 2, * "TypeUrl": "https://win2016-vm2/api/v2/enumSets/1766/members/1", * "Category": "Building", * "Children": [], * "ChildrenCount": 0 * } */ // Retrieves all the spaces in a flat hierarchy List <MetasysObject> spaces = client.GetSpaces().ToList(); MetasysObject firstSpace = spaces.FirstOrDefault(); Console.WriteLine(firstSpace); /* * { * "ItemReference": "Win2016-VM2:Win2016-VM2/JCI.Building 1.Floor 1.Milwaukee.507 E Michigan Street Campus", * "Id": "896ba096-db3c-5038-8505-636785906cca", * "Name": "507 E Michigan Street Campus", * "Description": null, * "Type": 2, * "TypeUrl": "https://win2016-vm2/api/v2/enumSets/1766/members/3", * "Category": "Room", * "Children": [], * "ChildrenCount": 0 * } */ /* SNIPPET 1: END */ }