Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. [WebMethod]
  2. public static String GetTopDocuments(string SearchText, string RelativeSearchPath, string ResourceTypes, string LinkedListUrl, string Program)
  3. {
  4. if (SPUtility.ValidateFormDigest())
  5. {
  6. string siteUrl = SPContext.Current.Site.Url;
  7.  
  8. if (!string.IsNullOrEmpty(Program))
  9. {
  10. Program = string.Format(@" Program:""{0}"" ", Program);
  11. }
  12.  
  13. //for when pages can be searchable
  14. string queryConstant = @"(path:""{0}{1}"" contenttype:""Halton Document"" {2} {3}) OR (contenttype:""Page"" {2} {3}) ";
  15. string query = string.Format(queryConstant, siteUrl, RelativeSearchPath, ResourceTypes, Program);
  16.  
  17. if (!string.IsNullOrEmpty(LinkedListUrl))
  18. {
  19. query = "(" + query + @") OR (path:""" + LinkedListUrl + @"/DispForm.aspx*"" " + ResourceTypes + Program + " ) " + SearchText;
  20. }
  21.  
  22. List<TopDocument> topDocuments = HaltonContext.GetTopDocuments(siteUrl, HaltonContext.Search(siteUrl, query));
  23.  
  24. var jsonSerialiser = new JavaScriptSerializer();
  25. return jsonSerialiser.Serialize(topDocuments);
  26. }
  27. return "error";
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement