2

I want to display the components modified by particular user using core service for which I m using SearchQueryData filter. I m getting the list of modified components but details of user who last modified the component is missing. For getting these details I m iterating through each item and getting the Version history but doing this way degrades the performance.

Here is the code:

            //search query 
            SearchQueryData filter = new SearchQueryData();
            filter.ModifiedAfter = fromDate;
            filter.ModifiedBefore = toDate;
            filter.ItemTypes = new ItemType[]
            {
                ItemType.Component,
                ItemType.ComponentTemplate,
                ItemType.Page,
                ItemType.PageTemplate,
                ItemType.Publication,
                ItemType.Schema
            };

            filter.BlueprintStatus = SearchBlueprintStatus.Unspecified;
            filter.SearchIn = new LinkToIdentifiableObjectData { Title = publicationId };

            //returns the list of items changed by date
            IdentifiableObjectData[] dataModified = client.GetSearchResults(filter);
            List<IdentifiableObjectData> modifiedData_User = new List<IdentifiableObjectData>();

            //iterate through each item and get the details of the user who modified this item
            foreach (var d in dataModified)
            {
                VersionsFilterData versionsFilter = new VersionsFilterData();
                versionsFilter.IncludeRevisorDescriptionColumn = true;
                IdentifiableObjectData versionList = client.GetList(d.Id, versionsFilter).Last();
                var versionInfo = (FullVersionInfo)versionList.VersionInfo;
                LinkToUserData revisor = versionInfo.Revisor;
                if (revisor.Title.ToLower() == username.ToLower())
                    modifiedData_User.Add(d);
            }

1) Can I get the details of user who modified the component using SearchQueryDataFilter so that I dont have to iterate through the result. 2) Is there any better way through which this can be achieved.

1 Answer 1

1

There is a SearchQueryData.Author Property used to set the author to search for. Did you try that? I can't test it running the code now, so can't confirm.

Update: using SearchQueryData.Author Property, The results will return items created by the specified author. So I guess you are doing it rightly looping over the results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.