/// <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> /// Loads the data in the control from a Json string /// </summary> /// <param name="jsonData">The json data.</param> public void LoadJsonData(string jsonData) { SqlConnections = null; SqlConnections = SqlConnectionInfosCollection.Deserialize(jsonData, false); if (this.SqlConnections == null) { this.SqlConnections = new SqlConnectionInfosCollection(); } this.IsInEditMode = false; this.IsChanged = false; }
/// <summary> /// Loads the data from the file given /// </summary> /// <exception cref="Dnw.UI.SqlServer.Models.NoConnectionDataFileException"></exception> /// <exception cref="System.ApplicationException">TODO: load from file</exception> private void Load(string fileName) { if (!fileName.XDwIsNullOrTrimEmpty()) { this.SqlConnections = null; this.SqlConnections = SqlConnectionInfosCollection.Deserialize(fileName); if (this.SqlConnections == null) { this.SqlConnections = new SqlConnectionInfosCollection(); } this.IsInEditMode = false; this.IsChanged = false; } else { throw new NoConnectionDataFileException(SqlConnectionInfoModelRx.excSCIMNoFileToLoad); } }