Esempio n. 1
0
        private void button_editSqlDef_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.comboBox_sqlServerType.Text == "SQLite")
            {
                SqliteDataSourceDlg datasource_dlg = new SqliteDataSourceDlg();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于内置的 SQLite 实现,不再需要任何其他数据库底层软件。请设置下列 SQLite 相关参数。";
                if (this.LineInfo != null)
                {
                    datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName;
                }
                else
                {
                    datasource_dlg.InstanceName = "dp2kernel"
                        + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                        + this.InstanceName;    // 应当没有空格和特殊字符
                }

                datasource_dlg.StartPosition = FormStartPosition.CenterScreen;
                datasource_dlg.ShowDialog(this);
                if (datasource_dlg.DialogResult != DialogResult.OK)
                    return;

                if (this.LineInfo == null)
                    this.LineInfo = new LineInfo();

                this.LineInfo.SqlServerType = "SQLite";
                this.LineInfo.SqlServerName = "~sqlite";
                this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName;
                this.LineInfo.DatabaseLoginName = "";
                this.LineInfo.DatabaseLoginPassword = "";
                RefreshSqlDef();

            }
            else if (this.comboBox_sqlServerType.Text == "MS SQL Server")
            {
                // MS SQL Server

                // 调对话框得到数据源配置参数
                // MsSqlServerDataSourceDlg datasource_dlg = new MsSqlServerDataSourceDlg();
                MsSqlServerDataSourceWizard datasource_dlg = new MsSqlServerDataSourceWizard();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                // datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 MS SQL Server 2000 以上版本实现。请设置下列 SQL Server 相关参数。";
                datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 MS SQL Server 2000 以上版本实现。请按“下一步”按钮,设置 SQL Server 相关参数。";
                if (this.LineInfo != null)
                {
                    datasource_dlg.SqlServerName = this.LineInfo.SqlServerName;
                    datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName;
                    datasource_dlg.KernelLoginName = this.LineInfo.DatabaseLoginName;
                    datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword;
                }
                else
                {
                    datasource_dlg.SqlServerName = "";
                    datasource_dlg.InstanceName = "dp2kernel"
                        + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                        + this.InstanceName;    // 应当没有空格和特殊字符
                    datasource_dlg.KernelLoginName = "dp2kernel"
                        + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                        + this.InstanceName;
                    datasource_dlg.KernelLoginPassword = "";
                }

                datasource_dlg.StartPosition = FormStartPosition.CenterScreen;
                datasource_dlg.ShowDialog(this);
                if (datasource_dlg.DialogResult != DialogResult.OK)
                    return;

                if (this.LineInfo == null)
                    this.LineInfo = new LineInfo();

                // TODO: 如果以前有值,需要把修改前后的值都记下来,便于在出现问题后复原

                this.LineInfo.SqlServerType = "MS SQL Server";
                this.LineInfo.SqlServerName = datasource_dlg.SqlServerName;
                this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName;
                this.LineInfo.DatabaseLoginName = datasource_dlg.KernelLoginName;
                this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword;

                RefreshSqlDef();

                // 记载到 DebugInfo 中
                if (string.IsNullOrEmpty(this.DebugInfo) == false)
                    this.DebugInfo += "\r\n\r\n";
                this.DebugInfo += datasource_dlg.DebugInfo;
            }
            else if (this.comboBox_sqlServerType.Text == "MySQL Server")
            {
                // MySQL Server

                // 调对话框得到数据源配置参数
                MySqlDataSourceDlg datasource_dlg = new MySqlDataSourceDlg();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 MySQL Server 5.5/5.6 以上版本实现。请设置下列 MySQL Server 相关参数。";
                if (this.LineInfo != null)
                {
                    datasource_dlg.SqlServerName = this.LineInfo.SqlServerName;
                    datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName;
                    datasource_dlg.KernelLoginName = this.LineInfo.DatabaseLoginName;
                    datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword;
                }
                else
                {
                    datasource_dlg.SqlServerName = "localhost";
                    datasource_dlg.InstanceName = "dp2kernel"
                        + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                        + this.InstanceName;    // 应当没有空格和特殊字符
#if NO
                    datasource_dlg.KernelLoginName = "dp2kernel"
                        + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                        + this.InstanceName;
#endif
                    datasource_dlg.KernelLoginName = "root";
                    datasource_dlg.KernelLoginPassword = "";
                }

                datasource_dlg.StartPosition = FormStartPosition.CenterScreen;
                datasource_dlg.ShowDialog(this);
                if (datasource_dlg.DialogResult != DialogResult.OK)
                    return;

                if (this.LineInfo == null)
                    this.LineInfo = new LineInfo();

                this.LineInfo.SqlServerType = "MySQL Server";
                this.LineInfo.SqlServerName = datasource_dlg.SqlServerName;
                this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName;
                this.LineInfo.DatabaseLoginName = datasource_dlg.KernelLoginName;
                this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword;
                RefreshSqlDef();
            }
            else if (this.comboBox_sqlServerType.Text == "Oracle")
            {
                // Oracle

                // 调对话框得到数据源配置参数
                // OracleDataSourceDlg datasource_dlg = new OracleDataSourceDlg();
                OracleDataSourceWizard datasource_dlg = new OracleDataSourceWizard();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                // datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 Oracle 11g 以上版本实现。请设置下列 Oracle 相关参数。";
                datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 Oracle Databse 11g 以上版本实现。请按“下一步”按钮,设置 Oracle Database 相关参数。";
                if (this.LineInfo != null)
                {
                    datasource_dlg.SqlServerName = this.LineInfo.SqlServerName;
                    datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName;
                    datasource_dlg.KernelLoginName = this.LineInfo.DatabaseLoginName;
                    datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword;
                }
                else
                {
                    datasource_dlg.SqlServerName = "";
                    datasource_dlg.InstanceName = "dp2kernel"
                        + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                        + this.InstanceName;    // 应当没有空格和特殊字符
                    datasource_dlg.KernelLoginName = "dp2kernel"
                        + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                        + this.InstanceName;
                    datasource_dlg.KernelLoginPassword = "";
                }

                datasource_dlg.StartPosition = FormStartPosition.CenterScreen;
                datasource_dlg.ShowDialog(this);
                if (datasource_dlg.DialogResult != DialogResult.OK)
                    return;

                if (this.LineInfo == null)
                    this.LineInfo = new LineInfo();

                this.LineInfo.SqlServerType = "Oracle";
                this.LineInfo.SqlServerName = datasource_dlg.SqlServerName;
                this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName;
                this.LineInfo.DatabaseLoginName = datasource_dlg.KernelLoginName;
                this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword;

                RefreshSqlDef();
            }
            else
            {
                strError = "未知的 SQL 服务器类型 '" + this.comboBox_sqlServerType.Text + "'";
                goto ERROR1;
            }

            return;
        ERROR1:
            MessageBox.Show(this, strError);
            return;
        }
Esempio n. 2
0
        private void button_editSqlDef_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.comboBox_sqlServerType.Text == "SQLite")
            {
                SqliteDataSourceDlg datasource_dlg = new SqliteDataSourceDlg();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于内置的 SQLite 实现,不再需要任何其他数据库底层软件。请设置下列 SQLite 相关参数。";
                if (this.LineInfo != null)
                {
                    datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName;
                }
                else
                {
                    datasource_dlg.InstanceName = "dp2kernel"
                                                  + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                                                  + this.InstanceName; // 应当没有空格和特殊字符
                }

                datasource_dlg.StartPosition = FormStartPosition.CenterScreen;
                datasource_dlg.ShowDialog(this);
                if (datasource_dlg.DialogResult != DialogResult.OK)
                {
                    return;
                }

                if (this.LineInfo == null)
                {
                    this.LineInfo = new LineInfo();
                }

                this.LineInfo.SqlServerType         = "SQLite";
                this.LineInfo.SqlServerName         = "~sqlite";
                this.LineInfo.DatabaseInstanceName  = datasource_dlg.InstanceName;
                this.LineInfo.DatabaseLoginName     = "";
                this.LineInfo.DatabaseLoginPassword = "";
                RefreshSqlDef();
            }
            else if (this.comboBox_sqlServerType.Text == "MS SQL Server")
            {
                // MS SQL Server

                // 调对话框得到数据源配置参数
                // MsSqlServerDataSourceDlg datasource_dlg = new MsSqlServerDataSourceDlg();
                MsSqlServerDataSourceWizard datasource_dlg = new MsSqlServerDataSourceWizard();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                // datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 MS SQL Server 2000 以上版本实现。请设置下列 SQL Server 相关参数。";
                datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 MS SQL Server 2000 以上版本实现。请按“下一步”按钮,设置 SQL Server 相关参数。";
                if (this.LineInfo != null)
                {
                    datasource_dlg.SqlServerName       = this.LineInfo.SqlServerName;
                    datasource_dlg.InstanceName        = this.LineInfo.DatabaseInstanceName;
                    datasource_dlg.KernelLoginName     = this.LineInfo.DatabaseLoginName;
                    datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword;
                }
                else
                {
                    datasource_dlg.SqlServerName = "";
                    datasource_dlg.InstanceName  = "dp2kernel"
                                                   + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                                                   + this.InstanceName; // 应当没有空格和特殊字符
                    datasource_dlg.KernelLoginName = "dp2kernel"
                                                     + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                                                     + this.InstanceName;
                    datasource_dlg.KernelLoginPassword = "";
                }

                datasource_dlg.StartPosition = FormStartPosition.CenterScreen;
                datasource_dlg.ShowDialog(this);
                if (datasource_dlg.DialogResult != DialogResult.OK)
                {
                    return;
                }

                if (this.LineInfo == null)
                {
                    this.LineInfo = new LineInfo();
                }

                // TODO: 如果以前有值,需要把修改前后的值都记下来,便于在出现问题后复原

                this.LineInfo.SqlServerType         = "MS SQL Server";
                this.LineInfo.SqlServerName         = datasource_dlg.SqlServerName;
                this.LineInfo.DatabaseInstanceName  = datasource_dlg.InstanceName;
                this.LineInfo.DatabaseLoginName     = datasource_dlg.KernelLoginName;
                this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword;

                RefreshSqlDef();

                // 记载到 DebugInfo 中
                if (string.IsNullOrEmpty(this.DebugInfo) == false)
                {
                    this.DebugInfo += "\r\n\r\n";
                }
                this.DebugInfo += datasource_dlg.DebugInfo;
            }
            else if (this.comboBox_sqlServerType.Text == "MySQL Server")
            {
                // MySQL Server

                // 调对话框得到数据源配置参数
                MySqlDataSourceDlg datasource_dlg = new MySqlDataSourceDlg();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 MySQL Server 5.5/5.6 以上版本实现。请设置下列 MySQL Server 相关参数。";
                if (this.LineInfo != null)
                {
                    datasource_dlg.SqlServerName       = this.LineInfo.SqlServerName;
                    datasource_dlg.InstanceName        = this.LineInfo.DatabaseInstanceName;
                    datasource_dlg.KernelLoginName     = this.LineInfo.DatabaseLoginName;
                    datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword;
                }
                else
                {
                    datasource_dlg.SqlServerName = "localhost";
                    datasource_dlg.InstanceName  = "dp2kernel"
                                                   + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                                                   + this.InstanceName; // 应当没有空格和特殊字符
#if NO
                    datasource_dlg.KernelLoginName = "dp2kernel"
                                                     + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                                                     + this.InstanceName;
#endif
                    datasource_dlg.KernelLoginName     = "root";
                    datasource_dlg.KernelLoginPassword = "";
                }

                datasource_dlg.StartPosition = FormStartPosition.CenterScreen;
                datasource_dlg.ShowDialog(this);
                if (datasource_dlg.DialogResult != DialogResult.OK)
                {
                    return;
                }

                if (this.LineInfo == null)
                {
                    this.LineInfo = new LineInfo();
                }

                this.LineInfo.SqlServerType         = "MySQL Server";
                this.LineInfo.SqlServerName         = datasource_dlg.SqlServerName;
                this.LineInfo.DatabaseInstanceName  = datasource_dlg.InstanceName;
                this.LineInfo.DatabaseLoginName     = datasource_dlg.KernelLoginName;
                this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword;
                RefreshSqlDef();
            }
            else if (this.comboBox_sqlServerType.Text == "Oracle")
            {
                // Oracle

                // 调对话框得到数据源配置参数
                // OracleDataSourceDlg datasource_dlg = new OracleDataSourceDlg();
                OracleDataSourceWizard datasource_dlg = new OracleDataSourceWizard();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                // datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 Oracle 11g 以上版本实现。请设置下列 Oracle 相关参数。";
                datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 Oracle Databse 11g 以上版本实现。请按“下一步”按钮,设置 Oracle Database 相关参数。";
                if (this.LineInfo != null)
                {
                    datasource_dlg.SqlServerName       = this.LineInfo.SqlServerName;
                    datasource_dlg.InstanceName        = this.LineInfo.DatabaseInstanceName;
                    datasource_dlg.KernelLoginName     = this.LineInfo.DatabaseLoginName;
                    datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword;
                }
                else
                {
                    datasource_dlg.SqlServerName = "";
                    datasource_dlg.InstanceName  = "dp2kernel"
                                                   + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                                                   + this.InstanceName; // 应当没有空格和特殊字符
                    datasource_dlg.KernelLoginName = "dp2kernel"
                                                     + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "")
                                                     + this.InstanceName;
                    datasource_dlg.KernelLoginPassword = "";
                }

                datasource_dlg.StartPosition = FormStartPosition.CenterScreen;
                datasource_dlg.ShowDialog(this);
                if (datasource_dlg.DialogResult != DialogResult.OK)
                {
                    return;
                }

                if (this.LineInfo == null)
                {
                    this.LineInfo = new LineInfo();
                }

                this.LineInfo.SqlServerType         = "Oracle";
                this.LineInfo.SqlServerName         = datasource_dlg.SqlServerName;
                this.LineInfo.DatabaseInstanceName  = datasource_dlg.InstanceName;
                this.LineInfo.DatabaseLoginName     = datasource_dlg.KernelLoginName;
                this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword;

                RefreshSqlDef();
            }
            else
            {
                strError = "未知的 SQL 服务器类型 '" + this.comboBox_sqlServerType.Text + "'";
                goto ERROR1;
            }

            return;

ERROR1:
            MessageBox.Show(this, strError);
            return;
        }