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(); } } }
private static void SaveExportFile(string fileName, ConnectionsSaver.Format saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget) { try { ISerializer <string> serializer; switch (saveFormat) { case ConnectionsSaver.Format.mRXML: serializer = new XmlConnectionsSerializer(); ((XmlConnectionsSerializer)serializer).SaveFilter = saveFilter; break; case ConnectionsSaver.Format.mRCSV: serializer = new CsvConnectionsSerializerMremotengFormat(); ((CsvConnectionsSerializerMremotengFormat)serializer).SaveFilter = saveFilter; break; default: throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null); } var serializedData = serializer.Serialize(exportTarget); var fileDataProvider = new FileDataProvider(fileName); fileDataProvider.Save(serializedData); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex); } finally { Runtime.RemoteConnectionsSyncronizer?.Enable(); } }
private static void SaveExportFile(string fileName, ConnectionsSaver.Format saveFormat, SaveFilter saveFilter, ConnectionInfo exportTarget) { try { ISerializer <string> serializer; switch (saveFormat) { case ConnectionsSaver.Format.mRXML: var factory = new CryptographyProviderFactory(); var cryptographyProvider = factory.CreateAeadCryptographyProvider(mRemoteNG.Settings.Default.EncryptionEngine, mRemoteNG.Settings.Default.EncryptionBlockCipherMode); cryptographyProvider.KeyDerivationIterations = Settings.Default.EncryptionKeyDerivationIterations; serializer = new XmlConnectionsSerializer(cryptographyProvider) { Export = true, SaveFilter = saveFilter }; break; case ConnectionsSaver.Format.mRCSV: serializer = new CsvConnectionsSerializerMremotengFormat { SaveFilter = saveFilter }; break; default: throw new ArgumentOutOfRangeException(nameof(saveFormat), saveFormat, null); } var serializedData = serializer.Serialize(exportTarget); var fileDataProvider = new FileDataProvider(fileName); fileDataProvider.Save(serializedData); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace($"Export.SaveExportFile(\"{fileName}\") failed.", ex); } finally { Runtime.RemoteConnectionsSyncronizer?.Enable(); } }
public ExportFormat(ConnectionsSaver.Format format) { Format = format; }