Esempio n. 1
0
        /// <summary>
        /// runs the survey and handles the response
        /// </summary>
        /// <returns></returns>
        private void RunSurvey(SurveyMode mode)
        {
            try
            {
                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(
                                                          () =>
                {
                    var previousActiveWorkday = Queries.GetPreviousActiveWorkDay();

                    // if it's the first time the notification is shown
                    if (_currentSurveyEntry == null)
                    {
                        _currentSurveyEntry = new SurveyEntry();
                        _currentSurveyEntry.TimeStampNotification = DateTime.Now;
                        if (previousActiveWorkday > DateTime.MinValue)
                        {
                            _currentSurveyEntry.PreviousWorkDay = previousActiveWorkday;
                        }
                    }

                    // (re-)set the timestamp of filling out the survey
                    _currentSurveyEntry.TimeStampStarted = DateTime.Now;

                    // set previous entry to show previous entry time in popup
                    var popup = (mode == SurveyMode.IntervalPopUp)
                        ? (Window) new IntervalProductivityPopUp(Queries.GetPreviousIntervalSurveyEntry())
                        : (Window) new DailyProductivityPopUp(previousActiveWorkday);

                    // show popup & handle response
                    if (mode == SurveyMode.DailyPopUp &&
                        ((DailyProductivityPopUp)popup).ShowDialog() == true)
                    {
                        HandleDailyPopUpResponse((DailyProductivityPopUp)popup);
                    }
                    else if (mode == SurveyMode.IntervalPopUp &&
                             ((IntervalProductivityPopUp)popup).ShowDialog() == true)
                    {
                        HandleIntervalPopUpResponse((IntervalProductivityPopUp)popup);
                    }
                    else
                    {
                        // we get here when DialogResult is set to false (which never happens)
                        Database.GetInstance().LogErrorUnknown(Name);

                        // to ensure it still shows some pop-ups later
                        _timeRemainingUntilNextSurvey = PopUpIntervalInMins;
                    }
                }));
            }
            catch (ThreadAbortException e) { Database.GetInstance().LogError(Name + ": " + e.Message); }
            catch (Exception e) { Database.GetInstance().LogError(Name + ": " + e.Message); }
        }
Esempio n. 2
0
        /// <summary>
        /// runs the survey and handles the response
        /// </summary>
        /// <returns></returns>
        private void RunSurvey(SurveyMode mode)
        {
            try
            {
                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(
                () =>
                {
                    var previousActiveWorkday = Queries.GetPreviousActiveWorkDay();

                    // if it's the first time the notification is shown
                    if (_currentSurveyEntry == null)
                    {
                        _currentSurveyEntry = new SurveyEntry();
                        _currentSurveyEntry.TimeStampNotification = DateTime.Now;
                        if (previousActiveWorkday > DateTime.MinValue) _currentSurveyEntry.PreviousWorkDay = previousActiveWorkday;
                    }

                    // (re-)set the timestamp of filling out the survey
                    _currentSurveyEntry.TimeStampStarted = DateTime.Now;

                    // set previous entry to show previous entry time in popup
                    var popup = (mode == SurveyMode.IntervalPopUp)
                        ? (Window)new IntervalProductivityPopUp(Queries.GetPreviousIntervalSurveyEntry())
                        : (Window)new DailyProductivityPopUp(previousActiveWorkday);

                    // show popup & handle response
                    if (mode == SurveyMode.DailyPopUp
                        && ((DailyProductivityPopUp)popup).ShowDialog() == true)
                    {
                        HandleDailyPopUpResponse((DailyProductivityPopUp)popup);
                    }
                    else if (mode == SurveyMode.IntervalPopUp
                        && ((IntervalProductivityPopUp)popup).ShowDialog() == true)
                    {
                        HandleIntervalPopUpResponse((IntervalProductivityPopUp)popup);
                    }
                    else
                    {
                        // we get here when DialogResult is set to false (which never happens)
                        Database.GetInstance().LogErrorUnknown(Name);

                        // to ensure it still shows some pop-ups later
                        _timeRemainingUntilNextSurvey = PopUpIntervalInMins;
                    }
                }));
            }
            catch (ThreadAbortException e) { Database.GetInstance().LogError(Name + ": " + e.Message); }
            catch (Exception e) { Database.GetInstance().LogError(Name + ": " + e.Message); }
        }