public override void Run() { string path = FileService.SaveFile(Res.GetString("TITLE_SAVE_CONNECTION"), Res.GetString("FILTER_CONNECTION_FILE")); if (!string.IsNullOrEmpty(path)) { TreeNode connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode(); FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>(); FdoConnection conn = mgr.GetConnection(connNode.Name); conn.Save(path); Log.InfoFormatted("Connection saved to: {0}", path); } }
/// <summary> /// Saves all currently loaded connections to the session directory /// </summary> public void Save() { string path = Preferences.SessionDirectory; if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } else { string [] files = System.IO.Directory.GetFiles(path, "*.conn"); foreach (string f in files) { System.IO.File.Delete(f); } files = System.IO.Directory.GetFiles(path, "*.xml"); foreach (string f in files) { System.IO.File.Delete(f); } string[] directories = System.IO.Directory.GetDirectories(path); foreach (string dir in directories) { System.IO.Directory.Delete(dir, true); } } foreach (string key in _ConnectionDict.Keys) { string file = System.IO.Path.Combine(path, key + ".conn"); string dir = System.IO.Path.GetDirectoryName(file); if (!System.IO.Directory.Exists(dir)) { System.IO.Directory.CreateDirectory(dir); } FdoConnection conn = _ConnectionDict[key]; conn.Save(file); } }