Beispiel #1
0
        private void RealErrorMessage(Exception exception)
        {
            if (InteractiveService != null)
            {
                foreach (var handler in CustomErrorHandlers)
                {
                    if (handler(exception, ApplicationInfo, User, InteractiveService))
                    {
                        return;
                    }
                }
            }
            if (errorMessageViewModel != null)
            {
                logger.Debug("Добавляем исключение в уже созданное окно.");
                errorMessageViewModel.AddException(exception);
            }
            else
            {
                logger.Debug("Создание окна отправки отчета о падении.");
                errorMessageViewModel = new ErrorMessageViewModel(ErrorMessageModelFactory.GetModel(), InteractiveService);
                errorMessageViewModel.AddException(exception);

                var errView = new ErrorMessageView(errorMessageViewModel);
                errView.ShowAll();
                errView.Run();
                errView.Destroy();
                errorMessageViewModel = null;
                logger.Debug("Окно отправки отчета, уничтожено.");
            }
        }
Beispiel #2
0
 private void IndexView_Login(object sender, EventArgs e)
 {
     if (e is LoginEventArgs)
     {
         LoginEventArgs loginEventArgs = e as LoginEventArgs;
         Dictionary <string, string> loginAccountInfo = new Dictionary <string, string>()
         {
             { "accountName", loginEventArgs.AccountName },
             { "passwd", loginEventArgs.Passwd }
         };
         AccountController           accountController = (AccountController)GetControllerByName("accountController");
         Dictionary <string, object> accountInfo       = accountController.Login(loginAccountInfo);
         if (null == accountInfo)
         {
             lastError = ErrorMessage.AccountNamePasswdNotMatch;
             int errorLevel = ErrorLevel.ErrorLevelWarning;
             ErrorMessageView errorMessageView = new ErrorMessageView(lastError, errorLevel);
             errorMessageView.ShowDialog();
         }
         else
         {
             userInfo = accountInfo;
             if (Database.AccountPrivilegeAdmin == (int)userInfo[Database.ItemAccountPrivilege])
             {
                 isAdmin = true;
             }
             else
             {
                 isAdmin = false;
             }
             FreeViewByName("indexView");
             LoadContentView();
         }
     }
 }
Beispiel #3
0
 private void ContentView_SelectTable(object sender, EventArgs e)
 {
     if (e is SelectTableEventArgs)
     {
         SelectTableEventArgs selectTableEventArgs = e as SelectTableEventArgs;
         ContentView          contentView          = (ContentView)GetViewByName("contentView");
         Dictionary <int, Dictionary <string, object> > tableData = null;
         string tableName = null;
         for (int i = 0; i < Database.TableList.Count; i++)
         {
             if (selectTableEventArgs.TableAttribute == (string)Database.TableList[i]["attribute"])
             {
                 tableName = (string)Database.TableList[i]["tableName"];
                 break;
             }
         }
         HydroController hydroController = (HydroController)GetControllerByName("hydroController");
         tableData = hydroController.GetTableDataByTableName(tableName);
         if (null == tableData)
         {
             Console.WriteLine(databaseDriver.LastError);
             Console.WriteLine(databaseDriver.LastQuery);
             lastError = ErrorMessage.GetDataFailed;
             int errorLevel = ErrorLevel.ErrorLevelWarning;
             ErrorMessageView errorMessageView = new ErrorMessageView(lastError, errorLevel);
             errorMessageView.ShowDialog();
         }
         else
         {
             contentView.RefreshTable(tableName, tableData, isAdmin);
         }
     }
 }
Beispiel #4
0
        protected override void SetupLayoutConstraints()
        {
            base.SetupLayoutConstraints();

            this.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            this.AddConstraints(
                BackgroundImage.FullSizeOf(this));

            this.AddConstraints(
                LoginField.AtTopOf(this, 220),
                LoginField.AtLeadingOf(this, 50),
                LoginField.AtTrailingOf(this, 50),
                LoginField.Height().EqualTo(Theme.Dimensions.TextFieldHeight),

                PasswordField.Below(LoginField, 12),
                PasswordField.WithSameLeading(LoginField),
                PasswordField.WithSameWidth(LoginField),
                PasswordField.WithSameHeight(LoginField),

                SignInButton.Below(PasswordField, 16),
                SignInButton.WithSameCenterX(this),
                SignInButton.Width().EqualTo(218),
                SignInButton.Height().EqualTo(44),

                ErrorMessageView.Above(LoginField, 36),
                ErrorMessageView.WithSameLeading(LoginField),
                ErrorMessageView.WithSameWidth(LoginField),

                ErrorMessageTriangleImage.Below(ErrorMessageView),
                ErrorMessageTriangleImage.WithSameCenterX(this));
        }
Beispiel #5
0
        public MainViewTests()
        {
            ErrorMessageView  errorMessageView  = new ErrorMessageView();
            DeleteConfirmView deleteConfirmView = new DeleteConfirmView();

            mainView = new MainView(errorMessageView);

            SettingsPresenter settingsPresenter = new SettingsPresenter(new SettingsUC(errorMessageView), errorMessageView);
            StoreFacade       facade            = ServicesInitialiser.facade;

            UnitsService         unitsService         = ServicesInitialiser.unitsService;
            UnitsDetailUC        unitsDetailUC        = new UnitsDetailUC(errorMessageView);
            UnitsDetailPresenter unitsDetailPresenter = new UnitsDetailPresenter(unitsDetailUC, facade);
            UnitsPresenter       unitsPresenter       = new UnitsPresenter(new UnitsUC(errorMessageView), facade, unitsDetailPresenter, deleteConfirmView, errorMessageView);

            SuppliersService         supplierService          = ServicesInitialiser.suppliersService;
            SuppliersDetailUC        suppliersDetailUC        = new SuppliersDetailUC(errorMessageView);
            SuppliersDetailPresenter suppliersDetailPresenter = new SuppliersDetailPresenter(suppliersDetailUC, facade);
            SuppliersPresenter       suppliersPresenter       = new SuppliersPresenter(new SuppliersUC(errorMessageView), suppliersDetailPresenter, facade, deleteConfirmView, errorMessageView);

            ProductsService         productsService         = ServicesInitialiser.productsService;
            ProductsDetailUC        productsDetailUC        = new ProductsDetailUC(errorMessageView);
            ProductsDetailPresenter productsDetailPresenter = new ProductsDetailPresenter(productsDetailUC, facade);
            ProductsPresenter       productsPresenter       = new ProductsPresenter(new ProductsUC(errorMessageView), productsDetailPresenter,
                                                                                    facade, deleteConfirmView, errorMessageView);

            ParametersService         parametersService         = ServicesInitialiser.parametersService;
            ParametersDetailUC        parametersDetailUC        = new ParametersDetailUC(errorMessageView);
            ParametersDetailPresenter parametersDetailPresenter = new ParametersDetailPresenter(parametersDetailUC, facade);
            ParametersPresenter       parametersPresenter       = new ParametersPresenter(new ParametersUC(errorMessageView),
                                                                                          parametersDetailPresenter, facade, deleteConfirmView, errorMessageView);

            ImagesService         imagesService         = ServicesInitialiser.imagesService;
            ImagesDetailUC        imagesDetailUC        = new ImagesDetailUC(errorMessageView);
            ImagesDetailPresenter imagesDetailPresenter = new ImagesDetailPresenter(imagesDetailUC, facade);
            ImagesPresenter       imagesPresenter       = new ImagesPresenter(new ImagesUC(errorMessageView), imagesDetailPresenter, ServicesInitialiser.facade, deleteConfirmView, errorMessageView);

            GroupsService         groupsService         = ServicesInitialiser.groupsService;
            GroupsDetailUC        groupsDetailUC        = new GroupsDetailUC(errorMessageView);
            GroupsDetailPresenter groupsDetailPresenter = new GroupsDetailPresenter(groupsDetailUC, ServicesInitialiser.facade);
            GroupsPresenter       groupsPresenter       = new GroupsPresenter(new GroupsUC(errorMessageView), groupsDetailPresenter, ServicesInitialiser.facade, deleteConfirmView, errorMessageView);

            CategoriesService         categoriesService         = ServicesInitialiser.categoriesService;
            CategoriesDetailUC        categoriesDetailUC        = new CategoriesDetailUC(errorMessageView);
            CategoriesDetailPresenter categoriesDetailPresenter = new CategoriesDetailPresenter(categoriesDetailUC, facade);
            CategoriesPresenter       categoriesPresenter       = new CategoriesPresenter(new CategoriesUC(errorMessageView), categoriesDetailPresenter, facade, deleteConfirmView, errorMessageView);


            mainPresenter = new MainPresenter(mainView,
                                              settingsPresenter,
                                              unitsPresenter, unitsDetailPresenter,
                                              suppliersPresenter, suppliersDetailPresenter,
                                              productsPresenter, productsDetailPresenter,
                                              parametersPresenter, parametersDetailPresenter,
                                              imagesPresenter, imagesDetailPresenter,
                                              groupsPresenter, groupsDetailPresenter,
                                              categoriesPresenter, categoriesDetailPresenter,
                                              facade, deleteConfirmView);
        }
Beispiel #6
0
        private async Task ShowReloadConfigDialog()
        {
            if (_plcComManager.GetIsAnyServicesBusy())
            {
            }
            var view = new ErrorMessageView();
            await DialogHost.Show(view, "MainDialogHost");

            _modalViewIsActive = false;
        }
Beispiel #7
0
        private void OnAddStudentClickEventRaised(object sender, EventArgs e)
        {
            try
            {
                _studentService.AddStudent(addStudentView.StudentName,
                                           addStudentView.StudentEmail,
                                           addStudentView.StudentSpecialty,
                                           addStudentView.StudentCourse);

                MessageBox.Show("Student successfully added.");
            }
            catch (ArgumentException ae)
            {
                var studentErroMessageView = new ErrorMessageView();
                studentErroMessageView.ShowErrorMessageView("Error", ae.Message);
            }
        }
Beispiel #8
0
        private void SetAdminView_AdminSet(object sender, EventArgs e)
        {
            if (e is AdminEventArgs)
            {
                AdminEventArgs              adminEventArgs    = e as AdminEventArgs;
                AccountController           accountController = (AccountController)GetControllerByName("accountController");
                Dictionary <string, string> accountInfo       = new Dictionary <string, string>()
                {
                    { "accountName", adminEventArgs.AccountName },
                    { "passwd", adminEventArgs.Passwd },
                    { "privilege", adminEventArgs.Privilege }
                };
                int returnCode = accountController.AddAccount(accountInfo);
                if (ControllerReturnCode.ACCOUNTADDACCOUNTSUCCESS != returnCode)
                {
                    int errorLevel;
                    switch (returnCode)
                    {
                    case ControllerReturnCode.ACCOUNTADDACCOUNTDUPLICATE:
                        lastError  = ErrorMessage.AcountNameExists;
                        errorLevel = ErrorLevel.ErrorLevelWarning;
                        break;

                    case ControllerReturnCode.ACCOUNTADDACCOUNTERROR:
                        lastError  = ErrorMessage.SetAdminFailed;
                        errorLevel = ErrorLevel.ErrorLevelSevere;
                        break;

                    default:
                        lastError  = ErrorMessage.SetAdminFailed;
                        errorLevel = ErrorLevel.ErrorLevelSevere;
                        break;
                    }
                    ErrorMessageView errorMessageView = new ErrorMessageView(lastError, errorLevel);
                    errorMessageView.ShowDialog();
                }
                FreeViewByName("setAdminView");
                IndexView indexView = (IndexView)GetViewByName("indexView");
                indexView.Login += IndexView_Login;
                indexView.ShowDialog();
            }
        }
Beispiel #9
0
        private async Task ShowMessageDialog(MessageEvent ev)
        {
            var view = new ErrorMessageView
            {
                DataContext = new ErrorDialogViewModel()
            };

            view.HeaderText.Text  = ev.HeaderText;
            view.ContentText.Text = ev.ContentText;

            if (ev.MessageLevel > MessageEvent.Level.Info)
            {
                SystemSounds.Hand.Play();
            }

            await DialogHost.Show(view, "MainDialogHost");

            _modalViewIsActive = false;
            // https://stackoverflow.com/questions/49965223/how-to-open-a-material-design-dialog-from-the-code-xaml-cs
        }
Beispiel #10
0
        public NavigationController(string databaseDriverName = "DatabaseDriver")
        {
            views       = new Dictionary <string, Form>();
            controllers = new Dictionary <string, Controller>();
            if (!InitDatabaseDriver(databaseDriverName))
            {
                ErrorMessageView errorMessageView = new ErrorMessageView(lastError, ErrorLevel.ErrorLevelSevere);
                errorMessageView.ShowDialog();
            }
            AccountController accountController = (AccountController)GetControllerByName("accountController");

            if (!accountController.IsAdminExists())
            {
                SetAdminView setAdminView = (SetAdminView)GetViewByName("setAdminView");
                setAdminView.AdminSet += SetAdminView_AdminSet;
                setAdminView.ShowDialog();
            }
            else
            {
                IndexView indexView = (IndexView)GetViewByName("indexView");
                indexView.Login += IndexView_Login;
                indexView.ShowDialog();
            }
        }
Beispiel #11
0
        public void ShowErrorMessage(string windowTitle, string errorMessage)
        {
            ErrorMessageView errorMessageView = new ErrorMessageView();

            errorMessageView.ShowErrorMessageView(windowTitle, errorMessage);
        }
Beispiel #12
0
 public void Init(ErrorMessageView view)
 {
     this.uiView = view;
     view.OnBackClicked.AddListener(() => sm.ChangeState <ListGameState>());
 }
Beispiel #13
0
 protected override void SetupSubviewsConstraints()
 {
     ErrorMessageView.AddConstraints(ErrorLabel.FullSizeOf(ErrorMessageView, 16));
 }