Example #1
0
        public async Task RefreshDataAsync(bool forceRefresh)
        {
            if (IsBusy || (!forceRefresh && PlotModels.Count > 0))
            {
                return;
            }

            IsBusy = true;

            try
            {
                PlotModels.Clear();
                IReadOnlyList <MeasurementHistory> history = null;

                try
                {
                    history = await _historyDataService.GetAllDataAsync(forceRefresh);
                }
                catch (DataNotFoundException)
                {
                    // TODO: if data id is empty, show message to user
                }

                foreach (var measurement in SelectedLocation)
                {
                    var historyItem = history.FirstOrDefault(h => h.SensorDeviceId.Equals(measurement.SensorDeviceId, StringComparison.OrdinalIgnoreCase) && h.SensorId.Equals(measurement.SensorId));
                    if (historyItem == null)
                    {
                        continue;
                    }

                    PlotModels.Add(GraphModel.GetPlotModel(historyItem, measurement.SensorClass, measurement.SensorName));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     DataContext = new PlotModels();
     MainFrame.Navigate(new SelectPlots());
 }