/// <summary> /// handler to postpone the survey for the selected time /// Hint: the selected time (e.g. postpone 1 hour) equals 1 hour of computer running (i.e. developer working) time /// </summary> /// <param name="notify"></param> private void PostponeIntervalSurvey(IntervalProductivityPopUp notify) { switch (notify.PostPoneSurvey) { case (PostPoneSurvey.Postpone1): _timeRemainingUntilNextSurvey = Settings.IntervalPostponeShortInterval; // set new interval break; case (PostPoneSurvey.Postpone2): _timeRemainingUntilNextSurvey = TimeSpan.FromHours(1); // in one hour break; case (PostPoneSurvey.Postpone3): _timeRemainingUntilNextSurvey = TimeSpan.FromHours(6); // in one workday //var now = DateTime.Now; //var nextDay = now.AddDays(1).Date.AddHours(8); //next day at 8 o'clock //var totalHours = (nextDay - now).TotalHours; //_timeRemainingUntilNextSurvey = TimeSpan.FromHours(totalHours); break; default: _timeRemainingUntilNextSurvey = Settings.IntervalPostponeShortInterval; // set new interval break; } }
/// <summary> /// Saves the interval-survey results in the db & resets some items /// </summary> /// <param name="popup"></param> private void SaveIntervalSurvey(IntervalProductivityPopUp popup) { _timeRemainingUntilNextSurvey = PopUpIntervalInMins; // set new default interval _currentSurveyEntry.Productivity = popup.UserSelectedProductivity; _currentSurveyEntry.TimeStampFinished = DateTime.Now; Queries.SaveIntervalEntry(_currentSurveyEntry); _currentSurveyEntry = null; // reset }
/// <summary> /// handles the response to the interval popup /// </summary> /// <param name="popup"></param> private void HandleIntervalPopUpResponse(IntervalProductivityPopUp popup) { // user took the survey || user didn't work if ((popup.UserSelectedProductivity >= 1 && popup.UserSelectedProductivity <= 7) || popup.UserSelectedProductivity == -1) { SaveIntervalSurvey(popup); } // user postponed the survey else if (popup.PostPoneSurvey != PostPoneSurvey.None) { PostponeIntervalSurvey(popup); Database.GetInstance().LogInfo(string.Format(CultureInfo.InvariantCulture, "The participant postponed the interval-survey ({0}).", popup.PostPoneSurvey)); } // something strange happened else { _currentSurveyEntry = null; _timeRemainingUntilNextSurvey = Settings.IntervalPostponeShortInterval; } }