コード例 #1
0
        public void addValue(DateTime timestamp, String field, Object value)
        {
            if (!_data.ContainsKey(timestamp))
            {
                // No value for this timestamp
                var obj = new TimeSeriesDataObject();

                obj.addValue(field, value);

                _data[timestamp] = obj;
            } else
            {
                // Existing value for this timestamp
                var obj = _data[timestamp];

                // Watch for the field already existing
                // at this point in time
                try
                {
                    obj.addValue(field, value);
                } catch (NonUniqueFieldIDException e)
                {
                    Console.WriteLine("Field ID: " + field + " already exists at: "
                        + timestamp.ToString(TIMESTAMP_FORMAT));
                }
            }
        }
コード例 #2
0
        public void addTimestampValues(DateTime timestamp, TimeSeriesDataObject timeData)
        {
            DateTime delocalized;


            // Delocalize timestamp, if it's not already UTC
            if (timestamp.Kind != DateTimeKind.Utc)
            {
                // DateTimeKind.Local or DateTimeKind.Unspecified
                delocalized = TimeZoneInfo.ConvertTime(timestamp, _feedTimeZone, TimeZoneInfo.Utc);
            }
            else
            {
                delocalized = timestamp;
            }

            // Stringify timestamps.. basically
            String delocalizedStr = delocalized.ToString(TIMESTAMP_FORMAT);

            // Try adding the data point to the current message
            bool accepted = _currentMessage.addData(
                delocalizedStr,
                timeData);

            if (!accepted)
            {
                // Current message is full!

                // Create new message
                _currentMessage = new NgestMessage(NgestMessage.TIMESERIES_TYPE, _feedKey);

                // Add data.. no way for this to fail
                _currentMessage.addData(delocalizedStr, timeData);

                // Add to messages list
                _messages.Add(_currentMessage);
            }
        }