Exemplo n.º 1
0
 /// <summary>
 /// Makes a query to SummonJson and returns dynamic objects to use in the Razor macro engine.
 /// </summary>
 /// <param name="queryString">Search string in Summon URL format</param>
 /// <param name="sessionId">Session Id from Summon API</param>
 /// <returns>Dynamic object with result documents for use in Razor</returns>
 public static dynamic GetItems(string queryString, string sessionId)
 {
     // queryString = ParseQueryString(queryString);
     var summon = new SummonJson(ApiId, ApiKey);
     var result = String.IsNullOrEmpty(sessionId) ? summon.Query(queryString) : summon.Query(queryString, sessionId);
     var sb = new StringBuilder("[" + result + "]");
     var dynamicObject = Json.Decode(sb.ToString());
     Log.Info("queryString " + queryString);
     if (dynamicObject[0].recordCount != null)
     {
         Log.Info("recordCount " + dynamicObject[0].recordCount + " totalRequestTime " + dynamicObject[0].totalRequestTime);
     }
     else
     {
         Log.Info("No results in JSON response.");
     }
     return dynamicObject;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Makes a query to SummonJson and returns a string containing the raw JSON data.
 /// </summary>
 /// <param name="queryString">Search string in Summon URL format</param>
 /// <param name="sessionId">Session Id from Summon API</param>
 /// <returns>JSON result</returns>
 public static string GetItemsAsJsonString(string queryString, string sessionId)
 {
     queryString = ParseQueryString(queryString);
     var summon = new SummonJson(ApiId, ApiKey);
     var result = String.IsNullOrEmpty(sessionId) ? summon.Query(queryString) : summon.Query(queryString, sessionId);
     return result;
 }