public static List<ADSK.File> findByMatches(_DocumentService documentService, String sfind) { /* Faz a pesquisa */ string bookmark = string.Empty; ADSK.SrchStatus status = null; ADSK.SrchCond[] conditions = new ADSK.SrchCond[1]; conditions[0] = new ADSK.SrchCond(); conditions[0].SrchOper = Condition.CONTAINS.Code; // (long)SrchOperator.Contains; // 1; // Contains conditions[0].SrchTxt = sfind; conditions[0].PropTyp = ADSK.PropertySearchType.SingleProperty; conditions[0].PropDefId = propid; conditions[0].SrchRule = ADSK.SearchRuleType.Must; //Console.WriteLine("Vai procurar os arquivos -------"); List<ADSK.File> fileList = new List<ADSK.File>(); while (status == null || fileList.Count < status.TotalHits) { ADSK.File[] files = documentService.FindFilesBySearchConditions( conditions, /*SrchCond [] conditions*/ null, /*SrchSort [] sortConditions*/ folderIds, /*Long [] folderIds*/ true, /*Boolean recurseFolders*/ true, /*Boolean latestOnly*/ ref bookmark, /*[out] String bookmark*/ out status /*[out] SrchStatus searchstatus*/ ); if (files != null) fileList.AddRange(files); } return fileList; }
public static List<ADSK.File> findByEquals(_DocumentService documentService, string filename) { /* Faz a pesquisa */ string bookmark = string.Empty; ADSK.SrchStatus status = null; ADSK.SrchCond[] conditions = new ADSK.SrchCond[1]; conditions[0] = new ADSK.SrchCond(); conditions[0].SrchOper = Condition.EQUALS.Code; // (long)SrchOperator.IsExactly; // 3; // Is exactly (or equals) conditions[0].SrchTxt = filename; conditions[0].PropTyp = ADSK.PropertySearchType.SingleProperty; conditions[0].PropDefId = propid; conditions[0].SrchRule = ADSK.SearchRuleType.Must; /*Console.WriteLine("Arquivos a procurar:"); foreach (ADSK.SrchCond cond in conditions) { Console.WriteLine(" -> " + cond.SrchTxt); }*/ //Console.WriteLine("Vai procurar os arquivos -------"); List<ADSK.File> fileList = new List<ADSK.File>(); while (status == null || fileList.Count < status.TotalHits) { ADSK.File[] files = documentService.FindFilesBySearchConditions( conditions, /*SrchCond [] conditions*/ null, /*SrchSort [] sortConditions*/ folderIds, /*Long [] folderIds*/ true, /*Boolean recurseFolders*/ true, /*Boolean latestOnly*/ ref bookmark, /*[out] String bookmark*/ out status /*[out] SrchStatus searchstatus*/ ); if (files != null) fileList.AddRange(files); } return fileList; }