private void btnSave_Click(object sender, EventArgs e) { if (_selectedConnections.Count == 0) { Utils.ShowWarning("Connection list is empty.", MessageBoxButtons.OK); return; } string templatesFolder = MultiExecSpec.TemplatesDirectory; if (!Directory.Exists(templatesFolder)) { Directory.CreateDirectory(templatesFolder); } string templateName = tbName.Text.Trim(); if (_isNewTemplate && String.IsNullOrEmpty(templateName)) { Utils.ShowError("Template name is empty!", MessageBoxButtons.OK); return; } string fileName = templatesFolder + templateName + MultiExecSpec.TemplateFileExt; if (_isNewTemplate && File.Exists(fileName)) { Utils.ShowError(String.Format("Template with name \'{0}\' already exists!", tbName.Text), MessageBoxButtons.OK); return; } MultiExecSpec.Save(_selectedConnections, fileName); DialogResult = DialogResult.OK; }
private void LoadSelectedTemplate() { try { toolStrip1.Enabled = false; ClearConnectionListView(); if (cmbTemplates.SelectedIndex == 0) { return; } string templateFileName = SelectedTemplateFileName; if (!File.Exists(templateFileName)) { Utils.ShowError(String.Format("Template file does not exist.\r\n{0}", templateFileName), MessageBoxButtons.OK); return; } _selectedConnections = MultiExecSpec.Load(templateFileName); RenderConnectionsInListView(_selectedConnections); } finally { toolStrip1.Enabled = true; } }
private void saveAsDefaultToolStripMenuItem_Click(object sender, EventArgs e) { if (_selectedConnections == null || _selectedConnections.Count == 0) { Utils.ShowWarning("Connection list is empty.", MessageBoxButtons.OK); return; } MultiExecSpec.Save(_selectedConnections, MultiExecSpec.DefaultTemplate); }
private void PrepareEdit(string templateName) { string templateFile = MultiExecSpec.TemplatesDirectory + templateName + MultiExecSpec.TemplateFileExt; try { _initializing = true; tbName.Text = templateName; _selectedConnections = MultiExecSpec.Load(templateFile); PopulateServers(); PopulateDatabases(); RenderConnectionsInListView(_selectedConnections); } finally { _initializing = false; } }
private void LoadDefaultTemplate(bool showNoDefaultInfo) { if (!File.Exists(MultiExecSpec.DefaultTemplate)) { ClearConnectionListView(); if (showNoDefaultInfo) { Utils.ShowInfo("Default connection list template not defined.\r\nPlease load a template and use Default -> Save As Default to save a default connection list template.", MessageBoxButtons.OK); } return; } _selectedConnections = MultiExecSpec.Load(MultiExecSpec.DefaultTemplate); _loadingTemplates = true; cmbTemplates.SelectedIndex = 0; _loadingTemplates = false; RenderConnectionsInListView(_selectedConnections); }