Ejemplo n.º 1
0
        private void RefreshSelectedDatabaseType()
        {
            DatabaseSettings databaseSettings = comboBoxDatabase.SelectedItem as DatabaseSettings;

            if (databaseSettings != null)
            {
                Mouse.OverrideCursor = Cursors.Wait;

                try
                {
                    databaseSettings.RefreshInstances();
                }
                catch (Exception ex)
                {
                    if (!_suppressInstanceListErrors)
                    {
                        Mouse.OverrideCursor = null;

                        StackHashMessageBox.Show(this,
                                                 Properties.Resources.InstanceListFailed_MBMessage,
                                                 Properties.Resources.InstanceListFailed_MBTitle,
                                                 StackHashMessageBoxType.Ok,
                                                 StackHashMessageBoxIcon.Error,
                                                 ex,
                                                 StackHashServiceErrorCode.NoError);
                    }
                }
                finally
                {
                    Mouse.OverrideCursor = null;
                }
            }

            UpdateState(false);
        }
Ejemplo n.º 2
0
        /// <summary />
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (targetType != typeof(string))
            {
                throw new InvalidOperationException("targetType must be string");
            }

            return(StackHashMessageBox.GetServiceErrorCodeMessage((StackHashServiceErrorCode)value));
        }
Ejemplo n.º 3
0
        private void buttonOK_Click(object sender, RoutedEventArgs e)
        {
            if (_worker.IsBusy)
            {
                return;
            }

            string errors = ValidateAndReturnErrors();

            if (errors != null)
            {
                StackHashMessageBox.Show(this,
                                         errors,
                                         Properties.Resources.Error_Title,
                                         StackHashMessageBoxType.Ok,
                                         StackHashMessageBoxIcon.Error);

                return;
            }

            DatabaseSettings databaseSettings = comboBoxDatabase.SelectedItem as DatabaseSettings;

            if (databaseSettings != null)
            {
                Mouse.OverrideCursor = Cursors.Wait;

                bool createDatabase = true;

                // if we're editing an existing profile then we only create a database if a copy is required
                // copy is required if the data source has changed (otherwise it's a move)
                if (!DBConfigSettings.Settings.IsNewProfile)
                {
                    createDatabase = databaseSettings.HasDataSourceChanged(_initialConnectionString, textBoxConnectionString.Text);
                    DBConfigSettings.Settings.DatabaseCopyRequired = createDatabase;
                }

                _worker.RunWorkerAsync(new WorkerArg(false,
                                                     createDatabase,
                                                     checkBoxStoreDatabaseInCabFolder.IsChecked == false,
                                                     textBoxCabFolder.Text,
                                                     textBoxConnectionString.Text,
                                                     databaseSettings.GetMasterConnectionString(textBoxConnectionString.Text),
                                                     textBoxDatabaseName.Text));
            }

            e.Handled = true;
        }
Ejemplo n.º 4
0
        private void buttonCancel_Click(object sender, RoutedEventArgs e)
        {
            if (_worker.IsBusy)
            {
                return;
            }

            if (StackHashMessageBox.Show(this,
                                         Properties.Resources.ConfirmCancel_MBMessage,
                                         Properties.Resources.ConfirmCancel_MBTitle,
                                         StackHashMessageBoxType.YesNo,
                                         StackHashMessageBoxIcon.Question) == StackHashDialogResult.Yes)
            {
                Close();
            }

            e.Handled = true;
        }
Ejemplo n.º 5
0
        private static void DisplayUnhandledExceptionAndDie(Exception ex)
        {
            try
            {
                Window owner = null;
                if (Application.Current != null)
                {
                    owner = Application.Current.MainWindow;
                }

                StackHashMessageBox.Show(owner,
                                         UnhandledExceptionMessage,
                                         UnhandledExceptionTitle,
                                         StackHashMessageBoxType.Ok,
                                         StackHashMessageBoxIcon.Error,
                                         ex,
                                         StackHash.StackHashService.StackHashServiceErrorCode.NoError);
            }
            catch (XamlParseException)
            {
                try
                {
                    // this will happen if the XAML window can't be created for some reason -
                    // try showing a regular message box in this case
                    MessageBox.Show(UnhandledExceptionMessage,
                                    UnhandledExceptionTitle,
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Hand);
                }
                catch { }
            }
            catch { }
            finally
            {
                App.Current.Shutdown();
            }
        }
Ejemplo n.º 6
0
        void _worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Mouse.OverrideCursor = null;

            WorkerResult result = e.Result as WorkerResult;

            // check that the test succeded
            if (result.TestStatus != StackHashErrorIndexDatabaseStatus.Success)
            {
                // test failed - always a fatal error
                StackHashMessageBox.Show(this,
                                         string.Format(CultureInfo.CurrentCulture,
                                                       Properties.Resources.TestFailed_MBMessage,
                                                       StackHashMessageBox.GetDatabaseStatusMessage(result.TestStatus)),
                                         Properties.Resources.TestFailed_MBTitle,
                                         StackHashMessageBoxType.Ok,
                                         StackHashMessageBoxIcon.Error,
                                         result.WorkerException,
                                         StackHashServiceErrorCode.NoError);
            }
            else if (!result.CanAccessCabFolder)
            {
                StackHashMessageBox.Show(this,
                                         Properties.Resources.TestCabFolderFailed_MBMessage,
                                         Properties.Resources.TestCabFolderFailed_MBTitle,
                                         StackHashMessageBoxType.Ok,
                                         StackHashMessageBoxIcon.Error,
                                         result.WorkerException,
                                         StackHashServiceErrorCode.NoError);
            }
            else
            {
                if (result.TestConnectionOnly)
                {
                    // test succeeded
                    StackHashMessageBox.Show(this,
                                             Properties.Resources.TestSuccess_MBMessage,
                                             Properties.Resources.TestSuccess_MBTitle,
                                             StackHashMessageBoxType.Ok,
                                             StackHashMessageBoxIcon.Information);
                }
                else
                {
                    if (result.WorkerException == null)
                    {
                        // config complete, we can close
                        Close();
                    }
                    else
                    {
                        // failed to create database
                        StackHashMessageBox.Show(this,
                                                 Properties.Resources.CreateFailed_MBMessage,
                                                 Properties.Resources.CreateFailed_MBTitle,
                                                 StackHashMessageBoxType.Ok,
                                                 StackHashMessageBoxIcon.Error,
                                                 result.WorkerException,
                                                 StackHash.StackHashService.StackHashServiceErrorCode.NoError);
                    }
                }
            }
        }