Example #1
0
        public override void Uninstall(System.Collections.IDictionary savedState)
        {
            base.Uninstall(savedState);

            string strParameter = this.Context.Parameters["rootdir"];

            if (string.IsNullOrEmpty(strParameter) == true)
            {
                return;
            }

#if OLD_MSI
            String strRootDir = UnQuote(this.Context.Parameters["rootdir"]);

            DialogResult result;

            string strText = "是否完全卸载?\r\n\r\n"
                             + "单击'是',则把全部实例的数据目录删除,所有的库配置信息丢失,所有的实例信息丢失。以后安装时需要重新安装数据目录和数据库。\r\n\r\n"
                             + "单击'否',不删除数据目录,仅卸载执行程序,下次安装时可以继续使用已存在的库配置信息。升级安装前的卸载应选此项。";
            result = MessageBox.Show(ForegroundWindow.Instance,
                                     strText,
                                     "卸载 dp2Kernel",
                                     MessageBoxButtons.YesNo,
                                     MessageBoxIcon.Question,
                                     MessageBoxDefaultButton.Button2);
            if (result == DialogResult.Yes)
            {
                InstanceDialog dlg = new InstanceDialog();
                GuiUtil.AutoSetDefaultFont(dlg);
                dlg.Text          = "彻底卸载所有实例和数据目录";
                dlg.Comment       = "下列实例将被全部卸载。请仔细确认。一旦卸载,全部数据目录和实例信息将被删除,并且无法恢复。";
                dlg.UninstallMode = true;
                dlg.SourceDir     = strRootDir;
                dlg.StartPosition = FormStartPosition.CenterScreen;
                dlg.ShowDialog(ForegroundWindow.Instance);

                if (dlg.DialogResult == DialogResult.Cancel)
                {
                    MessageBox.Show(ForegroundWindow.Instance,
                                    "已放弃卸载全部实例和数据目录。仅仅卸载了执行程序。");
                }
            }

            // InstallHelper.DeleteSetupCfgFile(strRootDir);
#endif
        }
Example #2
0
        public override void Install(System.Collections.IDictionary savedState)
        {
            base.Install(savedState);

            string strParameter = this.Context.Parameters["rootdir"];

            if (string.IsNullOrEmpty(strParameter) == true)
            {
                return;
            }

#if OLD_MSI
            string strRootDir = UnQuote(this.Context.Parameters["rootdir"]);

            Debug.Assert(String.IsNullOrEmpty(strRootDir) == false, "");

            // 可以提示,程序文件已经被刷新

            InstanceDialog dlg = new InstanceDialog();
            GuiUtil.AutoSetDefaultFont(dlg);

            dlg.SourceDir     = strRootDir;
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(ForegroundWindow.Instance);

            if (dlg.DialogResult == DialogResult.Cancel)
            {
                throw new InstallException("用户取消安装。");
            }

            if (dlg.Changed == true)
            {
                // 兑现修改
            }

            // stateSaver["upgrade"] = bUpgrade;
#endif
        }
Example #3
0
        public override void Uninstall(System.Collections.IDictionary savedState)
        {
            base.Uninstall(savedState);

            string strParameter = this.Context.Parameters["rootdir"];
            if (string.IsNullOrEmpty(strParameter) == true)
                return;

#if OLD_MSI
            String strRootDir = UnQuote(this.Context.Parameters["rootdir"]);

            DialogResult result;

            string strText = "是否完全卸载?\r\n\r\n"
                + "单击'是',则把全部实例的数据目录删除,所有的库配置信息丢失,所有的实例信息丢失。以后安装时需要重新安装数据目录和数据库。\r\n\r\n"
                + "单击'否',不删除数据目录,仅卸载执行程序,下次安装时可以继续使用已存在的库配置信息。升级安装前的卸载应选此项。";
            result = MessageBox.Show(ForegroundWindow.Instance,
                strText,
                "卸载 dp2Kernel",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button2);
            if (result == DialogResult.Yes)
            {
                InstanceDialog dlg = new InstanceDialog();
                GuiUtil.AutoSetDefaultFont(dlg);
                dlg.Text = "彻底卸载所有实例和数据目录";
                dlg.Comment = "下列实例将被全部卸载。请仔细确认。一旦卸载,全部数据目录和实例信息将被删除,并且无法恢复。";
                dlg.UninstallMode = true;
                dlg.SourceDir = strRootDir;
                dlg.StartPosition = FormStartPosition.CenterScreen;
                dlg.ShowDialog(ForegroundWindow.Instance);

                if (dlg.DialogResult == DialogResult.Cancel)
                {
                    MessageBox.Show(ForegroundWindow.Instance,
                        "已放弃卸载全部实例和数据目录。仅仅卸载了执行程序。");
                }
            }

            // InstallHelper.DeleteSetupCfgFile(strRootDir);
#endif
        }
Example #4
0
        public override void Install(System.Collections.IDictionary savedState)
        {
            base.Install(savedState);

            string strParameter = this.Context.Parameters["rootdir"];
            if (string.IsNullOrEmpty(strParameter) == true)
                return;

#if OLD_MSI
            string strRootDir = UnQuote(this.Context.Parameters["rootdir"]);

            Debug.Assert(String.IsNullOrEmpty(strRootDir) == false, "");

            // 可以提示,程序文件已经被刷新

            InstanceDialog dlg = new InstanceDialog();
            GuiUtil.AutoSetDefaultFont(dlg);

            dlg.SourceDir = strRootDir;
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(ForegroundWindow.Instance);

            if (dlg.DialogResult == DialogResult.Cancel)
                throw new InstallException("用户取消安装。");

            if (dlg.Changed == true)
            {
                // 兑现修改

            }

            // stateSaver["upgrade"] = bUpgrade;
#endif
        }
Example #5
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            string strError = "";

            // 检查

            // 数据目录
            if (String.IsNullOrEmpty(this.textBox_dataDir.Text) == true)
            {
                strError = "尚未指定数据目录";
                goto ERROR1;
            }

            if (String.IsNullOrEmpty(this.comboBox_sqlServerType.Text) == true)
            {
                strError = "尚未指定 SQL 服务器类型";
                goto ERROR1;
            }

            // sql服务器信息
            if (String.IsNullOrEmpty(this.textBox_sqlDef.Text) == true)
            {
                strError = "尚未指定 SQL 服务器信息";
                goto ERROR1;
            }

            // 协议绑定
            if (String.IsNullOrEmpty(this.textBox_bindings.Text) == true)
            {
                strError = "尚未指定协议绑定信息";
                goto ERROR1;
            }


            if (this.IsNew == true &&
                this.m_bDataDirExist == false)
            {
                // root用户信息
                if (this.LineInfo.RootUserName == null ||
                    this.LineInfo.RootPassword == null ||
                    this.LineInfo.RootUserRights == null)
                {
                    strError = "尚未设定root账户的用户名、密码、权限";
                    goto ERROR1;
                }
            }

            // 如果修改时,需要创建新的数据目录
            if (this.IsNew == false)
            {
                // 探测数据目录,是否已经存在数据,是不是属于升级情形
                // return:
                //      -1  error
                //      0   数据目录不存在
                //      1   数据目录存在,但是xml文件不存在
                //      2   xml文件已经存在
                int nRet = InstanceDialog.DetectDataDir(this.textBox_dataDir.Text,
                                                        out strError);
                if (nRet == -1)
                {
                    strError = "探测数据目录 '" + this.textBox_dataDir.Text + "' 是否存在时,出现错误: " + strError;
                    goto ERROR1;
                }

                if (nRet == 0 || nRet == 1)
                {
                    // root用户信息
                    if (this.LineInfo.RootUserName == null ||
                        this.LineInfo.RootPassword == null ||
                        this.LineInfo.RootUserRights == null)
                    {
                        strError = "尚未设定root账户的用户名、密码、权限";
                        goto ERROR1;
                    }
                }
            }

            // TODO: 如果在编辑状态,需要排除和listview中自己重的情况

            if (this.VerifyInstanceName != null)
            {
                VerifyEventArgs e1 = new VerifyEventArgs();
                e1.Value = this.textBox_instanceName.Text;
                this.VerifyInstanceName(this, e1);
                if (String.IsNullOrEmpty(e1.ErrorInfo) == false)
                {
                    strError = e1.ErrorInfo;
                    goto ERROR1;
                }
            }

            if (this.VerifyDataDir != null)
            {
                VerifyEventArgs e1 = new VerifyEventArgs();
                e1.Value = this.textBox_dataDir.Text;
                this.VerifyDataDir(this, e1);
                if (String.IsNullOrEmpty(e1.ErrorInfo) == false)
                {
                    strError = e1.ErrorInfo;
                    goto ERROR1;
                }
            }

            if (this.VerifyBindings != null)
            {
                VerifyEventArgs e1 = new VerifyEventArgs();
                e1.Value = this.textBox_bindings.Text;
                this.VerifyBindings(this, e1);
                if (String.IsNullOrEmpty(e1.ErrorInfo) == false)
                {
                    strError = e1.ErrorInfo;
                    goto ERROR1;
                }
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
            return;

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