Exemplo n.º 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;
                });
            };
        }
Exemplo n.º 2
0
        /// <summary>
        /// Default constuctor which initializes component on page.
        /// </summary>
        public FilterListPage()
        {
            _filterViewModel = new ResultsFilterViewModel();
            InitializeComponent();
            BusyIndicator.DataContext = _filterViewModel.ProgressBar;
            ListOfSurveys.ItemsSource = App.AppDictionary["FilteredResults"] as ObservableCollection <ResultsFilter.GroupedOC <ResultBasicInfo> >;
            _filterViewModel.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:
                        MessageBox.Show(Languages.AppResources.surveyViewModel_sendingCompleted);
                        _filterViewModel.Operations.MarkResultAsSent(resultId);
                        _filterViewModel.Filter.ReloadResult(resultId);
                        break;

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

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

                    case Model.SendResult.SendingEventArgs.SendingStatus.Canceled:
                        break;
                    }
                    _filterViewModel.ProgressBar.IsEnabled = false;
                    _filterViewModel.IsSending             = false;
                });
            };
            BuildApplicationBar();
        }