Ejemplo n.º 1
0
        public async Task UpdateItems()
        {
            if (LastTimestamps.Count > countOfRecordsToStore)
            {
                FlushOldRecords();
            }

            bool updateResult = await DataParser.UpdateData();

            if (updateResult)
            {
                var timestampToAdd = await DataParser.GetTimestamp();

                var dataToProcess = DataParser.FetchNumericData();
                if (timestampToAdd != null || dataToProcess.Count != 0)
                {
                    LastTimestamps.Add((DateTime)timestampToAdd);
                    foreach (var item in dataToProcess)
                    {
                        var key   = item.Key;
                        var value = item.Value;
                        if (Measures.ContainsKey(key))
                        {
                            Measures[key].LastMeasures.Add(value);
                        }
                        else
                        {
                            var measureToAdd = IDataItem.ReturnDataItem(key, firstValue: value);
                            Measures.Add(key, measureToAdd);
                        }
                    }

                    CreatePlots();
                }
            }
        }