%@ Page language="c#" Codebehind="SimpleSearch.aspx.cs" AutoEventWireup="false" Inherits="PRCSearchPage.SimpleSearch" %>
Test Search Page
<%
//proceed if we have a search string
if (!(searchString.Equals("")))
{
%>
Search for cards containing '<%= searchString %>'
<%
//set the endpoint to the value of your web services server
String endpoint =
"http://IP-GW-AS08:9080/ptapi/services/QueryInterfaceAPI";
//set username and password to log into your portal
//hard-coding the values is only for demo purposes
String username = "Administrator";
String password = "";
//get a remote session
Plumtree.Remote.PRC.IRemoteSession prcSession =
Plumtree.Remote.PRC.RemoteSessionFactory.GetExplicitLoginContext(
new System.Uri(endpoint),
username,
password);
Plumtree.Remote.PRC.Search.ISearchFactory searchFactory = prcSession.GetSearchFactory();
Plumtree.Remote.PRC.Search.IPortalSearchRequest searchRequest = searchFactory.CreatePortalSearchRequest();
//if we have a date, make a filter statement
if (null != startDate && (!(startDate.Equals(""))))
{
DateTime createdDate = DateTime.Parse(startDate);
Plumtree.Remote.PRC.Search.IFilterClause filterClause = searchFactory.CreateAndFilterClause();
filterClause.AddStatement(Plumtree.Remote.PRC.Search.PlumtreeField.CREATED, Plumtree.Remote.PRC.Operator.GreaterThan, createdDate);
searchRequest.SetQuery(searchString, filterClause);
}
else
{
searchRequest.SetQuery(searchString);
}
//use 10 results at a time
searchRequest.SetResultsCount(startCount, 10);
Plumtree.Remote.PRC.Search.ISearchResponse searchResponse = searchRequest.Execute();
int numResults = searchResponse.GetReturnedCount();
int first_result = searchResponse.GetFirstResultIndex();
int totalMatches = searchResponse.GetTotalCount();
//print out overall info
Response.Write("
Overall Info
");
Response.Write("");
Response.Write("Total Matches: | " + totalMatches + " |
");
Response.Write("Number Returned: | " + numResults + " |
");
Response.Write("Warning: | " + searchResponse.GetWarning() + " |
");
Response.Write("First Result (0-based): | " + first_result + " |
");
Response.Write("
");
//print out results if we have them
if (numResults > 0)
{
Response.Write("Results
");
Response.Write("");
Plumtree.Remote.PRC.Search.ISearchResultSet resultSet = searchResponse.GetResultSet();
IEnumerator results = resultSet.GetResults();
//print values and put results into hashmap to obtain properties in a new window
Hashtable map = new Hashtable();
while (results.MoveNext())
{
Plumtree.Remote.PRC.Search.IPortalSearchResult result = (Plumtree.Remote.PRC.Search.IPortalSearchResult) results.Current;
map.Add("" + result.GetRank(), result);
//results are 0 based- but we present them here to the end-user as 1 based.
Response.Write("" + (startCount + result.GetRank() + 1) + " | ");
Response.Write(" + ") | ");
Response.Write("" + result.GetName() +" | ");
Response.Write("Properties | ");
Response.Write("
");
Response.Write("" + result.GetExcerpt() + " |
");
}//while (results.MoveNext())
Session["resultsMap"] = map;
}// if (numResults > 0)
Response.Write("
");
//print the links at the bottom up to 150 results
Response.Write("");
int total = 15;
if (totalMatches < 150)
{
if ((totalMatches % 10) == 0)
{
total = totalMatches / 10;
}
else
{
total = (totalMatches / 10) + 1;
}
}
int currentPos = first_result;
currentPos = (currentPos / 10) + 1;
Response.Write("");
Response.Write("");
for (int i = 1; i <= total; i++)
{
if (i == currentPos)
{
Response.Write(i);
}
else
{
Response.Write("");
Response.Write(i);
Response.Write("");
}
Response.Write(" ");
}
Response.Write(" | ");
Response.Write("
");
Response.Write("
");
}
%>