コード例 #1
0
ファイル: Installer.cs プロジェクト: zszqwe/dp2
        // 创建数据目录
        public int CreateDataDir(
            string strRootDir,
            string strDefaultInstanceName,
            string strDefaultDataDir,
            out string strResultStartFileName,
            out string strResultDataDir,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            strResultStartFileName = "";
            strResultDataDir       = "";

            bool bFinished = false;

            // 要求在temp内准备要安装的数据文件(初次安装而不是升级安装)
            string strTempDataDir = PathUtil.MergePath(strRootDir, "temp");


REDO_INPUT:
            // 获得数据目录
            DataDirDlg datadir_dlg = new DataDirDlg();

            GuiUtil.AutoSetDefaultFont(datadir_dlg);
            datadir_dlg.Comment         = "请指定一个独立的数据目录, 用于存储dp2Kernel内核的各种配置信息。";
            datadir_dlg.MessageBoxTitle = "setup_dp2Kernel";
            datadir_dlg.DataDir         = strDefaultDataDir;

            datadir_dlg.StartPosition = FormStartPosition.CenterScreen;
            datadir_dlg.ShowDialog(ForegroundWindow.Instance);
            if (datadir_dlg.DialogResult != DialogResult.OK)
            {
                strError = "用户放弃指定数据目录。安装未完成。";
                throw new InstallException(strError);
            }

            string strDataDir = datadir_dlg.DataDir;

            string strExistingDatabasesFileName = PathUtil.MergePath(strDataDir,
                                                                     "databases.xml");

            if (File.Exists(strExistingDatabasesFileName) == true)
            {
                // 从以前的rmsws数据目录升级
                string       strText = "数据目录 '" + strDataDir + "' 中已经存在以前的数据库内核版本遗留下来的数据文件。\r\n\r\n确实要利用这个数据目录来进行升级安装么?\r\n(注意:如果利用以前的rmsws的数据目录来进行升级安装,则必须先行卸载rmsws,以避免它和(正在安装的)dp2Kernel同时运行引起冲突)\r\n\r\n(是)继续进行升级安装 (否)重新指定数据目录 (取消)放弃安装";
                DialogResult result  = MessageBox.Show(
                    ForegroundWindow.Instance,
                    strText,
                    "setup_dp2kernel",
                    MessageBoxButtons.YesNoCancel,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Cancel)
                {
                    strError = "用户放弃指定数据目录。安装未完成。";
                    throw new InstallException(strError);
                }

                if (result == DialogResult.No)
                {
                    goto REDO_INPUT;
                }

                // 创建start.xml文件
                string strStartXmlFileName = PathUtil.MergePath(strRootDir, "start.xml");
                nRet = this.CreateStartXml(strStartXmlFileName,
                                           strDataDir,
                                           out strError);
                if (nRet == -1)
                {
                    throw new InstallException(strError);
                }

                // 删除临时目录
                try
                {
                    Directory.Delete(strTempDataDir, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ForegroundWindow.Instance,
                                    "删除临时目录'" + strTempDataDir + "'出错:" + ex.Message);
                }

                strResultStartFileName = strStartXmlFileName;
                strResultDataDir       = strDataDir;
                return(0);
            }

            // Debug.Assert(false, "");

            nRet = PathUtil.CopyDirectory(strTempDataDir,
                                          strDataDir,
                                          true,
                                          out strError);
            if (nRet == -1)
            {
                strError = "拷贝临时目录 '" + strTempDataDir + "' 到数据目录'" + strDataDir + "'发生错误:" + strError;
                Debug.Assert(false, "");
                throw new InstallException(strError);
            }

            try
            {
                strResultDataDir = strDataDir;

                // 删除临时目录
                try
                {
                    Directory.Delete(strTempDataDir, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ForegroundWindow.Instance,
                                    "删除临时目录'" + strTempDataDir + "'出错:" + ex.Message);
                }


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

                datasource_dlg.Comment         = "dp2Kernel内核的数据库功能是基于 SQL Server 2000 以上版本实现的。请设置下列SQL Server相关参数。";
                datasource_dlg.StartPosition   = FormStartPosition.CenterScreen;
                datasource_dlg.InstanceName    = strDefaultInstanceName;
                datasource_dlg.KernelLoginName = strDefaultInstanceName; // 2010/12/15
                datasource_dlg.ShowDialog(ForegroundWindow.Instance);
                if (datasource_dlg.DialogResult != DialogResult.OK)
                {
                    strError = "放弃设置数据源,安装未完成。";
                    throw new InstallException(strError);
                }

                string strDatabasesFileName = strDataDir + "\\" + "databases.xml";
                nRet = this.ModifyDatabasesXml(strDatabasesFileName,
                                               datasource_dlg.SqlServerName,
                                               false, // datasource_dlg.SSPI,
                                               datasource_dlg.KernelLoginName,
                                               datasource_dlg.KernelLoginPassword,
                                               datasource_dlg.InstanceName,
                                               out strError);
                if (nRet == -1)
                {
                    throw new InstallException(strError);
                }


                // 设置root密码
                RootUserDlg root_dlg = new RootUserDlg();
                GuiUtil.AutoSetDefaultFont(root_dlg);
                root_dlg.UserName      = "******";
                root_dlg.Rights        = "this:management;children_database:management;children_directory:management;children_leaf:management;descendant_directory:management;descendant_record:management;descendant_leaf:management";
                root_dlg.StartPosition = FormStartPosition.CenterScreen;
                root_dlg.ShowDialog(ForegroundWindow.Instance);
                if (root_dlg.DialogResult != DialogResult.OK)
                {
                    strError = "放弃设置root用户特性,安装未完成。";
                    throw new InstallException(strError);
                }

                nRet = ModifyRootUser(strDataDir,
                                      root_dlg.UserName,
                                      root_dlg.Password,
                                      root_dlg.Rights,
                                      out strError);
                if (nRet == -1)
                {
                    throw new InstallException(strError);
                }


                // 创建start.xml文件
                string strStartXmlFileName = PathUtil.MergePath(strRootDir, "start.xml");
                nRet = this.CreateStartXml(strStartXmlFileName,
                                           strDataDir,
                                           out strError);
                if (nRet == -1)
                {
                    throw new InstallException(strError);
                }



                bFinished = true;

                strResultStartFileName = strStartXmlFileName;
                return(0);
            }
            finally
            {
                if (bFinished == false)
                {
                    try
                    {
                        Directory.Delete(strDataDir, true);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ForegroundWindow.Instance,
                                        "回滚时删除数据目录'" + strDataDir + "'出错:" + ex.Message);
                    }
                }
            }
        }
コード例 #2
0
ファイル: OneInstanceDialog.cs プロジェクト: renyh1013/dp2
        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();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                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();

                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();
            }
            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 以上版本实现。请设置下列 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 = "";
                    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 = "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();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 Oracle 11g 以上版本实现。请设置下列 Oracle 相关参数。";
                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;
        }
コード例 #3
0
ファイル: Installer.cs プロジェクト: renyh1013/dp2
        // 创建数据目录
        public int CreateDataDir(
            string strRootDir,
            string strDefaultInstanceName,
            string strDefaultDataDir,
            out string strResultStartFileName,
            out string strResultDataDir,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            strResultStartFileName = "";
            strResultDataDir = "";

            bool bFinished = false;

            // 要求在temp内准备要安装的数据文件(初次安装而不是升级安装)
            string strTempDataDir = PathUtil.MergePath(strRootDir, "temp");


            REDO_INPUT:
            // 获得数据目录
            DataDirDlg datadir_dlg = new DataDirDlg();
            GuiUtil.AutoSetDefaultFont(datadir_dlg);
            datadir_dlg.Comment = "请指定一个独立的数据目录, 用于存储dp2Kernel内核的各种配置信息。";
            datadir_dlg.MessageBoxTitle = "setup_dp2Kernel";
            datadir_dlg.DataDir = strDefaultDataDir;

            datadir_dlg.StartPosition = FormStartPosition.CenterScreen;
            datadir_dlg.ShowDialog(ForegroundWindow.Instance);
            if (datadir_dlg.DialogResult != DialogResult.OK)
            {
                strError = "用户放弃指定数据目录。安装未完成。";
                throw new InstallException(strError);
            }

            string strDataDir = datadir_dlg.DataDir;

            string strExistingDatabasesFileName = PathUtil.MergePath(strDataDir,
                "databases.xml");

            if (File.Exists(strExistingDatabasesFileName) == true)
            {
                // 从以前的rmsws数据目录升级
                string strText = "数据目录 '" + strDataDir + "' 中已经存在以前的数据库内核版本遗留下来的数据文件。\r\n\r\n确实要利用这个数据目录来进行升级安装么?\r\n(注意:如果利用以前的rmsws的数据目录来进行升级安装,则必须先行卸载rmsws,以避免它和(正在安装的)dp2Kernel同时运行引起冲突)\r\n\r\n(是)继续进行升级安装 (否)重新指定数据目录 (取消)放弃安装";
                DialogResult result = MessageBox.Show(
                    ForegroundWindow.Instance,
    strText,
    "setup_dp2kernel",
    MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Cancel)
                {
                    strError = "用户放弃指定数据目录。安装未完成。";
                    throw new InstallException(strError);
                }

                if (result == DialogResult.No)
                    goto REDO_INPUT;

                // 创建start.xml文件
                string strStartXmlFileName = PathUtil.MergePath(strRootDir, "start.xml");
                nRet = this.CreateStartXml(strStartXmlFileName,
                    strDataDir,
                    out strError);
                if (nRet == -1)
                    throw new InstallException(strError);

                // 删除临时目录
                try
                {
                    Directory.Delete(strTempDataDir, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ForegroundWindow.Instance,
                        "删除临时目录'" + strTempDataDir + "'出错:" + ex.Message);
                }

                strResultStartFileName = strStartXmlFileName;
                strResultDataDir = strDataDir; 
                return 0;
            }

            // Debug.Assert(false, "");

            nRet = PathUtil.CopyDirectory(strTempDataDir,
                strDataDir,
                true,
                out strError);
            if (nRet == -1)
            {
                strError = "拷贝临时目录 '" + strTempDataDir + "' 到数据目录'" + strDataDir + "'发生错误:" + strError;
                Debug.Assert(false, "");
                throw new InstallException(strError);
            }

            try
            {

                strResultDataDir = strDataDir;

                // 删除临时目录
                try
                {
                    Directory.Delete(strTempDataDir, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ForegroundWindow.Instance,
                        "删除临时目录'" + strTempDataDir + "'出错:" + ex.Message);
                }


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

                datasource_dlg.Comment = "dp2Kernel内核的数据库功能是基于 SQL Server 2000 以上版本实现的。请设置下列SQL Server相关参数。";
                datasource_dlg.StartPosition = FormStartPosition.CenterScreen;
                datasource_dlg.InstanceName = strDefaultInstanceName;
                datasource_dlg.KernelLoginName = strDefaultInstanceName; // 2010/12/15
                datasource_dlg.ShowDialog(ForegroundWindow.Instance);
                if (datasource_dlg.DialogResult != DialogResult.OK)
                {
                    strError = "放弃设置数据源,安装未完成。";
                    throw new InstallException(strError);
                }

                string strDatabasesFileName = strDataDir + "\\" + "databases.xml";
                nRet = this.ModifyDatabasesXml(strDatabasesFileName,
                    datasource_dlg.SqlServerName,
                    false, // datasource_dlg.SSPI,
                    datasource_dlg.KernelLoginName,
                    datasource_dlg.KernelLoginPassword,
                    datasource_dlg.InstanceName,
                    out strError);
                if (nRet == -1)
                    throw new InstallException(strError);


                // 设置root密码
                RootUserDlg root_dlg = new RootUserDlg();
                GuiUtil.AutoSetDefaultFont(root_dlg);
                root_dlg.UserName = "******";
                root_dlg.Rights = "this:management;children_database:management;children_directory:management;children_leaf:management;descendant_directory:management;descendant_record:management;descendant_leaf:management";
                root_dlg.StartPosition = FormStartPosition.CenterScreen;
                root_dlg.ShowDialog(ForegroundWindow.Instance);
                if (root_dlg.DialogResult != DialogResult.OK)
                {
                    strError = "放弃设置root用户特性,安装未完成。";
                    throw new InstallException(strError);
                }

                nRet = ModifyRootUser(strDataDir,
                    root_dlg.UserName,
                    root_dlg.Password,
                    root_dlg.Rights,
                    out strError);
                if (nRet == -1)
                    throw new InstallException(strError);


                // 创建start.xml文件
                string strStartXmlFileName = PathUtil.MergePath(strRootDir, "start.xml");
                nRet = this.CreateStartXml(strStartXmlFileName,
                    strDataDir,
                    out strError);
                if (nRet == -1)
                    throw new InstallException(strError);



                bFinished = true;

                strResultStartFileName = strStartXmlFileName;
                return 0;

            }
            finally
            {
                if (bFinished == false)
                {
                    try
                    {
                        Directory.Delete(strDataDir, true);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ForegroundWindow.Instance,
                            "回滚时删除数据目录'" + strDataDir + "'出错:" + ex.Message);
                    }
                }
            }
        }
コード例 #4
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();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

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

                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();
            }
            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 以上版本实现。请设置下列 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 = "";
                    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         = "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();
                GuiUtil.AutoSetDefaultFont(datasource_dlg);

                datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 Oracle 11g 以上版本实现。请设置下列 Oracle 相关参数。";
                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;
        }