예제 #1
0
        private static async Task <bool> WriteDataAsync(string baseId, Forecast data)
        {
            try
            {
                // Write current value
                var id          = $"{baseId}.forecast.current";
                var description = $"Forecast current value for {baseId}";
                var stream      = await SdsHelper.GetOrCreateTypeAndStreamAsync <ForecastCurrent>(id, description);

                if (stream != null)
                {
                    await SdsHelper.dataService.UpdateValueAsync <ForecastCurrent>(stream.Id, data.Current);
                }

                id          = $"{baseId}.forecast.daily";
                description = $"Forecast daily value for {baseId}";
                stream      = await SdsHelper.GetOrCreateTypeAndStreamAsync <ForecastDaily>(id, description);

                if (stream != null)
                {
                    foreach (var item in data.Daily)
                    {
                        await SdsHelper.dataService.UpdateValueAsync(stream.Id, item);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #2
0
        private static async Task <bool> WriteDataAsync(string id, WeatherStation data)
        {
            try
            {
                var description = "Snapshot values for ${id}";
                var stream      = await SdsHelper.GetOrCreateTypeAndStreamAsync <WeatherStation>(id, description);

                //Write data
                if (stream != null)
                {
                    await SdsHelper.dataService.UpdateValueAsync <WeatherStation>(stream.Id, data);
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }