public void SetUp()
        {
            _fakeReaderProvider = Substitute.For <IDataReaderProvider>();
            _fakeReader         = Substitute.For <IDataReader>();

            _provider = new FileDataProvider(_fakeReaderProvider);
        }
Beispiel #2
0
        private static void ProcessKey(string key)
        {
            IDataProvider   dataProvider   = new FileDataProvider();
            ISearchStrategy searchStrategy = new EndsWithSearchStrategy(dataProvider);
//			ISearchStrategy	searchStrategy = new StartsWithSearchStrategy(dataProvider);
//			ISearchStrategy	searchStrategy = new WholeWordSearchStrategy(dataProvider);

            var result = searchStrategy.PerformSearch(key);

            Console.WriteLine("Search results: ");

            if (!result.Any() || result.Count == 0)
            {
                string noMatchesSign = ConfigurationManager.AppSettings["NoMathchesSign"] ?? "-";
                Console.WriteLine(noMatchesSign);
            }
            else
            {
                Console.WriteLine($"Count of matches: {result.Count}");
                foreach (var match in result)
                {
                    Console.WriteLine(match);
                }
            }
        }
Beispiel #3
0
        public Daisy3_Import(string bookfile, string outDir, bool skipACM, SampleRate audioProjectSampleRate, bool stereo, bool autoDetectPcmFormat, bool xukPrettyFormat)
        {
            m_XukPrettyFormat = xukPrettyFormat;

            m_SkipACM = skipACM;
            m_audioProjectSampleRate = audioProjectSampleRate;
            m_audioStereo            = stereo;
            m_autoDetectPcmFormat    = autoDetectPcmFormat;

            reportProgress(10, UrakawaSDK_daisy_Lang.InitializeImport);

            m_PackageUniqueIdAttr = null;
            m_Book_FilePath       = bookfile;
            m_outDirectory        = outDir;
            if (!m_outDirectory.EndsWith("" + Path.DirectorySeparatorChar))
            {
                m_outDirectory += Path.DirectorySeparatorChar;
            }

            if (!Directory.Exists(m_outDirectory))
            {
                FileDataProvider.CreateDirectory(m_outDirectory);
            }

            m_Xuk_FilePath = GetXukFilePath(m_outDirectory, m_Book_FilePath, null, false);

            if (RequestCancellation)
            {
                return;
            }
            //initializeProject();

            //reportProgress(100, UrakawaSDK_daisy_Lang.ImportInitialized);
        }
Beispiel #4
0
        public async Task Test_FileDataProvider_LoopAsync()
        {
            var loop = new Loop()
            {
                Id = 1
            };

            loop.Inner = loop;

            var fdp = new FileDataProvider()
            {
                DirectoryPath   = _directory,
                FilenameBuilder = x => x.EventType
            };

            Configuration.DataProvider = fdp;
            var guid = "x" + Guid.NewGuid().ToString();

            await new AuditScopeFactory().CreateAsync(new AuditScopeOptions(guid, extraFields: loop, isCreateAndSave: true));

            var ev = await fdp.GetEventAsync(Path.Combine(_directory, guid));

            Assert.IsNotNull(ev);
            Assert.AreEqual(guid, ev.EventType);
            Assert.AreEqual(2, ev.CustomFields.Count);
            Assert.AreEqual(1, ev.CustomFields["Id"]);
            Assert.AreEqual("{\r\n  \"Id\": 1\r\n}", ev.CustomFields["Inner"].ToString());
        }
 static Configuration()
 {
     AuditDisabled  = false;
     DataProvider   = new FileDataProvider();
     CreationPolicy = EventCreationPolicy.InsertOnEnd;
     ResetCustomActions();
 }
Beispiel #6
0
        public static string GetXukFilePath_SpineItem(string outputDirectory, string relativeFilePath, string title, int index)
        {
            relativeFilePath = FileDataProvider.EliminateForbiddenFileNameCharacters(relativeFilePath);

            string extension       = Path.GetExtension(relativeFilePath);
            string croppedFileName = Path.GetFileNameWithoutExtension(relativeFilePath);

            if (croppedFileName.Length > 12)
            {
                croppedFileName = croppedFileName.Substring(0, 12);
            }
            croppedFileName = croppedFileName + extension;

            if (index >= 0)
            {
                croppedFileName = "_" + index + "_" + croppedFileName;
            }

            string xukFileName =
                croppedFileName.Replace('.', '_')
                + (!string.IsNullOrEmpty(title)
                       ? "-" //"["
                   + CleanupTitle(title, 12)
                   //+ "]"
                       : "")
                + OpenXukAction.XUK_EXTENSION;

#if DEBUG
            DebugFix.Assert(xukFileName.Length <= (1 + 12 + 6 + 1 + 12 + 4));
            DebugFix.Assert(outputDirectory.Length + xukFileName.Length <= 250);
#endif

            return(Path.Combine(outputDirectory, xukFileName));
        }
Beispiel #7
0
        public void Test_FileDataProvider_Loop()
        {
            var loop = new Loop()
            {
                Id = 1
            };

            loop.Inner = loop;

            var fdp = new FileDataProvider()
            {
                DirectoryPath   = _directory,
                FilenameBuilder = x => x.EventType
            };

            Configuration.DataProvider = fdp;
            var guid = "x" + Guid.NewGuid().ToString();

            try
            {
                new AuditScopeFactory().Log(guid, loop);
                Assert.Fail("Should have thrown JsonException");
            }
            catch (JsonException ex)
            {
                if (!ex.Message.Contains("cycle"))
                {
                    Assert.Fail("Should have failed with JsonException object cycle");
                }
            }

            Assert.IsFalse(File.Exists(Path.Combine(_directory, guid)));
        }
Beispiel #8
0
        public void FileDataProvider_ReturnFileNamesList()
        {
            //Arrange
            Mock <ILogger <FileDataProvider> > moq = new Mock <ILogger <FileDataProvider> >(MockBehavior.Loose);

            FileDataProvider fileDataProvider    = new FileDataProvider(moq.Object);
            string           path                = Path.GetTempPath();
            string           tempDirectory       = Path.Combine(path, "testfiledataprovidertest1");
            List <string>    assertFileNamesList = new List <string>
            {
                Path.Combine(tempDirectory, "file1.txt"),
                Path.Combine(tempDirectory, "file2.txt"),
                Path.Combine(tempDirectory, "file3.txt"),
                Path.Combine(tempDirectory, "file4.txt"),
            };

            if (Directory.Exists(tempDirectory))
            {
                Directory.Delete(tempDirectory, true);
            }
            Directory.CreateDirectory(tempDirectory);
            assertFileNamesList.ForEach(async fileName => await File.WriteAllTextAsync(fileName, ""));

            //Act
            List <string> resultList = fileDataProvider.GetDataNamesEnumerator(tempDirectory).OrderBy(name => name).ToList();

            Directory.Delete(tempDirectory, true);

            //Assert
            Assert.Equal(assertFileNamesList, resultList);
        }
Beispiel #9
0
        public static string GetJobOutputEpubFilePath(string id)
        {
            XmlDocument         doc     = GetJob(id);
            XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);

            manager.AddNamespace("ns", "http://www.daisy.org/ns/pipeline/data");

            XmlNodeList nodes = doc.SelectNodes("//ns:job/ns:results/ns:result[@name='output-dir']/ns:result[contains(@file, '.epub')]", manager);

            if (nodes.Count <= 0)
            {
                nodes = doc.SelectNodes("//ns:job/ns:results/ns:result[@name='output']/ns:result[contains(@file, '.epub')]", manager);
            }
            if (nodes.Count > 0)
            {
                string path = nodes[0].Attributes.GetNamedItem("file").Value;
                path = FileDataProvider.UriDecode(path);
                path = path.Replace("file:/", "").Replace('/', '\\');
                if (path.StartsWith("\\"))
                {
                    path = path.Substring(1);
                }
                return(path);
            }

            return(null);
        }
Beispiel #10
0
        private static void Run(string resultsFile, string path, long limit, string codec, string architecture)
        {
            var         provider = new FileDataProvider(path.Split(';'));
            TimedMethod compressor;
            TimedMethod decompressor;

            var codecCode = SelectCodec(codec, architecture, out compressor, out decompressor);

            Warmup(compressor, decompressor);

            long total = 0;
            var  pct   = 0;

            while (total < limit)
            {
                var original     = provider.GetBytes();
                var length       = original.Length;
                var compressed   = compressor.Run(original, length);
                var decompressed = decompressor.Run(compressed, length);
                AssertEqual(original, decompressed);
                total += length;

                var new_pct = (int)(total * 100 / limit);
                if (new_pct > pct)
                {
                    Console.WriteLine("{0}%", new_pct);
                    pct = new_pct;
                }
            }

            Console.WriteLine("{0}: {1:0.00} / {2:0.00}", codecCode, compressor.Speed, decompressor.Speed);

            UpdateResults(resultsFile, codecCode, compressor, decompressor);
        }
Beispiel #11
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();
            }
        }
Beispiel #12
0
        public async Task Test_FileDataProvider_ErrorAsync()
        {
            var loop = new Loop()
            {
                Id = 1
            };

            loop.Inner = loop;

            var fdp = new FileDataProvider()
            {
                DirectoryPath   = _directory,
                FilenameBuilder = x => x.EventType
            };

            Configuration.Setup().UseFileLogProvider(_ => _
                                                     .Directory(_directory)
                                                     .FilenameBuilder(x => x.EventType)
                                                     .JsonSettings(new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Error
            }));

            var guid = "x" + Guid.NewGuid().ToString();

            try
            {
                await new AuditScopeFactory().CreateAsync(new AuditScopeOptions(guid, extraFields: loop, isCreateAndSave: true));
                Assert.Fail("Should not get here. JsonSettings not respected?");
            }
            catch (JsonSerializationException ex)
            {
                Assert.IsTrue(ex.Message.ToLower().Contains("loop detected"));
            }
        }
Beispiel #13
0
        public async Task Test_FileDataProvider_LoopAsync()
        {
            var loop = new Loop()
            {
                Id = 1
            };

            loop.Inner = loop;

            var fdp = new FileDataProvider()
            {
                DirectoryPath   = _directory,
                FilenameBuilder = x => x.EventType
            };

            Configuration.DataProvider = fdp;
            var guid = "x" + Guid.NewGuid().ToString();
            await AuditScope.CreateAndSaveAsync(guid, loop);

            var ev = await fdp.GetEventAsync(Path.Combine(_directory, guid));

            Assert.IsNotNull(ev);
            Assert.AreEqual(guid, ev.EventType);
            Assert.AreEqual(2, ev.CustomFields.Count);
            Assert.AreEqual(1, ev.CustomFields["Id"]);
            Assert.AreEqual(JObject.Parse("{\"Id\": 1}").ToString(), ev.CustomFields["Inner"].ToString());
        }
Beispiel #14
0
        public void Temp()
        {
            FileDataProvider fdp = mDataProviderManager.Presentation.DataProviderFactory.Create <FileDataProvider>(
                DataProviderFactory.AUDIO_WAV_MIME_TYPE);

            Assert.IsNotNull(fdp, "Could not create FileDataProvider");
        }
Beispiel #15
0
        public void Test_FileDataProvider_Loop()
        {
            var loop = new Loop()
            {
                Id = 1
            };

            loop.Inner = loop;

            var fdp = new FileDataProvider()
            {
                DirectoryPath   = _directory,
                FilenameBuilder = x => x.EventType
            };

            Configuration.DataProvider = fdp;
            var guid = "x" + Guid.NewGuid().ToString();

            new AuditScopeFactory().Log(guid, loop);

            var ev = fdp.GetEvent(Path.Combine(_directory, guid));

            Assert.IsNotNull(ev);
            Assert.AreEqual(guid, ev.EventType);
            Assert.AreEqual(2, ev.CustomFields.Count);
            Assert.AreEqual(1, ev.CustomFields["Id"]);
            Assert.AreEqual("{\r\n  \"Id\": 1\r\n}", ev.CustomFields["Inner"].ToString());
        }
        public void Test_Valid_ValidNumbers_FromFile()
        {
            FileDataProvider fileDataProvider = new FileDataProvider();
            var numbers = fileDataProvider.GetNumbers(matrixPopulator.FilePath);

            Assert.IsNotNull(numbers);
        }
        public void ReadKeyedTestData_WithExampleDataFileWithDuplicates_DoesNotThrow()
        {
            var fileDataProvider = new FileDataProvider(_logger.Object);
            var directory        = Path.Combine(Assembly.GetExecutingAssembly().GetDirectory(), _dataDir);

            Assert.DoesNotThrow(() => fileDataProvider.ReadKeyedTestData <DuplicatePoco>(directory));
        }
Beispiel #18
0
        /*
         * A Sugar simulator requires a food & exercise index database.
         * And should implement two interfaces Init() and PrintIndex()
         * The database can consume the data from any provider, based on the configuation or whatever the provider component it is intansiated with
         * dependency injection
         *
         */
        public static void Init()
        {
            try
            {
                /* We could have many providers of data. We could decide which provider to go based on dependency injection*/
                /* The data provider exposes two interface methods.. LoadFoodIndex*/
                var dataProvider = new FileDataProvider();

                Console.WriteLine("...Loading the Food Index");
                dataProvider.LoadFoodIndex(ref FoodIndex);

                Console.WriteLine("...Loading the Exercise Index");
                dataProvider.LoadExerciseIndex(ref ExerciseIndex);

                Success = true;
                Console.WriteLine("...Database Load SUCCESS");
            }
            catch
            {
                //We implement logs and errors, why the food and index download was a failure.
                //The calling Simulator main program will exit. So we wil read the logs and errors and troubleshoot.
                Console.WriteLine("...Database Load FAILED..");
            }

            Console.WriteLine("-----------------------------------------------------------------");
        }
        public ConnectionTreeModel LoadConnections(bool import)
        {
            IDeserializer deserializer;
            if (UseDatabase)
            {
                var connector = new SqlDatabaseConnector();
                var dataProvider = new SqlDataProvider(connector);
                var dataTable = dataProvider.Load();
                deserializer = new DataTableDeserializer(dataTable);
            }
            else
            {
                var dataProvider = new FileDataProvider(ConnectionFileName);
                var xmlString = dataProvider.Load();
                deserializer = new XmlConnectionsDeserializer(xmlString, PromptForPassword);
            }

            var connectionTreeModel = deserializer.Deserialize();

            if (connectionTreeModel != null)
                frmMain.Default.ConnectionsFileName = ConnectionFileName;
            else
                connectionTreeModel = new ConnectionTreeModel();

            if (import) return connectionTreeModel;
            PuttySessionsManager.Instance.AddSessions();
            connectionTreeModel.RootNodes.AddRange(PuttySessionsManager.Instance.RootPuttySessionsNodes);

            return connectionTreeModel;
        }
Beispiel #20
0
        // Access a channel which we know exist and is the only channel by this name.
        //sdk2
        //internal Channel GetSingleChannelByName(string name)
        //{
        //    List<Channel> channels = getChannelsManager().getListOfChannels(name);
        //    if (channels.Count == 0) throw new Exception(String.Format("No channel named \"{0}\"", name));
        //    if (channels.Count > 1) throw new Exception(String.Format("Expected 1 channel for {0}, got {1}.",
        //        name, channels.Count));
        //    return channels[0];
        //}

        // Create a media object from a sound file.
        private ManagedAudioMedia ImportAudioFromFile(string path)
        {
            string dataProviderDirectory = DataProviderManager.DataFileDirectoryFullPath;

            //EnforceSinglePCMFormat is always true
            //if (!MediaDataManager.EnforceSinglePCMFormat)
            //    {
            //    Stream input = File.OpenRead ( path );
            //    PCMDataInfo info = PCMDataInfo.parseRiffWaveHeader ( input );
            //    input.Close ();
            //    DataManager.setDefaultBitDepth ( info.getBitDepth () );
            //    DataManager.setDefaultNumberOfChannels ( info.getNumberOfChannels () );
            //    DataManager.setDefaultSampleRate ( info.getSampleRate () );
            //    DataManager.setEnforceSinglePCMFormat ( true );
            //    }

            AudioMediaData data = MediaDataFactory.CreateAudioMediaData();

            if (Path.GetFullPath(path).StartsWith(Path.GetFullPath(dataProviderDirectory)))
            {
                FileDataProvider dataProv = (FileDataProvider)DataProviderFactory.Create(urakawa.data.DataProviderFactory.AUDIO_WAV_MIME_TYPE);
                dataProv.InitByMovingExistingFile(path);
                data.AppendPcmData(dataProv);
            }
            else
            {
                data.AppendPcmData_RiffHeader(path);
            }

            ManagedAudioMedia media = MediaFactory.CreateManagedAudioMedia();

            media.AudioMediaData = data;
            return(media);
        }
Beispiel #21
0
        public void Import(string filePath, ContainerInfo destinationContainer)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Unable to import file. File path is null.");
                return;
            }

            if (!File.Exists(filePath))
            {
                Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, $"Unable to import file. File does not exist. Path: {filePath}");
            }

            var dataProvider = new FileDataProvider(filePath);
            var xmlString    = dataProvider.Load();
            var xmlConnectionsDeserializer = new CsvConnectionsDeserializerMremotengFormat();
            var connectionTreeModel        = xmlConnectionsDeserializer.Deserialize(xmlString);

            var rootImportContainer = new ContainerInfo {
                Name = Path.GetFileNameWithoutExtension(filePath)
            };

            rootImportContainer.AddChildRange(connectionTreeModel.RootNodes.First().Children.ToArray());
            destinationContainer.AddChild(rootImportContainer);
        }
Beispiel #22
0
        public async Task FileDataProvider_ReturnFileContentModel()
        {
            //Arrange
            Mock <ILogger <FileDataProvider> > moq = new Mock <ILogger <FileDataProvider> >(MockBehavior.Loose);

            FileDataProvider fileDataProvider       = new FileDataProvider(moq.Object);
            string           path                   = Path.GetTempPath();
            string           tempDirectory          = Path.Combine(path, "testfiledataprovidertest2");
            string           tempFileName           = Path.Combine(tempDirectory, "file1.txt");
            DataContentModel assertFileContentModel = new DataContentModel()
            {
                FilePath       = tempFileName,
                ContentStrings = new string[]
                {
                    "Line1",
                    "Line2",
                    "Line3"
                }
            };

            if (Directory.Exists(tempDirectory))
            {
                Directory.Delete(tempDirectory, true);
            }
            Directory.CreateDirectory(tempDirectory);
            await File.WriteAllLinesAsync(tempFileName, assertFileContentModel.ContentStrings);

            //Act
            DataContentModel resultModel = await fileDataProvider.ReadDataToModelAsync(tempFileName);

            Directory.Delete(tempDirectory, true);

            //Assert
            Assert.Equal(assertFileContentModel, resultModel);
        }
Beispiel #23
0
 static AudioFormatConvertorSession()
 {
     if (!Directory.Exists(TEMP_AUDIO_DIRECTORY))
     {
         FileDataProvider.CreateDirectory(TEMP_AUDIO_DIRECTORY);
     }
 }
        public void ReadTestData_WithNoDirectoryProvided_ReturnsEmptyCollection()
        {
            var fileDataProvider = new FileDataProvider(_logger.Object);

            var result = fileDataProvider.ReadTestData <TestPoco>(null);

            result.Should().BeEmpty();
        }
Beispiel #25
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);
        }
        public void TestFileNotFound()
        {
            var data = new FileDataProvider("noFile.txt");

            TriangleReader reader = new TriangleReader(data);

            reader.ReadTriangle();
        }
        public ConnectionTreeModel Load()
        {
            var dataProvider = new FileDataProvider(_connectionFilePath);
            var xmlString    = dataProvider.Load();
            var deserializer = new XmlConnectionsDeserializer(PromptForPassword);

            return(deserializer.Deserialize(xmlString));
        }
        public void Should_ThrowException_When_ForInvalidCharactersInFile()
        {
            matrixPopulator.FilePath = ConfigurationManager.AppSettings["InValidFilePath"];
            FileDataProvider fileDataProvider = new FileDataProvider();
            var numbers = fileDataProvider.GetNumbers(matrixPopulator.FilePath);

            Assert.Fail("An exception is thrown for invalid characters found in the test.prm file.");
        }
Beispiel #29
0
        private void SaveToRemoteDesktop2008FormattedCsv()
        {
            var csvSerializer = new CsvConnectionsSerializerRemoteDesktop2008Format();
            var dataProvider  = new FileDataProvider(ConnectionFileName);
            var csvContent    = csvSerializer.Serialize(ConnectionTreeModel);

            dataProvider.Save(csvContent);
        }
        public void LoadingFileThatDoesntExistProvidesEmptyString()
        {
            var fileThatShouldntExist = Guid.NewGuid().ToString();
            var dataProvider          = new FileDataProvider(fileThatShouldntExist);
            var loadedData            = dataProvider.Load();

            Assert.That(loadedData, Is.Empty);
        }
        private ICredentialRepository BuildXmlRepo(ICredentialRepositoryConfig config)
        {
            var dataProvider = new FileDataProvider(config.Source);
            var saver        = new CredentialRecordSaver(dataProvider, _serializer);
            var loader       = new CredentialRecordLoader(dataProvider, _deserializer);

            return(new XmlCredentialRepository(config, saver, loader));
        }
        public void Import(string fileName, ContainerInfo destinationContainer)
        {
            var dataProvider = new FileDataProvider(fileName);
            var xmlString = dataProvider.Load();
            var xmlConnectionsDeserializer = new XmlConnectionsDeserializer(xmlString);
            var connectionTreeModel = xmlConnectionsDeserializer.Deserialize(true);

            var rootImportContainer = new ContainerInfo { Name = Path.GetFileNameWithoutExtension(fileName) };
            rootImportContainer.Children.AddRange(connectionTreeModel.RootNodes.First().Children);
            destinationContainer.AddChild(rootImportContainer);
        }
        public void Import(string filePath, ContainerInfo destinationContainer)
        {
            var dataProvider = new FileDataProvider(filePath);
            var xmlContent = dataProvider.Load();

            var deserializer = new PuttyConnectionManagerDeserializer(xmlContent);
            var connectionTreeModel = deserializer.Deserialize();

            var importedRootNode = connectionTreeModel.RootNodes.First();
            if (importedRootNode == null) return;
            var childrenToAdd = importedRootNode.Children.ToArray();
            destinationContainer.AddChildRange(childrenToAdd);
        }
        public void Import(string fileName, ContainerInfo destinationContainer)
        {
            var dataProvider = new FileDataProvider(fileName);
            var content = dataProvider.Load();
            var lines = content.Split(Environment.NewLine.ToCharArray());

            var deserializer = new RemoteDesktopConnectionDeserializer(lines);
            var connectionTreeModel = deserializer.Deserialize();

            var importedConnection = connectionTreeModel.RootNodes.First().Children.First();

            if (importedConnection == null) return;
            importedConnection.Name = Path.GetFileNameWithoutExtension(fileName);
            destinationContainer.AddChild(importedConnection);
        }
Beispiel #35
0
 private void SaveToMremotengFormattedCsv()
 {
     var csvConnectionsSerializer = new CsvConnectionsSerializerMremotengFormat { SaveFilter = SaveFilter };
     var dataProvider = new FileDataProvider(ConnectionFileName);
     var csvContent = csvConnectionsSerializer.Serialize(ConnectionTreeModel);
     dataProvider.Save(csvContent);
 }
Beispiel #36
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();
     }
 }