Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FindFileElementsBySearchClause command

1 REPLY 1
Reply
Message 1 of 2
o-fischer
382 Views, 1 Reply

FindFileElementsBySearchClause command

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.

 

1 REPLY 1
Message 2 of 2
martin.weiss
in reply to: o-fischer

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)

Best Regards
Martin

coolOrange
www.coolorange.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report