public void SetsFileContent()
        {
            Assert.That(File.Exists(_testFilePath), Is.False);
            var expectedFileContent = Guid.NewGuid().ToString();

            _dataProvider.Save(expectedFileContent);
            var fileContent = File.ReadAllText(_testFilePath);

            Assert.That(fileContent, Is.EqualTo(expectedFileContent));
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        public void Save(ConnectionTreeModel connectionTreeModel, string propertyNameTrigger = "")
        {
            var csvConnectionsSerializer = new CsvConnectionsSerializerMremotengFormat(_saveFilter, Runtime.CredentialProviderCatalog);
            var dataProvider             = new FileDataProvider(_connectionFileName);
            var csvContent = csvConnectionsSerializer.Serialize(connectionTreeModel);

            dataProvider.Save(csvContent);
        }
Exemplo n.º 4
0
        private void SaveToRemoteDesktop2008FormattedCsv()
        {
            var csvSerializer = new CsvConnectionsSerializerRemoteDesktop2008Format();
            var dataProvider  = new FileDataProvider(ConnectionFileName);
            var csvContent    = csvSerializer.Serialize(ConnectionTreeModel);

            dataProvider.Save(csvContent);
        }
Exemplo n.º 5
0
        private void SaveToMremotengFormattedCsv()
        {
            var csvConnectionsSerializer = new CsvConnectionsSerializerMremotengFormat {
                SaveFilter = SaveFilter
            };
            var dataProvider = new FileDataProvider(ConnectionFileName);
            var csvContent   = csvConnectionsSerializer.Serialize(ConnectionTreeModel);

            dataProvider.Save(csvContent);
        }
Exemplo n.º 6
0
        private static void SaveExportFile(string fileName,
                                           SaveFormat saveFormat,
                                           SaveFilter saveFilter,
                                           ConnectionInfo exportTarget)
        {
            try
            {
                ISerializer <ConnectionInfo, string> serializer;
                switch (saveFormat)
                {
                case SaveFormat.mRXML:
                    var cryptographyProvider     = new CryptoProviderFactoryFromSettings().Build();
                    var rootNode                 = exportTarget.GetRootParent() as RootNodeInfo;
                    var connectionNodeSerializer = new XmlConnectionNodeSerializer27(
                        cryptographyProvider,
                        rootNode?.PasswordString
                        .ConvertToSecureString() ??
                        new RootNodeInfo(RootNodeType
                                         .Connection)
                        .PasswordString
                        .ConvertToSecureString(),
                        saveFilter);
                    serializer = new XmlConnectionsSerializer(cryptographyProvider, connectionNodeSerializer);
                    break;

                case SaveFormat.mRCSV:
                    serializer =
                        new CsvConnectionsSerializerMremotengFormat(saveFilter, Runtime.CredentialProviderCatalog);
                    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.ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
            }
        }
Exemplo n.º 7
0
        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();
            }
        }
Exemplo n.º 8
0
 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);
                 ((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();
     }
 }
Exemplo n.º 9
0
 private void SaveToMremotengFormattedCsv()
 {
     var csvConnectionsSerializer = new CsvConnectionsSerializerMremotengFormat { SaveFilter = SaveFilter };
     var dataProvider = new FileDataProvider(ConnectionFileName);
     var csvContent = csvConnectionsSerializer.Serialize(ConnectionTreeModel);
     dataProvider.Save(csvContent);
 }