/// <summary> /// Imports the content of a connections file and adds them to the current collection /// </summary> public void Import(ImportExportData data) { try { string content = null; if (data.Encrypt) { content = EncDec.Decrypt(data.FileName, true); } else { content = File.ReadAllText(data.FileName); } SqlConnectionInfosCollection imported = SqlConnectionInfosCollection.Deserialize(content, false); if (imported.Count > 0) { foreach (SqlConnectionInfo item in imported) { SqlConnections.Add(item); } } IsChanged = true; } catch (Exception ex) { EventLogger.SendMsg(ex); throw; } }
/// <summary> /// Adds a new element to the connections collection and /// activates editing on it. /// </summary> public void AddNew() { IsInEditMode = true; SqlConnectionInfo newItem = new SqlConnectionInfo(); SqlConnections.Add(newItem); CurrentConnection = newItem; IsChanged = true; }
/// <summary> /// Clones the current connection in a new one /// </summary> public void Clone() { if (CurrentConnection != null) { SqlConnectionInfo newItem = CurrentConnection.Clone(); newItem.ConnectionID += "(Copy)"; SqlConnections.Add(newItem); CurrentConnection = newItem; IsInEditMode = true; IsChanged = true; } }