コード例 #1
0
        public void Database_Deploy()
        {
            ExpressionEditor_AcceptEdit();

            var f = new DeployForm();

            f.PreselectDb = LastDeploymentDb;
            var res = f.ShowDialog();

            if (res == DialogResult.Cancel)
            {
                return;
            }

            LastDeploymentDb = f.PreselectDb;

            // Backup database metadata
            if (Preferences.Current.BackupOnSave)
            {
                var backupFilename = string.Format("{0}\\Backup_{1}_{2}.zip", Preferences.Current.BackupLocation, Handler.Database.Name, DateTime.Now.ToString("yyyyMMddhhmmssfff"));
                TabularDeployer.SaveModelMetadataBackup(f.DeployTargetServer.ConnectionString, f.DeployTargetDatabaseID, backupFilename);
            }


            UI.StatusLabel.Text = "Deploying...";
            Application.DoEvents();
            using (new Hourglass())
            {
                bool   cancelled = false;
                bool   error     = false;
                string message   = "";

                using (var df = new DeployingForm())
                {
                    df.DeployAction = () =>
                    {
                        try
                        {
                            Program.UpdateDeploymentMetadata(Handler.Model, DeploymentModeMetadata.WizardUI);
                            TabularDeployer.Deploy(Handler, f.DeployTargetServer.ConnectionString, f.DeployTargetDatabaseID, f.DeployOptions, df.CancelToken);
                        }
                        catch (Exception ex)
                        {
                            cancelled = df.CancelToken.IsCancellationRequested;
                            error     = !cancelled;
                            message   = ex.Message;
                            df.ThreadClose();
                        }
                    };
                    df.ShowDialog();
                }

                if (error || cancelled)
                {
                    MessageBox.Show(message, error ? "Error occured during deployment" : "Deploy cancelled", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                UI.StatusLabel.Text = error ? "Deploy failed!" : cancelled ? "Deploy cancelled!" : "Deploy succeeded!";
            }
        }
コード例 #2
0
ファイル: Publish.cs プロジェクト: thxu/TPublish
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                var projInfo = ThreadHelper.JoinableTaskFactory.Run(GetSelectedProjInfoAsync);
                if (projInfo == null)
                {
                    throw new Exception("您还未选中项目");
                }

                if (projInfo.Kind != "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
                {
                    throw new Exception("当前插件仅支持C#程序");
                }

                var projModel = projInfo.AnalysisProject();
                if (projModel == null)
                {
                    throw new Exception("项目信息解析失败");
                }

                OptionPageGrid settingInfo = PublishService.GetSettingPage();
                if (string.IsNullOrWhiteSpace(settingInfo?.IpAdress))
                {
                    throw new Exception("请先完善设置信息");
                }

                // 尝试连接服务器
                //var isConnected = PublishService.CheckConnection();
                //if (!isConnected)
                //{
                //    throw new Exception("尝试连接服务器失败");
                //}

                //var publishForm = new PublishForm();
                //publishForm.Show();
                //publishForm.Ini(projModel);

                var form   = new DeployForm();
                var iniRes = form.Ini(projModel);
                if (iniRes.IsSucceed)
                {
                    form.Show();
                }
                else
                {
                    MessageBox.Show(iniRes.Message);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
コード例 #3
0
        public void Database_Deploy()
        {
            ExpressionEditor_AcceptEdit();

            var f   = new DeployForm();
            var res = f.ShowDialog();

            if (res == DialogResult.Cancel)
            {
                return;
            }

            // Backup database metadata
            if (Preferences.Current.BackupOnSave)
            {
                var backupFilename = string.Format("{0}\\Backup_{1}_{2}.zip", Preferences.Current.BackupLocation, Handler.Database.Name, DateTime.Now.ToString("yyyyMMddhhmmssfff"));
                TabularDeployer.SaveModelMetadataBackup(f.DeployTargetServer.ConnectionString, f.DeployTargetDatabaseID, backupFilename);
            }


            UI.StatusLabel.Text = "Deploying...";
            Application.DoEvents();
            using (new Hourglass())
            {
                var df    = new DeployingForm();
                var error = false;
                df.DeployAction = () =>
                {
                    try
                    {
                        TabularDeployer.Deploy(Handler, f.DeployTargetServer.ConnectionString, f.DeployTargetDatabaseID, f.DeployOptions);
                    }
                    catch (Exception ex)
                    {
                        error = true;
                        df.ThreadClose();
                        MessageBox.Show(ex.Message, "Error occured during deployment", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                };
                df.ShowDialog();
                UI.StatusLabel.Text = error ? "Deploy failed!" : "Deploy succeeded!";
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: thxu/TPublish
        static void Main()
        {
            string[] args = Environment.GetCommandLineArgs();
            //MessageBox.Show($"{args.Length},{args[0]},{args[1]}");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (args.Length == 2)
            {
                ProjectModel model = ProjectHelper.ParseProject(args[1]);
                if (model == null)
                {
                    MessageBox.Show("项目解析失败");
                    return;
                }
                model.ProjType = 1;
                //ProjectModel model = new ProjectModel()
                //{
                //    Key = "abed0270-e96c-45b5-b513-785ba08fc0c8",
                //    //NetFrameworkVersion = "net45",
                //    //ProjName = "ConsoleApp1",
                //    //ProjPath = @"E:\Code\C#\Test\Test\ConsoleApp1\ConsoleApp1.csproj",
                //    //NetFrameworkVersion = "netcoreapp2.2",
                //    ProjName = "ConsoleApp3.0_NetCore",
                //    ProjPath = @"E:\Code\C#\Test\Test\ConsoleApp3.0_NetCore\ConsoleApp3.0_NetCore.csproj",
                //    OutPutType = "Library",
                //    ProjType = 0,
                //};
                var form = new DeployForm(model);
                form.Activate();
                Application.Run(form);
            }
            else
            {
                Application.Run(new DeployForm(new ProjectModel()
                {
                    Key = Guid.NewGuid().ToString()
                }));
            }
        }
コード例 #5
0
        private void btnDeploy_Click(object sender, EventArgs e)
        {
            DeployForm deployForm = new DeployForm();

            deployForm.Show();
        }