示例#1
0
        /// <summary>
        /// Find the timestamp of the most recent record for each device.
        /// </summary>
        /// <returns>The high water mark.</returns>
        private DateTime getWeatherHighWaterMark()
        {
            Utils.Log("Getting high water mark for weather...");

            var mostRecent = ElasticUtils.getHighWaterMark <WeatherReading>(EsClient, settings.weatherUnderground.IndexName, null);

            if (mostRecent != null)
            {
                return(mostRecent.timestamp.AddSeconds(1));
            }

            return(new DateTime(2014, 1, 1, 0, 0, 0, DateTimeKind.Utc));
        }
示例#2
0
        /// <summary>
        /// Find the timestamp of the most recent record for each device.
        /// </summary>
        /// <returns>The high water mark.</returns>
        /// <param name="uuid">Device UUID</param>
        private DateTime getDeviceHighWaterMark(string uuid)
        {
            var query = new TermQuery {
                Field = "device.uuid.keyword", Value = uuid
            };

            Utils.Log("Getting high water mark for {0}...", uuid);

            var mostRecent = ElasticUtils.getHighWaterMark <SensorReading>(EsClient, settings.indexname, query);

            if (mostRecent != null)
            {
                if (mostRecent.device.uuid != uuid)
                {
                    throw new ArgumentException("High watermark returned for incorrect UUID!");
                }

                return(mostRecent.timestamp.AddSeconds(1));
            }

            return(new DateTime(2017, 1, 1, 0, 0, 0, DateTimeKind.Utc));
        }