コード例 #1
0
ファイル: MainForm.cs プロジェクト: TomasBouda/EasyDB
        private void BackupSelectedScript()
        {
            if (listDbObjects.FocusedItem?.Tag != null)
            {
                var dbObject = listDbObjects.FocusedItem.Tag as IDbObject;

                if (DataProvider.ActiveManager.IsView(dbObject))
                {
                    dbObject = DataProvider.ActiveManager.View(dbObject);
                }
                else if (DataProvider.ActiveManager.IsStoredProcedure(dbObject))
                {
                    dbObject = DataProvider.ActiveManager.StoredProcedure(dbObject);
                }
                else
                {
                    return;
                }

                Tuple <string, string> output;
                if (FileHelper.BackupScript(dbObject.Name, dbObject.Script, out output))
                {
                    EasyMessageBox.MessageWithActions(
                        "Script saved",
                        $"Script saved successfully.\r\n{output.Item1}",
                        "OK",
                        new ActionButton(() => Process.Start(output.Item1), "Open File"),
                        new ActionButton(() => Process.Start(output.Item2), "Open Dir")
                        );
                }
                else
                {
                    EasyMessageBox.Error($"Error occured while saving file.\n{output.Item1}");
                }
            }
        }