Hello,
I try to use this command but i always receive 0 result.
I have somme Custom Entities and for each i have somes files linked.
With the GetLinksByParentIds command, i have a list of links, so i extract the long[] from this list.
After i try to search in this list with somes personnal properties.
this is my code:
long
TDPNUMBERid = myuser.getPropertyId("TDP Number", filePropDefs);
List<FileElementSrchCondition> myList = newList<FileElementSrchCondition>();
FileElementSrchCondition cond1 = newFileElementSrchCondition()
{
FileElementPropDefId = TDPNUMBERid.ToString(),
Oper =
SearchOperator.Contains,
Val = DocNo
};
myList.Add(cond1);
FileElementSrchClause myFileElemSrchClause = newFileElementSrchClause()
{
CondArray=myList.ToArray(),
Rule=
SearchRule.Must
};
Lnk[] wsLnksList = myuser.userConnection.WebServiceManager.DocumentService.GetLinksByParentIds(newlong[]{myuser.getWSCustomEntityID(myws)},newstring[]{"FILE"});
long[] idsList = (from l in wsLnksList
select l.ToEntId).ToArray();
int bookmark=0;
int _totalhits;
FileElement[] test11 = myuser.userConnection.WebServiceManager.DocumentServiceExtensions.FindFileElementsBySearchClause(myFileElemSrchClause, ref bookmark, condition, idsList, null, out _totalhits);
where condition is a file search condtion array.
I don't understand what i have to define in FileElementSrchClause?
Can somebody help me?
Thanks.
hi,
have you tried to use FindFilesBySearchConditions instead?
Here is a smal code snippet of my wrapped search function that should work in your case.
public IEnumerable<Autodesk.Connectivity.WebServices.File> SearchFiles(IEnumerable<SrchCond> conditions,IEnumerable<SrchSort> sorts, int quantity)
{
var srcSorts = new List<SrchSort>();
string bookmark = string.Empty;
SrchStatus status = null;
var results = new List<Autodesk.Connectivity.WebServices.File>();
while (status == null || results.Count < status.TotalHits)
{
try
{
var result = WebServiceManager.DocumentService.FindFilesBySearchConditions(conditions.ToArray(), srcSorts.ToArray(), new[] { RootFolder.Id }, true, true, ref bookmark, out status);
if (result == null)
break;
results.AddRange(result);
if (results.Count >= quantity)
break;
}
catch (Exception ex)
{
}
}
return results.Take(quantity);
}
Just call it with a new SrchCond similar as your FileElementSrchCondition.
(If this answer helped solving your problem, please mark as solved)