private string GetSelectedTemplateFile(bool fullPath) { if (this.optOpenTemplateFromFile.Checked) { return(this.cmbPathToFile.Text); } if (this.optSelectExistTemplate.Checked) { Template template = this.cmbTemplate.SelectedItem as Template; if (template == null) { return(string.Empty); } string templateName = TemplateNodesLoader.GetTemplateById(template.Id).Item1; string path = Settings.TemplateDirectory + @"\" + templateName; if (fullPath) { path = Environment.CurrentDirectory + @"\" + path; } return(path); } return(string.Empty); }
public InternalSqliteConnectionDialog(MsSqlAuditorModel model) { this._model = model; this._storage = model.DefaultVaultProcessor.CurrentStorage; this._connectionsManager = new ConnectionsManager(model); this._loginManager = new LoginManager(this._storage); this._templateManager = new TemplateManager(this._storage); this._templates = TemplateNodesLoader.GetTemplates(); InitializeComponent(); List <BindingWrapper <ConnectionType> > connectionTypes = this._model.ConnectionTypes; this.dataTypeBindingSource.DataSource = connectionTypes; this.dataTypeBindingSource.DataMember = "Item"; this.cmbDataType.DataSource = dataTypeBindingSource.DataSource; this.cmbDataType.SelectionChangeCommitted += this.cmbDataType_SelectedIndexChanged; this.cmbConnectionGroup.SelectionChangeCommitted += this.cmbConnectionGroup_SelectedIndexChanged; this.cmbServerInstance.SelectionChangeCommitted += this.cmbServerInstance_SelectedIndexChanged; this.cmbTemplate.SelectionChangeCommitted += this.cmbTemplate_SelectedIndexChanged; this.cmbLogin.SelectionChangeCommitted += this.cmbLogin_SelectedIndexChanged; if (connectionTypes.Count > 0) { UpdateConnectionGroupList(); } UpdateButtonsState(); }
//void ReloadConectionGroupInfos() //{ // var filenames = _filesProvider.GetConnectionsFilenames(); // _connections = new List<ConnectionGroupInfo>(); // foreach (var filename in filenames) // { // _connections.AddRange(ConnectionsLoader.LoadFromXml(filename)); // } //} /// <summary> /// Load Template /// </summary> /// <param name="filename">Xml-file name</param> /// <param name="connectionGroup"></param> /// <param name="isExternal">Is opened from user file template</param> /// <returns>Tree template</returns> public TemplateNodeInfo LoadTemplateNodes( string filename, bool isExternal, out string startupTemplateId, out Stack <string> startupTemplateInfoIdStack ) { if (!File.Exists(filename)) { throw new FileNotFoundException("Template needed!"); } var doc = new XmlDocument(); doc.Load(filename); if (AppVersionHelper.IsNotDebug() && !isExternal) { var cryptoProcessor = new CryptoProcessor( this.Settings.SystemSettings.PublicKeyXmlSign, this.Settings.SystemSettings.PrivateKeyXmlDecrypt ); cryptoProcessor.DecryptXmlDocument(doc); } return(TemplateNodesLoader.LoadFromXml(this, doc, out startupTemplateId, out startupTemplateInfoIdStack)); }
private void mnuNewDirectConnection_Click(object sender, EventArgs e) { using (CreateDirectConnectionDialog createConnectionDialog = new CreateDirectConnectionDialog(this._model)) { if (createConnectionDialog.ShowDialog() == DialogResult.OK) { ConnectionData connectionData = createConnectionDialog.ResultConnection; ConnectionGroupInfo group = connectionData.ConnectionGroup; Template selectedTemplate = TemplateNodesLoader.GetTemplateByFile( createConnectionDialog.SelectedTemplateFileFullPath ); ConnectionTabControl targetTab = GetTargetTab( group.Name + " {" + group.TemplateFileName + "}" ); targetTab.SelectedTemplate = selectedTemplate; targetTab.OpenConnection(group); } } }
private void frmMain_Load(object sender, EventArgs e) { try { setTitle(null, null); this._systemMenu = new SystemMenu(this); this._systemMenu.AppendSeparator(); this._showHideMainMenuLineItem = this._systemMenu.AppendNewItem("", (s, args) => { this._model.Settings.ShowMainMenu = !this._model.Settings.ShowMainMenu; UpdateMainMenuVisibility(this._model.Settings, null); }); UpdateShowHideMainMenuLineItem(); if (this.isDisableMainMenu) { this._model.Settings.ShowMainMenu = false; UpdateMainMenuVisibility(this._model.Settings, true); } RestoreSizeAndLocation(this._model.Settings); this._model.SettingsChanged += (o, args) => ApplySettings(); if (strServerName != null && strTemplate != null && strDatabaseType != null) { // log.DebugFormat( // "strServerName:'{0}';strTemplate:'{1}';strDatabaseType:'{2}'", // strServerName ?? "<Null>", // strTemplate ?? "<Null>", // strDatabaseType ?? "<Null>" // ); InstanceInfo instanceInfo = new InstanceInfo { Authentication = new AuthenticationInfo { IsWindows = true, Password = string.Empty, Username = string.Empty }, Instance = strServerName, IsEnabled = true, Name = strServerName, IsODBC = false, DbType = strDatabaseType }; ConnectionGroupInfo connectionGroupInfo = new ConnectionGroupInfo(); connectionGroupInfo.Connections.Add(instanceInfo); string strTemplateFileName = Path.GetFileName(strTemplate); string strFullPathToTemplateFile = Path.GetFullPath(strTemplate); string strTemplateDir = Path.GetDirectoryName(strTemplate); if (string.IsNullOrEmpty(strTemplateDir)) { strTemplateDir = Program.Model.Settings.TemplateDirectory; strFullPathToTemplateFile = Path.GetFullPath(strTemplateDir + "\\" + strTemplate); connectionGroupInfo.IsExternal = false; } else { connectionGroupInfo.IsExternal = true; } connectionGroupInfo.IsDirectConnection = true; connectionGroupInfo.TemplateDir = strTemplateDir; connectionGroupInfo.TemplateFileName = strTemplateFileName; connectionGroupInfo.Name = strServerName; var targetTab = GetTargetTab(connectionGroupInfo.Name + "{" + connectionGroupInfo.TemplateFileName + "}"); Template selectedTemplate = TemplateNodesLoader.GetTemplateByFile(strFullPathToTemplateFile); targetTab.SelectedTemplate = selectedTemplate; targetTab.OpenConnection(connectionGroupInfo); } } catch (Exception ex) { log.Error(ex); } }