If you have played around with the new Grid Control, you may have noticed that there is a column for the status icon. It’s a highly useful piece of information that is difficult to calculate. The good news is that you can leverage the 2014 API to give you this data, either in icon form or object form.
Client side properties:
The status icon is an example of a client-side property. It’s not something the server can do because it requires data from your hard-drive. There are many factors that go into the status image, including comparing the state of the local file with the state of the corresponding file in Vault. So, if you are looking for an easy way for your app to see what files are out of date, the status property gives that to you easily.
You can’t search on client-side properties, since the server controls the search feature. You also can’t use any of the web service functions because those functions only deal with server-side data. You need to use VDF libraries (Autodesk.DataManagement.*) in order to work with client-side properties.
Getting the icon:
If you are displaying the grid, the control itself will take care of displaying the icon. But if you want to use the icon in your own UI, there is a way to get it. It’s probably best if I just start with the code and then explain what the code is doing.
using VDF = Autodesk.DataManagement.Client.Framework;
PropertyDefinitionDictionary props =
PropertyDefinition statusProp =
EntityStatusImageInfo status =
statusProp, null) as EntityStatusImageInfo;
Step one is to get the VDF PropertyDefintion for the status information. I do this by first calling Connection.PropertyManager.GetPropertyDefinitions and grabbing all file-related PropertyDefinitions. This is a VDF function, so I get back both client and server property definitions. The return object is indexed by ID and system name. So, it’s easy to look up a property if I know the system name. In the case of Vault status, the ID is defined in PropertyDefinitionsIds.
The last step is to call GetPropertyValue for on my FileIteration object. The function returns an Object, which I convert to EntityStatusImageInfo.
This is a very useful class. Not only does it give you the Image object itself, but it gives you a data structure describing the status. So you can, for example, write special logic for cases where the local file version doesn’t match any vault version (ie. edited out of turn).
You can call GetImage to get an Image object that you can display in your UI. The algorithm for calculating that image is surprisingly complex, so it’s good do have a functions that does the calculation for you. Because this is the same code used by the clients, your icon will match the icon seen in Vault Explorer and the CAD plug-ins.