About      |       Articles      |      Services      |      Software      |      Contact

Latest Free SharePoint Software

ARB Security Solutions regularly releases free SharePoint software, including WebParts, Client Applications, Framework Extensions, and other Miscellaneous Components.
The most recent freeware is:

Title: Simple SharePoint Rollup WebPart
Date Published: 10/22/2009

Previous Two Free WebPart Releases:

SecureCenter For SharePoint

By SharePoint security integrators, for SharePoint security integrators.

SharePoint Security Assurance Program™

For externally facing SharePoint deployments, security is an acutely important deployment concern. Learn how through daily security scanning, you can ensure external business users and partners that they can collaborate in confidence!

Security Assurance WebPart:



Using the KeywordQuery Class to Get a List of Department Employees

Along the same lines as this post, once one has located the relevant department that they desire from a collection, how is it possible to use that department string name in order to get a list of the relevant employees? As we used the KeywordQuery class the last time, we are going to take the same approach in order to return a new DataTable with those values.

Here is the code in order to execute that:

C#:
  1. public static DataTable BuildDepartmentEmployees(string url, string deptName, int queryLimit)
  2. {
  3. using (var resultĀ  = new DataTable())
  4. {
  5. using (var site = new SPSite(url))
  6. {
  7. using (var query = new KeywordQuery(site))
  8. {
  9. query.ResultTypes = ResultType.RelevantResults;
  10. query.EnableStemming = true;
  11. query.TrimDuplicates = true;
  12. query.StartRow = 0;
  13. query.RowLimit = queryLimit;
  14. string str =
  15. query.QueryText = string.Format("scope:\"{0}\"", "people") + string.Format(" department:\"{0}\"", deptName);
  16. query.SortList.Add("Rank", SortDirection.Ascending);
  17. query.SelectProperties.Add("AccountName");
  18. query.SelectProperties.Add("FirstName");
  19. query.SelectProperties.Add("LastName");
  20. query.SelectProperties.Add("JobTitle");
  21. query.SelectProperties.Add("WorkEmail");
  22. query.SelectProperties.Add("Department");
  23. query.SelectProperties.Add("WorkPhone");
  24. query.SelectProperties.Add("Fax");
  25. query.SelectProperties.Add("UserProfile_GUID");
  26. query.SelectProperties.Add("UserName");
  27. query.SelectProperties.Add("PreferredName");
  28. query.SelectProperties.Add("OfficeNumber");
  29. query.SelectProperties.Add("MobilePhone");
  30. query.SelectProperties.Add("PIctureURL");
  31. query.SelectProperties.Add("WebSite");
  32. query.SelectProperties.Add("PublicSiteRedirect");
  33. using (ResultTable reader = query.Execute()[ResultType.RelevantResults])
  34. {
  35. result.Load(reader, LoadOption.OverwriteChanges);
  36. }
  37. }
  38. }
  39. return result;
  40. }
  41. }

  • Share/Bookmark

1 Comment »

  1. [...] Using the KeywordQuery Class to Get a List of Department Employees (Adam Buenz)Along the same lines as this post, once one has located the relevant department that they desire from a collection, how is it possible to use that department string name in order to get a list of the relevant employees? As we used the KeywordQuery class the last time, we are going to take the same approach in order to return a new DataTable with those values. [...]

    Pingback by SharePoint Daily for November 10, 2008 - SharePoint Daily — November 10, 2008 @ 8:39 am

RSS feed for comments on this post. TrackBack URL

Leave a comment