private void ConnectButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.ConnectionStringComboBox.SelectedIndex == -1)
            {
                MessageBox.Show(Properties.Resources.PleaseSelectConnectionString);
                return;
            }
            var ci = this.ConnectionStringComboBox.SelectedValue as ConnectionStringInfo;

            if (AValue.CanConnectToDatabase(AValue.SchemaData.DatabaseServer, ci.ConnectionString) == false)
            {
                MessageBox.Show(Properties.Resources.ConnectionStringInvalid);
                return;
            }

            this.ImportTable();
            this.ImportStoredProcedure();
            this.ImportUserDefinedTableType();

            if (this.TableListBox.Items.Count == 0 &&
                this.StoredProcedureListBox.Items.Count == 0 &&
                this.UserDefinedTableTypeListBox.Items.Count == 0)
            {
                MessageBox.Show(Properties.Resources.ThereIsNoObjectDeletedAfterLastProcess);
            }

            AValue.ConfigData.MoveConnectionStringToFirst(ci);
            this.ConnectionStringComboBox.SelectedItem = AValue.ConfigData.ConnectionStrings[0];
        }
        private void ExecuteButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.ConnectionStringComboBox.SelectedIndex == -1)
            {
                MessageBox.Show(Properties.Resources.PleaseSelectConnectionString);
                return;
            }
            var ci = this.ConnectionStringComboBox.SelectedValue as ConnectionStringInfo;

            if (AValue.CanConnectToDatabase(AValue.SchemaData.DatabaseServer, ci.ConnectionString) == false)
            {
                MessageBox.Show(Properties.Resources.ConnectionStringInvalid);
                return;
            }
            var sv = new ImportObjectCommandService(AValue.SchemaData, ci.ConnectionString
                                                    , _Tables.Where(el => el.IsChecked).Select(el => el.Item.Name)
                                                    , _StoredProcedures.Where(el => el.IsChecked).Select(el => el.Item.Name)
                                                    , _UserDefinedTableTypes.Where(el => el.IsChecked).Select(el => el.Item.Name)
                                                    );

            AValue.ConfigData.MoveConnectionStringToFirst(ci);
            this.ConnectionStringComboBox.SelectedItem = AValue.ConfigData.ConnectionStrings[0];

            this.Hide();

            var w = new ProgressWindow(sv);

            w.ShowDialog();
            sv.ThrowException();

            this.Close();
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (AValue.CanConnectToDatabase(AValue.SchemaData.DatabaseServer, this.ConnectionStringTextBox.Text) == false)
            {
                MessageBox.Show(Properties.Resources.ConnectionStringInvalid);
                return;
            }

            this.OnSaved();
            this.Close();
        }
Exemple #4
0
        private void ExecuteButton_Click(object sender, RoutedEventArgs e)
        {
            Analytics.TrackEvent("ImportObjectGenerateFile Execute");

            var ci = this.ConnectionStringComboBox.SelectedValue as ConnectionStringInfo;

            if (ci == null)
            {
                MessageBox.Show(Properties.Resources.PleaseSelectConnectionString);
                return;
            }
            if (AValue.CanConnectToDatabase(AValue.SchemaData.DatabaseServer, ci.ConnectionString) == false)
            {
                MessageBox.Show(Properties.Resources.ConnectionStringInvalid);
                return;
            }

            var path = this.OutputDirectoryPathTextBox.Text;

            if (path.EndsWith("\\") == false)
            {
                path += "\\";
            }
            AValue.EnsureGenerateSourceCodeFolder(path);
            this.OutputDirectoryPathTextBox.Text = path;

            var sv = new ImportObjectGenerateFileCommandService(AValue.SchemaData);

            sv.ImportAllObject = this.ImportAllObjectCheckBox.IsChecked == true;
            sv.LoadCommand(ci.ConnectionString, path, this.NamespaceNameTextBox.Text, this.DatabaseKeyTextBox.Text);

            AValue.ConfigData.MoveConnectionStringToFirst(ci);
            this.ConnectionStringComboBox.SelectedItem = AValue.ConfigData.ConnectionStrings[0];

            this.Hide();

            var w = new ProgressWindow(sv);

            w.ShowDialog();
            sv.ThrowException();

            this.Close();
        }