public MainViewModel() { logger.Info("Audio View started at {0}", DateTime.Now); SettingsViewModel = SettingsViewModel.Instance; HistoryViewModel = new HistoryViewModel(); MeasurementsViewModel = new MeasurementsViewModel(this); // Debug for me MeasurementsViewModel.NewViewModel = new NewMeasurementViewModel(MeasurementsViewModel); // Load offline files DataStorageMeterListener.UploadLocalFiles(); }
public MainViewModel() { ShowControls = false; logger.Info("Audio View started at {0}", DateTime.Now); SettingsViewModel = SettingsViewModel.Instance; HistoryViewModel = new HistoryViewModel(); MeasurementsViewModel = new MeasurementsViewModel(this); service = new UserService(); User user = getAuthData(); if (user == null) { NeedLogIn = true; LogInFailed = false; LogInExpired = false; ShowControls = false; } else { // Verify expired try { //var audioViewEntities = new AudioViewEntities(); //audioViewEntities.Users.Where(x => x.username == "kasper").First(); var userResult = service.GetUserSync(user.UserName); if (userResult == null) { NeedLogIn = true; LogInFailed = true; LogInExpired = false; ShowControls = false; IsLoading = false; } else { if (user.Expires != null && userResult.Expires < DateTime.Now) { NeedLogIn = true; LogInFailed = false; LogInExpired = true; ShowControls = false; IsLoading = false; } else { NeedLogIn = false; LogInFailed = false; LogInExpired = false; ShowControls = true; IsLoading = false; } } } catch (Exception exp) { logger.Error(exp); if (user.Expires != null && user.Expires < DateTime.Now) { NeedLogIn = true; LogInFailed = true; LogInExpired = false; ShowControls = false; IsLoading = false; } else { // Allow user in NeedLogIn = false; LogInFailed = false; LogInExpired = false; ShowControls = true; IsLoading = false; } } } // Debug for me MeasurementsViewModel.NewViewModel = new NewMeasurementViewModel(MeasurementsViewModel); // Load offline files DataStorageMeterListener.UploadLocalFiles(); }