private static void SaveExportFile(string fileName, ConnectionsSaver.Format saveFormat, TreeNode rootNode, Security.Save saveSecurity) { try { if (Runtime.SQLConnProvider != null) { Runtime.SQLConnProvider.Disable(); } ConnectionsSaver connectionsSave = new ConnectionsSaver(); connectionsSave.Export = true; connectionsSave.ConnectionFileName = fileName; connectionsSave.SaveFormat = saveFormat; connectionsSave.ConnectionList = Runtime.ConnectionList; connectionsSave.ContainerList = Runtime.ContainerList; connectionsSave.RootTreeNode = rootNode; connectionsSave.SaveSecurity = saveSecurity; connectionsSave.SaveConnections(); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionMessage(string.Format("Export.SaveExportFile(\"{0}\") failed.", fileName), ex); } finally { if (Runtime.SQLConnProvider != null) { Runtime.SQLConnProvider.Enable(); } } }
public static void SaveConnectionsAs() { ConnectionsSaver connectionsSave = new ConnectionsSaver(); try { if (SQLConnProvider != null) { SQLConnProvider.Disable(); } using (SaveFileDialog saveFileDialog = new SaveFileDialog()) { saveFileDialog.CheckPathExists = true; saveFileDialog.InitialDirectory = ConnectionsFileInfo.DefaultConnectionsPath; saveFileDialog.FileName = ConnectionsFileInfo.DefaultConnectionsFile; saveFileDialog.OverwritePrompt = true; List <string> fileTypes = new List <string>(); fileTypes.AddRange(new[] { Language.strFiltermRemoteXML, "*.xml" }); fileTypes.AddRange(new[] { Language.strFilterAll, "*.*" }); saveFileDialog.Filter = string.Join("|", fileTypes.ToArray()); if (saveFileDialog.ShowDialog(frmMain.Default) != DialogResult.OK) { return; } connectionsSave.SaveFormat = ConnectionsSaver.Format.mRXML; connectionsSave.ConnectionFileName = saveFileDialog.FileName; connectionsSave.Export = false; connectionsSave.SaveSecurity = new Security.Save(); connectionsSave.ConnectionList = ConnectionList; connectionsSave.ContainerList = ContainerList; connectionsSave.RootTreeNode = Windows.treeForm.tvConnections.Nodes[0]; connectionsSave.SaveConnections(); if (saveFileDialog.FileName == GetDefaultStartupConnectionFileName()) { Settings.Default.LoadConsFromCustomLocation = false; } else { Settings.Default.LoadConsFromCustomLocation = true; Settings.Default.CustomConsPath = saveFileDialog.FileName; } } } catch (Exception ex) { MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotSaveAs, connectionsSave.ConnectionFileName), ex); } finally { SQLConnProvider?.Enable(); } }
public RemoteConnectionsSyncronizer(IConnectionsUpdateChecker updateChecker) { _updateChecker = updateChecker; _updateTimer = new Timer(3000); _connectionsLoader = new ConnectionsLoader { UseDatabase = mRemoteNG.Settings.Default.UseSQLServer }; _connectionsSaver = new ConnectionsSaver { SaveFormat = ConnectionsSaver.Format.SQL }; SetEventListeners(); }
public static void SaveConnections(bool Update = false) { if (!IsConnectionsFileLoaded) { return; } try { if (Update && Settings.Default.UseSQLServer == false) { return; } if (SQLConnProvider != null) { SQLConnProvider.Disable(); } ConnectionsSaver conS = new ConnectionsSaver(); if (!Settings.Default.UseSQLServer) { conS.ConnectionFileName = GetStartupConnectionFileName(); } conS.ConnectionList = ConnectionList; conS.ContainerList = ContainerList; conS.Export = false; conS.SaveSecurity = new Security.Save(); conS.RootTreeNode = Windows.treeForm.tvConnections.Nodes[0]; if (Settings.Default.UseSQLServer) { conS.SaveFormat = ConnectionsSaver.Format.SQL; conS.SQLHost = Convert.ToString(Settings.Default.SQLHost); conS.SQLDatabaseName = Convert.ToString(Settings.Default.SQLDatabaseName); conS.SQLUsername = Convert.ToString(Settings.Default.SQLUser); var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); conS.SQLPassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), GeneralAppInfo.EncryptionKey); } conS.SaveConnections(); if (Settings.Default.UseSQLServer) { LastSqlUpdate = DateTime.Now; } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionsFileCouldNotBeSaved + Environment.NewLine + ex.Message); } finally { SQLConnProvider?.Enable(); } }
public static void SaveConnectionsAs() { var connectionsSave = new ConnectionsSaver(); try { RemoteConnectionsSyncronizer?.Disable(); using (var saveFileDialog = new SaveFileDialog()) { saveFileDialog.CheckPathExists = true; saveFileDialog.InitialDirectory = ConnectionsFileInfo.DefaultConnectionsPath; saveFileDialog.FileName = ConnectionsFileInfo.DefaultConnectionsFile; saveFileDialog.OverwritePrompt = true; var fileTypes = new List <string>(); fileTypes.AddRange(new[] { Language.strFiltermRemoteXML, "*.xml" }); fileTypes.AddRange(new[] { Language.strFilterAll, "*.*" }); saveFileDialog.Filter = string.Join("|", fileTypes.ToArray()); if (saveFileDialog.ShowDialog(frmMain.Default) != DialogResult.OK) { return; } connectionsSave.SaveFormat = ConnectionsSaver.Format.mRXML; connectionsSave.ConnectionFileName = saveFileDialog.FileName; connectionsSave.Export = false; connectionsSave.SaveFilter = new SaveFilter(); connectionsSave.ConnectionTreeModel = ConnectionTreeModel; connectionsSave.SaveConnections(); if (saveFileDialog.FileName == GetDefaultStartupConnectionFileName()) { Settings.Default.LoadConsFromCustomLocation = false; } else { Settings.Default.LoadConsFromCustomLocation = true; Settings.Default.CustomConsPath = saveFileDialog.FileName; } } } catch (Exception ex) { MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotSaveAs, connectionsSave.ConnectionFileName), ex); } finally { RemoteConnectionsSyncronizer?.Enable(); } }
public static void SaveConnections(bool update = false) { if (ConnectionTreeModel == null) { return; } try { if (update && Settings.Default.UseSQLServer == false) { return; } RemoteConnectionsSyncronizer?.Disable(); var connectionsSaver = new ConnectionsSaver(); if (!Settings.Default.UseSQLServer) { connectionsSaver.ConnectionFileName = GetStartupConnectionFileName(); } connectionsSaver.Export = false; connectionsSaver.SaveFilter = new SaveFilter(); connectionsSaver.ConnectionTreeModel = ConnectionTreeModel; if (Settings.Default.UseSQLServer) { connectionsSaver.SaveFormat = ConnectionsSaver.Format.SQL; connectionsSaver.SQLHost = Convert.ToString(Settings.Default.SQLHost); connectionsSaver.SQLDatabaseName = Convert.ToString(Settings.Default.SQLDatabaseName); connectionsSaver.SQLUsername = Convert.ToString(Settings.Default.SQLUser); var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); connectionsSaver.SQLPassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), EncryptionKey); } connectionsSaver.SaveConnections(); if (Settings.Default.UseSQLServer) { LastSqlUpdate = DateTime.Now; } } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionsFileCouldNotBeSaved + Environment.NewLine + ex.Message); } finally { RemoteConnectionsSyncronizer?.Enable(); } }
public RemoteConnectionsSyncronizer(IConnectionsUpdateChecker updateChecker) { _updateChecker = updateChecker; _updateTimer = new Timer(3000); _connectionsLoader = new ConnectionsLoader { UseDatabase = mRemoteNG.Settings.Default.UseSQLServer }; _connectionsSaver = new ConnectionsSaver { SaveFormat = ConnectionsSaver.Format.SQL }; SetEventListeners(); }