Created
February 27, 2015 21:06
-
-
Save alex-wilmer/21e5db247fe593882447 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[WebMethod] | |
public static String GetTopDocuments(string SearchText, string RelativeSearchPath, string ResourceTypes, string LinkedListUrl, string Program) | |
{ | |
if (SPUtility.ValidateFormDigest()) | |
{ | |
string siteUrl = SPContext.Current.Site.Url; | |
if (!string.IsNullOrEmpty(Program)) | |
{ | |
Program = string.Format(@" Program:""{0}"" ", Program); | |
} | |
//for when pages can be searchable | |
string queryConstant = @"(path:""{0}{1}"" contenttype:""Halton Document"" {2} {3}) OR (contenttype:""Page"" {2} {3}) "; | |
string query = string.Format(queryConstant, siteUrl, RelativeSearchPath, ResourceTypes, Program); | |
if (!string.IsNullOrEmpty(LinkedListUrl)) | |
{ | |
query = "(" + query + @") OR (path:""" + LinkedListUrl + @"/DispForm.aspx*"" " + ResourceTypes + Program + " ) " + SearchText; | |
} | |
List<TopDocument> topDocuments = HaltonContext.GetTopDocuments(siteUrl, HaltonContext.Search(siteUrl, query)); | |
var jsonSerialiser = new JavaScriptSerializer(); | |
return jsonSerialiser.Serialize(topDocuments); | |
} | |
return "error"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment