示例#1
0
        /// <summary>
        /// Constructor which initializes properties and using input surveyId like ID of survey.
        /// </summary>
        /// <param name="surveyId">ID of survey.</param>
        public SurveyViewModel(string surveyId)
        {
            ListOfResults = new ObservableCollection <ResultBasicInfo>();
            _operations   = new OperationsOnListOfResults(surveyId, ListOfResults);
            SurveyId      = surveyId;
            ProgressBar   = new ProcessingBar();
            Message       = new DialogBox();
            _resultSender = new SendResult();
            _resultSender.SendingCompleted += (object sender, EventArgs args) =>
            {
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    SendResult.SendingEventArgs.SendingStatus status = (args as SendResult.SendingEventArgs).Status;
                    string resultId = (args as SendResult.SendingEventArgs).ResultId;
                    switch (status)
                    {
                    case Model.SendResult.SendingEventArgs.SendingStatus.Sent:
                        Message.Show(Languages.AppResources.surveyViewModel_sendingCompleted);
                        _operations.MarkResultAsSent(resultId);
                        break;

                    case Model.SendResult.SendingEventArgs.SendingStatus.ServerError:
                        Message.Show(Languages.AppResources.surveyViewModel_serverError);
                        break;

                    case Model.SendResult.SendingEventArgs.SendingStatus.UnknownError:
                        Message.Show(Languages.AppResources.surveyViewModel_unknownError);
                        break;

                    case Model.SendResult.SendingEventArgs.SendingStatus.Canceled:
                        break;
                    }

                    ProgressBar.IsEnabled = false;
                    SendingInProgress     = false;
                });
            };
        }