Ejemplo n.º 1
0
        private void buttonNext_Click(object sender, System.EventArgs e)
        {
            if (ValidateProjectLocation())
            {
                if (NHibernateHelper.ProjectLoader.IsFluentProject(tbProjectLocation.Text) &&
                    !FluentCompiledAssemblyFound())
                {
                    MessageBox.Show(this, "Compiled assembly not found for this Fluent NHibernate project. Please recompile the project, then try again.", "Compiled assembly missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (radioManual.Checked)
                {
                    if (ucDatabaseInformation1.ConnectionStringHelper.CurrentDbType == DatabaseTypes.Unknown)
                    {
                        MessageBox.Show(this, "Please select a database.", "Missing data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    bool informationFilled = LoadExistingDatabase.TestConnection(false, ucDatabaseInformation1);

                    if (informationFilled == false)
                        return;

                    nhConfigFile = CreateConfigFileManually(ucDatabaseInformation1.SelectedDatabaseType, ucDatabaseInformation1.ConnectionStringHelper.GetNHConnectionStringSqlClient());
                }
                if (nhConfigFile == null)
                {
                    //MessageBox.Show(this, "No config file specified.", "Config file missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    // Check whether we can find a config file
                    nhConfigFile = GetNhConfigFileFromCsprojFile(tbProjectLocation.Text);

                    if (nhConfigFile == null)
                    {
                        MessageBox.Show(this, "No NHibernate config file could be found for this project. If the file exists in another project then please locate it, otherwise manually enter the settings.", "NH config file missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        radioFile.Visible = true;
                        radioManual.Visible = true;
                    }
                    else
                    {
                        radioFile.Visible = false;
                        radioManual.Visible = false;
                    }
                    panelConfigSettings.Visible = nhConfigFile == null;
                    return;
                }
                var newProjectInfo = new LoadExistingNHibernateProjectInfo();
                newProjectInfo.Filename = tbProjectLocation.Text;
                newProjectInfo.NhConfigFile = nhConfigFile;
                NewProjectForm.NewProjectInformation = newProjectInfo;
                NewProjectForm.NewProjectOutputPath = Path.GetDirectoryName(tbProjectLocation.Text);

                //if (radioManual.Checked)
                //{
                //    NewProjectForm.NewProjectInformation = new LoadExistingDatabaseInfo
                //                                            {
                //                                                DatabaseLoader = DatabasePresenter.CreateDatabaseLoader(ucDatabaseInformation1),
                //                                                ConnStringHelper = ucDatabaseInformation1.GetHelper()
                //                                            };
                //}
                NewProjectForm.SetScreenData(
                                                ScreenDataKey,
                                                new ScreenData
                                                {
                                                    ExistingFilename = tbProjectLocation.Text
                                                });

                // Skip the Database, SelectSchemaObjects and Prefixes screens.
                NewProjectForm.SkipScreens(3);
                NewProjectForm.UserChosenAction = NewProjectFormActions.NewProject;
                NewProjectForm.Finish();
            }
            else
            {
                highlighter1.SetHighlightColor(tbProjectLocation, DevComponents.DotNetBar.Validator.eHighlightColor.Orange);
                MessageBox.Show(this, "Please select a *.csproj file", "Invalid Visual Studio project file", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 2
0
        private void buttonNext_Click(object sender, System.EventArgs e)
        {
            if (ValidateProjectLocation())
            {
                if (NHibernateHelper.ProjectLoader.IsFluentProject(tbProjectLocation.Text) &&
                    !FluentCompiledAssemblyFound())
                {
                    MessageBox.Show(this, "Compiled assembly not found for this Fluent NHibernate project. Please recompile the project, then try again.", "Compiled assembly missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (radioManual.Checked)
                {
                    if (ucDatabaseInformation1.ConnectionStringHelper.CurrentDbType == DatabaseTypes.Unknown)
                    {
                        MessageBox.Show(this, "Please select a database.", "Missing data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    bool informationFilled = LoadExistingDatabase.TestConnection(false, ucDatabaseInformation1);

                    if (informationFilled == false)
                    {
                        return;
                    }

                    nhConfigFile = CreateConfigFileManually(ucDatabaseInformation1.SelectedDatabaseType, ucDatabaseInformation1.ConnectionStringHelper.GetNHConnectionStringSqlClient());
                }
                if (nhConfigFile == null)
                {
                    //MessageBox.Show(this, "No config file specified.", "Config file missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    // Check whether we can find a config file
                    nhConfigFile = GetNhConfigFileFromCsprojFile(tbProjectLocation.Text);

                    if (nhConfigFile == null)
                    {
                        MessageBox.Show(this, "No NHibernate config file could be found for this project. If the file exists in another project then please locate it, otherwise manually enter the settings.", "NH config file missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        radioFile.Visible   = true;
                        radioManual.Visible = true;
                    }
                    else
                    {
                        radioFile.Visible   = false;
                        radioManual.Visible = false;
                    }
                    panelConfigSettings.Visible = nhConfigFile == null;
                    return;
                }
                var newProjectInfo = new LoadExistingNHibernateProjectInfo();
                newProjectInfo.Filename              = tbProjectLocation.Text;
                newProjectInfo.NhConfigFile          = nhConfigFile;
                NewProjectForm.NewProjectInformation = newProjectInfo;
                NewProjectForm.NewProjectOutputPath  = Path.GetDirectoryName(tbProjectLocation.Text);

                //if (radioManual.Checked)
                //{
                //    NewProjectForm.NewProjectInformation = new LoadExistingDatabaseInfo
                //                                            {
                //                                                DatabaseLoader = DatabasePresenter.CreateDatabaseLoader(ucDatabaseInformation1),
                //                                                ConnStringHelper = ucDatabaseInformation1.GetHelper()
                //                                            };
                //}
                NewProjectForm.SetScreenData(
                    ScreenDataKey,
                    new ScreenData
                {
                    ExistingFilename = tbProjectLocation.Text
                });

                // Skip the Database, SelectSchemaObjects and Prefixes screens.
                NewProjectForm.SkipScreens(3);
                NewProjectForm.UserChosenAction = NewProjectFormActions.NewProject;
                NewProjectForm.Finish();
            }
            else
            {
                highlighter1.SetHighlightColor(tbProjectLocation, DevComponents.DotNetBar.Validator.eHighlightColor.Orange);
                MessageBox.Show(this, "Please select a *.csproj file", "Invalid Visual Studio project file", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }