/// <summary>
        /// Loop through insights JSON data, find insights field and submit it for processing into the database,
        ///     Each case determines if the point has a running total computed (running_total = true) and 
        ///     if the value is reported to the Awareness Map (geo_total = true)
        /// </summary>
        /// <param name="processFBRec">Delegate of processing method</param>
        /// <param name="json_insight">JSON insights data from Facebook</param>
        /// <param name="pull_date">Date and time this data was pulled from FB</param>
        private void processInsight(ProcessFBDelegate processFBRec, JObject json_insight, DateTime pull_date)
        {
            string name_token = "";
            string period = "";
            int i = 0;
            JArray insightArr = JArray.Parse(json_insight["insights"]["data"].ToString());

            List<Facebook_field> fb_fields = amDB.getInsightFields();

            foreach(JToken ins in insightArr) //for each insight field
            {
                name_token = ins["name"].ToString();
                period = ins["period"].ToString();
                var key = name_token + ":" + period;

                foreach (Facebook_field f in fb_fields) //for each insight field being collected.
                {
                    if (name_token == f.field_name && period == f.fetch_period)
                    {
                        if (period == "lifetime")
                            processFBRec(name_token, period, pull_date, ins, false, false);
                        else if (f.running_total == 1)
                            processFBRec(name_token, period, pull_date, ins, true, false);
                        else if (f.reporting_period == "day")
                            processFBRec(name_token, period, pull_date, ins, false, false);
                    }
                }
            }
        }
 /// <summary>
 /// Get FB historical data from files
 /// </summary>
 /// <param name="fileLocName">path and name of file containing FB insights data</param>
 public void getFBHistorical(String fileLocName)
 {
     //Read JSON file
     JObject json_insight = JObject.Parse(File.ReadAllText(fileLocName));
     ProcessFBDelegate pFBHist = new ProcessFBDelegate(processFBHistory);
     //ProcessFBDelegate pFBHist = new ProcessFBDelegate(processFBField);
     DateTime pull_date = DateTime.Now;
     processInsight(pFBHist, json_insight, pull_date);
     //processInsightNewPoints(pFBHist, json_insight, pull_date);
 }
        /// <summary>
        /// Get FB historical data from FB
        /// </summary>
        /// <param name="since">YYY-MM-DD string for start date</param>
        /// <param name="until">YYY-MM-DD string for end date</param>
        public void getFBHistorical(string since, string until)
        {
            Console.WriteLine("********** From " + since + " to " + until + " ************");
            Search searchChoreo = new Search(session);

            // Setup inputs for Temboo Facebook search
            searchChoreo.setObjectType("page");
            searchChoreo.setFields("insights.since("+since+").until("+until+")");
            searchChoreo.setAccessToken(accessToken);
            searchChoreo.setQuery("KeepItPumping");

            // Execute Choreo
            SearchResultSet searchResults = searchChoreo.execute();
            JObject json_insight = JObject.Parse(searchResults.Response);
            string name_token = (string)json_insight["data"][0]["insights"]["data"][0]["name"];
            json_insight = JObject.Parse(json_insight["data"][0].ToString());
            int i = 0;
            DateTime pull_date = DateTime.Now;

            // Set up call to historical processing
            ProcessFBDelegate pFBDel = new ProcessFBDelegate(processFBHistory);
            processInsight(pFBDel, json_insight, pull_date);
        }
        /// <summary>
        /// Request and retrieve insights data.
        ///     Get the page ID with the Temboo lookup service
        ///     Get the insights data with the Temboo GetObject service
        /// </summary>
        public void getFacebookData()
        {
            /*
            URLLookup uRLLookupChoreo = new URLLookup(session);

            // Set inputs
            uRLLookupChoreo.setAccessToken(accessToken);
            uRLLookupChoreo.setIDs(pageURL);

            // Execute Choreo
            URLLookupResultSet uRLLookupResults = uRLLookupChoreo.execute();

            // Print results
            //Console.WriteLine(uRLLookupResults.Response);
            string s_lookup = uRLLookupResults.Response;
            JObject json_lookup = JObject.Parse(s_lookup);

            string page_id = (string)json_lookup[pageURL]["id"];
            Console.WriteLine("page ID = " + page_id);

            GetObject getObjectChoreo = new GetObject(session);

            // Set inputs
            getObjectChoreo.setAccessToken(accessToken);
            getObjectChoreo.setFields("insights");
            getObjectChoreo.setObjectID(page_id);

            // Execute GetObject Choreo
            GetObjectResultSet getObjectResults = getObjectChoreo.execute();

            // Print results
            //Console.WriteLine(getObjectResults.Response);

            //Put results in JSON object
            JObject json_insight = JObject.Parse(getObjectResults.Response);
            string name_token = (string)json_insight["insights"]["data"][0]["name"];
            int i = 0;
            DateTime pull_date = DateTime.Now;
            */
            Search searchChoreo = new Search(session);

            // Setup inputs for Temboo Facebook search
            string since = DateTime.Now.AddDays(-5).ToString("yyyy-MM-dd");
            string until = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
            searchChoreo.setObjectType("page");
            searchChoreo.setFields("insights.since(" + since + ").until(" + until + ")");
            searchChoreo.setAccessToken(accessToken);
            searchChoreo.setQuery("KeepItPumping");

            // Execute Choreo
            SearchResultSet searchResults = searchChoreo.execute();
            JObject json_insight = JObject.Parse(searchResults.Response);
            string name_token = (string)json_insight["data"][0]["insights"]["data"][0]["name"];
            json_insight = JObject.Parse(json_insight["data"][0].ToString());
            int i = 0;
            DateTime pull_date = DateTime.Now;

            //Set up to call realtime processing
            ProcessFBDelegate pFBDel = new ProcessFBDelegate(processFBField);
            processInsight(pFBDel, json_insight, pull_date);

            //Console.WriteLine("found data = " + saved_fields);
        }