Beispiel #1
0
        private void ExecuteButton_Click(object sender, RoutedEventArgs e)
        {
            var path = this.OutputDirectoryPathTextBox.Text;

            if (path.EndsWith("\\") == false)
            {
                path += "\\";
            }
            AValue.EnsureGenerateSourceCodeFolder(path);
            this.OutputDirectoryPathTextBox.Text = path;
            AValue.ConfigData.SetOutputDirectoryPath(path);
            AValue.SchemaData.NamespaceName = this.NamespaceNameTextBox.Text;
            AValue.SchemaData.DatabaseKey   = this.DatabaseKeyTextBox.Text;
            AValue.EnsureGenerateSourceCodeFolder(path);

            var sv = new CommandService();
            var cm = new GenerateSourceCodeCommand(AValue.ConfigData.GetOutputDirectoryPath(), AValue.SchemaData);

            cm.Tables.AddRange(_Tables.Where(el => el.IsChecked).Select(el => el.Item));
            cm.StoredProcedures.AddRange(_StoredProcedures.Where(el => el.IsChecked).Select(el => el.Item));
            cm.UserDefinedTableTypes.AddRange(_UserDefinedTableTypes.Where(el => el.IsChecked).Select(el => el.Item));
            sv.Commands.Add(cm);

            if (cm.Tables.Count == 0 &&
                cm.StoredProcedures.Count == 0 &&
                cm.UserDefinedTableTypes.Count == 0)
            {
                MessageBox.Show(Properties.Resources.PleaseSelectItem);
                return;
            }

            this.Hide();

            var w = new ProgressWindow(sv);

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

            this.Close();
        }
        private void ExecuteButton_Click(object sender, RoutedEventArgs e)
        {
            Analytics.TrackEvent("DeleteObject Execute");

            var tNames = _Tables.Where(el => el.IsChecked).Select(el => el.Item.Name).ToList();
            var sNames = _StoredProcedures.Where(el => el.IsChecked).Select(el => el.Item.Name).ToList();
            var uNames = _UserDefinedTableTypes.Where(el => el.IsChecked).Select(el => el.Item.Name).ToList();
            var ci     = this.ConnectionStringComboBox.SelectedValue as ConnectionStringInfo;
            var sv     = new DeleteObjectCommandService(AValue.ConfigData.GetOutputDirectoryPath(), AValue.SchemaData, ci.ConnectionString
                                                        , tNames, sNames, uNames);

            AValue.ConfigData.MoveConnectionStringToFirst(ci);

            this.Hide();

            var w = new ProgressWindow(sv);

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

            this.Close();
        }
        private void ExecuteButton_Click(object sender, RoutedEventArgs e)
        {
            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();
        }
        private void ExecuteButton_Click(object sender, RoutedEventArgs e)
        {
            var tNames = _Tables.Where(el => el.IsChecked).Select(el => el.Item.Name).ToList();
            var sNames = _StoredProcedures.Where(el => el.IsChecked).Select(el => el.Item.Name).ToList();
            var uNames = _UserDefinedTableTypes.Where(el => el.IsChecked).Select(el => el.Item.Name).ToList();
            var ci = this.ConnectionStringComboBox.SelectedValue as ConnectionStringInfo;
            var sv = new DeleteObjectCommandService(AValue.ConfigData.GetOutputDirectoryPath(), AValue.SchemaData, ci.ConnectionString
                , tNames, sNames, uNames);

            AValue.ConfigData.MoveConnectionStringToFirst(ci);

            this.Hide();

            var w = new ProgressWindow(sv);
            w.ShowDialog();
            sv.ThrowException();

            this.Close();
        }
        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();
        }