Ejemplo n.º 1
0
        public string CreateTestData()
        {
            if (!Request.IsLocal)
            {
                throw new HttpException(401, "Unauthorized access");
            }

            var stationId  = "myTestStation";
            var sensorType = "Temperature";
            var startTime  = new DateTime(2016, 1, 1);

            _repository.DeleteAllByStationId(stationId);

            var points = Enumerable
                         .Range(1, 5000)
                         .Select(i => new DataPoint
            {
                ReceivedTimestampUtc = DateTime.UtcNow,
                SensorTimestampUtc   = startTime + TimeSpan.FromMinutes(15 * i),
                SensorType           = sensorType,
                StationId            = stationId,
                SensorValueNumber    = ToSensorValue(i)
            });

            foreach (var dataPoint in points)
            {
                _repository.Save(dataPoint);
            }

            return("OK");
        }
Ejemplo n.º 2
0
        public string AddDataPoints(AddDataPointsRequest dataPointsRequest)
        {
            if (dataPointsRequest == null)
            {
                return("no dataPointsRequest");
            }

            if (dataPointsRequest.DataPoints == null)
            {
                return("no dataPointsRequest.DataPoints");
            }

            foreach (var dataPoint in dataPointsRequest.DataPoints)
            {
                Debugger.Log(0, "", $"{dataPoint.SensorValueNumber}{Environment.NewLine}");

                _repository.Save(CreateDataPointRepositoryDto(dataPoint, DateTime.UtcNow));
            }

            return("OK");
        }
Ejemplo n.º 3
0
        public void SaveAndLoad()
        {
            var dataPoint = new DataPoint
            {
                ReceivedTimestampUtc = new DateTime(2001, 2, 3, 4, 5, 6),
                SensorTimestampUtc   = new DateTime(2001, 2, 3, 4, 5, 6),
                SensorType           = "MyTestSensor",
                StationId            = "MyStationId"
            };

            _repository.Save(dataPoint);

            var allValues = _repository.FindAll();

            allValues.Should().HaveCount(1);
        }