Ejemplo n.º 1
0
        /// <summary>
        /// Gets the time series.
        /// </summary>
        /// <returns>The time series.</returns>
        ///
        public CTimeSeries GetTimeSeries(CTimeSeriesRequest Request)
        {
            var Result = QueryTimeSeries(Request.GetURL());

            var Json = Result.Result;

            //Console.WriteLine(Json);

            CTimeSeriesFromJson Deserialized = null;

            if (Json != null)
            {
                // Remove some text to make it easier for the JSON parser.

                Json = Json.Replace("{\"dataset_data\":", "");

                Json = Json.Remove(Json.Length - 1);

                Deserialized = JsonConvert.DeserializeObject <CTimeSeriesFromJson>(Json);
            }

            if (Deserialized == null)
            {
                return(new CTimeSeries(Request));
            }
            else
            {
                return(SCTimeSeriesUtilities.ConvertToTimeSeries(Deserialized, Request));
            }
        }
        internal static CTimeSeries ConvertToTimeSeries(CTimeSeriesFromJson FromJson, CTimeSeriesRequest Request)
        {
            CTimeSeries Result = new CTimeSeries(Request);

            // Setup the meta data if any.
            Result.Meta = ConvertToMeta(FromJson);

            // Handle the data
            // We create a CTimeSeriesData object foreach list.
            foreach (var TheList in FromJson.data)
            {
                //SCListUtilities.Print<string>(TheList);

                Result.Data.Add(SCTimeSeriesUtilities.ParseFromStringList(TheList));
            }

            return(Result);
        }