public static string GetVaultCheckOutComment(VDF.Vault.Currency.Entities.FileIteration selectedFile, VDF.Vault.Currency.Connections.Connection connection) { // a list of dictionaries of the vault properties of the associated files List <Dictionary <string, string> > vaultPropDictList = new List <Dictionary <string, string> >(); // function that gets properties requires a list so we'll define a list and add the selected file to it... List <VDF.Vault.Currency.Entities.FileIteration> fileList = new List <VDF.Vault.Currency.Entities.FileIteration>(); fileList.Add(selectedFile); // define a dictionary to hold all the properties pertaining to a vault entity VDF.Vault.Currency.Properties.PropertyDefinitionDictionary allPropDefDict = new VDF.Vault.Currency.Properties.PropertyDefinitionDictionary(); allPropDefDict = connection.PropertyManager.GetPropertyDefinitions(VDF.Vault.Currency.Entities.EntityClassIds.Files, null, VDF.Vault.Currency.Properties.PropertyDefinitionFilter.IncludeAll); // define a list of only the properties that we are concerned about. List <VDF.Vault.Currency.Properties.PropertyDefinition> filteredPropDefList = new List <VDF.Vault.Currency.Properties.PropertyDefinition>(); List <string> propNames = new List <string> { "Comment" }; // copy only definitions in propNames list from allPropDefDict to filteredPropDefList foreach (string s in propNames) { VDF.Vault.Currency.Properties.PropertyDefinition propDefs = new Autodesk.DataManagement.Client.Framework.Vault.Currency.Properties.PropertyDefinition(); propDefs = allPropDefDict[s]; filteredPropDefList.Add(propDefs); } // the following line should return a list of properties VDF.Vault.Currency.Properties.PropertyValues propValues = new Autodesk.DataManagement.Client.Framework.Vault.Currency.Properties.PropertyValues(); propValues = connection.PropertyManager.GetPropertyValues(fileList, filteredPropDefList, null); VDF.Vault.Currency.Properties.PropertyDefinition def = new VDF.Vault.Currency.Properties.PropertyDefinition(propNames[0]); VDF.Vault.Currency.Properties.PropertyValue val; Dictionary <VDF.Vault.Currency.Properties.PropertyDefinition, VDF.Vault.Currency.Properties.PropertyValue> d = propValues.GetValues(selectedFile); d.TryGetValue(def, out val); string key = null; if (def != null) { key = (def.SystemName == null) ? null : def.SystemName; string value = null; if (val != null) { value = (val.Value == null) ? "" : val.Value.ToString(); return(value); } else { value = ""; } } return(null); }
public static FileFolder SearchVaultPDF(System.IO.FileInfo pdfFile) { // search the vault for the specified file // find the Filename property //string fname = getIptFileName(symFile.Name); string fname = (Path.GetFileNameWithoutExtension(pdfFile.Name) + ".ipt"); Autodesk.DataManagement.Client.Framework.Vault.Currency.Properties.PropertyDefinition propDef = connection.PropertyManager.GetPropertyDefinitionBySystemName("ClientFileName"); if (propDef == null) { throw new Exception("Error looking up FileName property"); } SrchCond condition = new SrchCond(); condition.SrchTxt = fname; condition.SrchOper = 3; //exact match condition.PropDefId = propDef.Id; condition.PropTyp = PropertySearchType.SingleProperty; List <FileFolder> resultList = new List <FileFolder>(); SrchStatus status = null; string bookmark = string.Empty; while (status == null || resultList.Count < status.TotalHits) { //FileFolder[] results = docSrv.FindFileFoldersBySearchConditions( FileFolder[] results = connection.WebServiceManager.DocumentService.FindFileFoldersBySearchConditions( new SrchCond[] { condition }, null, null, true, true, ref bookmark, out status); if (results != null) { resultList.AddRange(results); return(resultList[0]); } else { // search for assemblies yet too. fname = (Path.GetFileNameWithoutExtension(pdfFile.Name) + ".iam"); propDef = connection.PropertyManager.GetPropertyDefinitionBySystemName("ClientFileName"); if (propDef == null) { throw new Exception("Error looking up FileName property"); } condition = new SrchCond(); condition.SrchTxt = fname; condition.SrchOper = 3; //exact match condition.PropDefId = propDef.Id; condition.PropTyp = PropertySearchType.SingleProperty; resultList = new List <FileFolder>(); status = null; bookmark = string.Empty; while (status == null || resultList.Count < status.TotalHits) { //FileFolder[] results = docSrv.FindFileFoldersBySearchConditions( results = connection.WebServiceManager.DocumentService.FindFileFoldersBySearchConditions( new SrchCond[] { condition }, null, null, true, true, ref bookmark, out status); if (results != null) { resultList.AddRange(results); return(resultList[0]); } else { return(null); } } return(null); } } return(null); }