예제 #1
0
        private bool LoadFile()
        {
            fbd = fbd ?? new FolderBrowserDialog()
            {
                Description = "选择脚本所在文件夹",
            };

            if (fbd.ShowDialog(this) == DialogResult.OK)
            {
                this.context.Path = fbd.SelectedPath;
                isChooseScriptDir = true;
                lblInfo2          = $"脚本目录:\r\n{this.context.Path}";
                welcome.SetLabel(lblInfo, lblInfo2);

                this.context.Files = SqlAdoExecutor.GetFiles(context.Path);
                if (this.context.Files != null && this.context.Files.Any())
                {
                    return(true);
                }
                else
                {
                    MessageBox.Show(this, "您选择的文件夹不包含脚本,或者未按规定方式组织脚本,\r\n请重新选择目录。", "提示", MessageBoxButtons.OK);
                    return(false);
                }
            }

            welcome.SetLabel(lblInfo, lblInfo2);
            return(false);
        }
예제 #2
0
        private void BtnOpen_Click(object sender, EventArgs e)
        {
            this.context.Path             = @"E:\Tests\TestScripts";
            this.context.Files            = SqlAdoExecutor.GetFiles(context.Path);
            this.context.ConnectionString =
                "data source=.;initial catalog=test;user id=sa;password=111111;MultipleActiveResultSets=True";
            GoToNext();
            return;

            if (this.LoadFile() && isConfigDb)
            {
                GoToNext();
            }
        }
예제 #3
0
        private static void TestSqlAdo()
        {
            var ctx = new Context()
            {
                AppInfo  = new AppInfo(false),
                InstInfo = new InstInfo()
                {
                    InstallPath = @"F:\\Test"
                }
            };
            var insCtx = new InstallContext(ctx);
            var tr     = new SqlAdoExecutor();

            tr.SetContext(insCtx, new Log(), "", @"E:\Tests\TestScripts");
            tr.Run();
            tr.Rollback();
        }
예제 #4
0
        private void Begin()
        {
            this.pnlControl.Enabled = false;
            var process = pnlMain.Controls.OfType <FrmInstall>().FirstOrDefault();

            if (process == null)
            {
                return;
            }

            isInstalling = true;
            Global.Log   = process;
            var installer = new SqlAdoExecutor();

            installer.SetOwner(this);
            installer.Init(this.context, process);
            process.SetMaxValue(installer.GetProcessValue(), 0);
            if (!installer.Run())
            {
                if (installer.CommandStatus == CommandStatus.Running &&
                    MessageBox.Show(this, "脚本执行出错,是否需要还原?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    installer.Rollback();
                }
            }
            else
            {
                process.Complete();
            }

            this.pnlControl.Enabled = true;
            this.btnPrev.Enabled    = false;
            this.btnCancel.Enabled  = false;
            isInstalling            = false;
            isRunned = true;
        }