The code below updates multiple properties of a file:
//synchronize source file properties to export file properties for UDPs assigned to both
try
{
mTrace.WriteLine("Job tries synchronizing export file's properties in Vault.");
//get the design rep category's user properties
ACET.IExplorerUtil mExplUtil = Autodesk.Connectivity.Explorer.ExtensibilityTools.ExplorerLoader.LoadExplorerUtil(
connection.Server, connection.Vault, connection.UserID, connection.Ticket);
Dictionary<ACW.PropDef, object> mPropDictonary = new Dictionary<ACW.PropDef, object>();
//get property definitions filtered to UDPs
VDF.Vault.Currency.Properties.PropertyDefinitionDictionary mPropDefs = connection.PropertyManager.GetPropertyDefinitions(
VDF.Vault.Currency.Entities.EntityClassIds.Files, null, VDF.Vault.Currency.Properties.PropertyDefinitionFilter.IncludeUserDefined);
//get property definitions assigned to Design Representation category
ACW.CatCfg catCfg1 = mWsMgr.CategoryService.GetCategoryConfigurationById(mExpFile.Cat.CatId, new string[] { "UserDefinedProperty" });
List<long> mFilePropDefs = new List<long>();
foreach (ACW.Bhv bhv in catCfg1.BhvCfgArray.First().BhvArray)
{
mFilePropDefs.Add(bhv.Id);
}
//get properties assigned to source file and add definition/value pair to dictionary
ACW.PropInst[] mSourcePropInst = mWsMgr.PropertyService.GetProperties("FILE", new long[] { mFile.Id }, mFilePropDefs.ToArray());
ACW.PropDef[] propDefs = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE");
foreach (ACW.PropInst item in mSourcePropInst)
{
VDF.Vault.Currency.Properties.PropertyDefinition mPropDef = connection.PropertyManager.GetPropertyDefinitionById(item.PropDefId);
ACW.PropDef propDef = propDefs.SingleOrDefault(n => n.Id == item.PropDefId);
mPropDictonary.Add(propDef, item.Val);
}
//update export file using the property dictionary; note this the IExplorerUtil method bumps file iteration and requires no check out
mExplUtil.UpdateFileProperties(mExpFile, mPropDictonary);
}
To get the full context of all references used, you may download the full example from here: https://github.com/koechlm/Vault-Sample---STEPExportJob.
Markus Koechl
Solutions Engineer PDM, Autodesk Central Europe