Пример #1
0
        private void SetValues()
        {
            // if there isn't a current activity that's not done, check if there is an incomplete activity in the DB
            if (_currentOutsideActivity == null || _currentOutsideActivity.OutsideActivityId == 0)
            {
                _currentOutsideActivity = _dataService.GetLatestOutsideActivity();
            }

            // reset the chronometer and views
            // if last activity in DB is not done and is tracking, check if user
            // wants to save, discard, or continue tracking the activity.
            if (_currentOutsideActivity != null && (_currentOutsideActivity.IsTracking || !(_currentOutsideActivity.Done)))
            {
                _checkInterruptedActivity();
            }
            else
            {
                SetSaveActivityView();
            }

            // see if the db has any users
            // start with last user to have an activity
            // if there is no previous user, get the default user
            // if there is no default user and there are no users, create a default user
            if (_currentUser == null || _currentUser.UserId == 0)
            {
                try
                {
                    //_dataService.deleteAllUsers();
                    _currentUser = _dataService.GetDefaultUser();
                }
                catch (System.NullReferenceException)
                {
                    _currentOutsideActivity.UserId = _dataService.CreateUser(_currentUser);
                }
            }
        }