Example #1
0
        public async void OnLogin()
        {
            if (this.IsBusy == true)
            {
                // Исключить повторную авторизации
                return;
            }

            if (!CheckUserInput())
            {
                return;
            }

            try
            {
                this.IsBusy = true;

                bool acceptSsl = sslSwitch.IsToggled;

                await App.Core.Connect(serverAddressInput.Text, loginInput.Text, passwordInput.Text, acceptSsl);

                this.IsBusy = false;

                SuccessLogin?.Invoke(this, EventArgs.Empty);
            }
            catch (Exception exc)
            {
                BugReportService.HandleException(Droid.Resources.Messages.LoginPage_Error_Connect_to_Server, exc.Message, exc);
            }
            finally
            {
                this.IsBusy = false;
            }
        }
Example #2
0
        protected override async void OnAppearing()
        {
            if (!string.IsNullOrEmpty(AppDataStorage.Uri) && !string.IsNullOrEmpty(AppDataStorage.Token))
            {
                this.IsBusy = true;
                this.onLoginButton.IsEnabled = false;

                try
                {
                    // Скрываем логин и пароль, так как мы входим по токену.
                    ShowPasswordControls(false);

                    await this.coreService.ConnectToken(AppDataStorage.Uri, AppDataStorage.Token);

                    SuccessLogin?.Invoke(this, EventArgs.Empty);
                }
                catch (Exception exc)
                {
                    // Произошла ошибка входа, попробуем войти с помощью логина и пароля.

                    ShowPasswordControls(true);

                    BugReportService.HandleException(Droid.Resources.Messages.LoginPage_Error_Connect, exc.Message, exc);
                }
                finally
                {
                    this.IsBusy = false;
                    this.onLoginButton.IsEnabled = true;
                }
            }
        }
Example #3
0
File: test.cs Project: mono/gert
	static void RunBugReportService ()
	{
		for (int i = 0; i < iterationsPerThread; i++) {
			try {
				using (BugReportService service = new BugReportService ()) {
					service.Connect ("google.com", 80);
				}
			} catch (Exception ex) {
				Console.WriteLine (ex.ToString ());
				errorCount++;
			}
		}
	}
Example #4
0
        public async Task Reload(bool isForce = false)
        {
            try
            {
                Reports.Clear();

                List <ReportView> reportsAll = new List <ReportView>();

                foreach (var measurePointView in MeasurePointViews)
                {
                    var requiredFlags = MeasurePointInfoFlags.Reports;

                    if (!measurePointView.MeasurePoint.AvailableInfo.HasFlag(requiredFlags) || isForce == true)
                    {
                        await measurePointView.MeasurePoint.RefreshAsync(requiredFlags);
                    }

                    foreach (var report in measurePointView.MeasurePoint.Reports)
                    {
                        ReportView reportView = new ReportView(report.Report);
                        reportsAll.Add(reportView);
                    }
                }

                foreach (ReportGroupType type in (ReportType[])Enum.GetValues(typeof(ReportGroupType)))
                {
                    var list = reportsAll.Where(x => x.GroupType == type);

                    if (list.Count() > 0)
                    {
                        ReportsView item = new ReportsView(list.First().GroupType,
                                                           list.First().GroupTypeDescription);

                        foreach (var element in list)
                        {
                            if (item.Where(x => x.Id == element.Id).Count() == 0)
                            {
                                item.Add(element);
                            }
                        }

                        Reports.Add(item);
                    }
                }
            }
            catch (Exception exc)
            {
                BugReportService.HandleException(Droid.Resources.Messages.Text_Error, exc.Message, exc);
            }
        }
        internal async Task MarkAsReadAsync()
        {
            try
            {
                await this.Notification.MarkAsReadAsync();

                OnPropertyChanged(nameof(BackgroundColor));
                OnPropertyChanged(nameof(FontAttribute));
            }
            catch (Exception exc)
            {
                BugReportService.HandleException(Droid.Resources.Messages.Text_Error, exc.Message, exc);
            }
        }
        /// <summary>
        /// Загружает список нештатных ситуаций.
        /// </summary>
        /// <returns></returns>
        private async Task LoadIncidents()
        {
            string message = CheckUserInput();

            if (!string.IsNullOrEmpty(message))
            {
                await DisplayAlert(Droid.Resources.Messages.Text_Error, message, "OK");

                return;
            }

            this.IsBusy = true;

            try
            {
                Task <Core.DayIncidentList[]> getTask;

                if (this.pageMode == PageMode.NewOnly)
                {
                    getTask = this.core.GetNewIncidents(this.SelectedNodeGroupId);
                }
                else if (this.pageMode == PageMode.Interval)
                {
                    getTask = this.core.GetIncidents(this.startDatePicker.Date, this.endDatePicker.Date.Date.AddDays(1), this.SelectedNodeGroupId);
                }
                else
                {
                    getTask = this.core.GetActiveIncidents(this.IncidentFilter);
                }

                var incidents = await getTask;

                this.IncidentList.Clear();

                this.IncidentList.AddRange(incidents);
            }
            catch (Exception exc)
            {
                BugReportService.HandleException(Droid.Resources.Messages.Text_Error_Load, exc.Message, exc);
            }
            finally
            {
                this.IsBusy = false;
            }
        }
        public async Task Reload(bool isForce = false)
        {
            try
            {
                Reports.Clear();

                var reportManager = new ReportManager(App.Core.Server);

                var reportList = await reportManager.GetReportListAsync();

                var reportsAll = new List <ReportView>();

                foreach (var report in reportList)
                {
                    var reportView = new ReportView(report);
                    reportsAll.Add(reportView);
                }

                foreach (var type in ReportTypeFilter)
                {
                    var list = reportsAll.Where(x => x.Type == type);

                    if (list.Count() > 0)
                    {
                        var item = new ReportsView(list.First().GroupType,
                                                   list.First().GroupTypeDescription);

                        foreach (var element in list)
                        {
                            if (item.Where(x => x.Id == element.Id).Count() == 0)
                            {
                                item.Add(element);
                            }
                        }

                        Reports.Add(item);
                    }
                }
            }
            catch (Exception exc)
            {
                BugReportService.HandleException(Droid.Resources.Messages.Text_Error_Load, exc.Message, exc);
            }
        }
        /// <summary>
        /// Пользователь щёлкнул на детальной информации объекта.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void OnDetailStateSelected(object sender, SelectedItemChangedEventArgs e)
        {
            try
            {
                var listView = (ListView)sender;

                // Получаем детальную информацию
                var detailState = (MeasurePointStateView)e.SelectedItem;

                if (listView != null)
                {
                    listView.SelectedItem = null;
                }

                if (detailState == null)
                {
                    return;
                }

                // Проверим идентификатор детальной информации.

                switch (detailState.Id)
                {
                case DetailedState.CriticalIncidents:
                case DetailedState.Incidents:
                    // При щелчке на НС откроем отфильтрованную страницу.
                    await ShowIncidentsForMeasurePoint();

                    break;
                }
            }
            catch (Exception exc)
            {
                BugReportService.HandleException(Droid.Resources.Messages.Text_Error_Load, exc.Message, exc);
            }
        }
        private async Task LoadMeasurePointData()
        {
            this.IsBusy = true;

            try
            {
                await this.MeasurePoint.LoadData();

                OnPropertyChanged(nameof(MeasurePoint));
            }
            catch (Exception exc)
            {
                BugReportService.HandleException(
                    Droid.Resources.Messages.Text_Error_Load,
                    $"{Droid.Resources.Messages.IncidentDetailPage_Error_Load_Description}. {exc.Message}",
                    exc);
            }
            finally
            {
                this.IsBusy = false;
            }

            this.isLoaded = true;
        }