Esempio n. 1
0
        /// <summary>
        /// Query the next result
        /// </summary>
        /// <returns>the JsonObject of the next result</returns>
        public string getNextResult()
        {
            //this one is tricky, it gets the next jsob object to draw,
            //if we're querying with a result set
            //string temp="";
            if (curResultSet2.Count > 0)
            {
                //temp = curResultSet2[0];
                //curResultSet2.RemoveAt(0);
                //return temp;


                temp = curResultSet2[0];
                curResultSet2.RemoveAt(0);

                //making sure it's unique
                foreach (string t in uniqueJsonObjects)
                {
                    if (temp.Equals(t))
                    {
                        return("");
                    }
                }
                //adding it to the list if it's unique
                uniqueJsonObjects.Add(temp);
                //returning it
                return(temp);
            }
            //else we need to get a new resultset
            else
            {
                //inner results to execute queries to
                List <ResSetToJSON.innerResult> results = new List <ResSetToJSON.innerResult>();

                //the query gets processed and the query is removed from the query list till it's empty
                if (generatedQueriesList != null && generatedQueriesList.Count > 0)
                {
                    //making the nextQuery
                    startConnection();
                    results = QueryProcessor.ExecuteQueryWithInnerQuery(generatedQueriesList[0], obj1, obj2);
                    closeConnection();

                    //removing the query done from the list
                    generatedQueriesList.RemoveAt(0);

                    //generating the JsonObj
                    curResultSet2 = ResSetToJSON.ToListOfJsonObj(results);


                    getNextResult();
                }

                else
                {
                    //termenating
                    isEndOfResults = true;
                    return("");
                }
            }
            return(temp);
        }
        /// <summary>
        /// helper function to manage the changes of the queries first and last objects
        /// </summary>
        /// <param name="temp">the innerResult object ot set it's first and last object</param>
        /// <param name="input">the query string</param>
        /// <returns></returns>
        private static ResSetToJSON.innerResult setOriginalObjects(ResSetToJSON.innerResult temp, string input)
        {
            //List<string> urls = new List<string>();
            string one="";
            string two="";
            MatchCollection mc = Regex.Matches(input, @"\<(.*?)\>", RegexOptions.IgnoreCase);
            one = mc[0].Value.Replace("<", "");
            temp.firstObj = one.Replace(">", "");

            two = mc[1].Value.Replace("<", "");
            temp.lastObj = two.Replace(">", "");

            return temp;
        }