/// <summary>
/// import profile pic from
pubhub to root site
/// </summary>
/// <param name="searchQuery"></param>
/// <returns></returns>
public static bool ImportContacts(string
searchQuery)
{
var searchDt = new DataTable(); bool
isImport = false;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SearchServiceApplicationProxy proxy =
SearchServiceApplicationProxy.GetProxy(
SPServiceContext.GetContext(SPContext.Current.Site)) as
SearchServiceApplicationProxy;
if (proxy == null)
throw new ArgumentNullException("SearchServiceApplicationProxy
is null");
var keywordQuery = new KeywordQuery(proxy)
{
ResultsProvider = SearchProvider.Default,
ResultTypes = ResultType.RelevantResults,
TrimDuplicates = false,
HiddenConstraints = "scope:\"MyContacts\"",
RowLimit = 500
};
keywordQuery.SelectProperties.Add("Title");
keywordQuery.SelectProperties.Add("Path");
keywordQuery.SelectProperties.Add("PictureThumbnailURL");
keywordQuery.SelectProperties.Add("PicOwner");
keywordQuery.SelectProperties.Add("PicOwnerEmail");
ResultTableCollection
fullTextSearchResults = keywordQuery.Execute();
if (fullTextSearchResults.Exists(ResultType.RelevantResults))
{
ResultTable searchResult =
fullTextSearchResults[ResultType.RelevantResults];
searchDt.Load(searchResult, LoadOption.OverwriteChanges);
if
(searchDt.Rows.Count > 0)
{
//insert data to list
insertToRootList(searchDt);
isImport = true;
}
}
}); return
isImport;
}
No comments:
Post a Comment