Пример #1
0
        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;
        }
Пример #2
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);
        }
        public ConnectionTreeModel Load()
        {
            var dataProvider = new FileDataProvider(_connectionFilePath);
            var xmlString    = dataProvider.Load();
            var deserializer = new XmlConnectionsDeserializer(PromptForPassword);

            return(deserializer.Deserialize(xmlString));
        }
        public void LoadingFileThatDoesntExistProvidesEmptyString()
        {
            var fileThatShouldntExist = Guid.NewGuid().ToString();
            var dataProvider          = new FileDataProvider(fileThatShouldntExist);
            var loadedData            = dataProvider.Load();

            Assert.That(loadedData, Is.Empty);
        }
Пример #5
0
        public void Print_DataFromFile_SameValue(string path)
        {
            string expected = FileDataProvider.Load(new FileInfo(path));

            Debug.Write(expected);

            var printer = new Printer("test", "test");
            var actual  = printer.Print <string, string>(expected);

            Assert.AreEqual(expected, actual);
        }
Пример #6
0
        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);
        }
Пример #8
0
        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 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);
        }
        public void Import(string fileName, ContainerInfo destinationContainer)
        {
            var dataProvider = new FileDataProvider(fileName);
            var content      = dataProvider.Load();

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

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

            if (importedConnection == null)
            {
                return;
            }
            importedConnection.Name = Path.GetFileNameWithoutExtension(fileName);
            destinationContainer.AddChild(importedConnection);
        }
Пример #11
0
        public void Import(string filePath, ContainerInfo destinationContainer)
        {
            var dataProvider = new FileDataProvider(filePath);
            var fileContent  = dataProvider.Load();

            var deserializer        = new RemoteDesktopConnectionManagerDeserializer(fileContent);
            var connectionTreeModel = deserializer.Deserialize();

            var importedRootNode = connectionTreeModel.RootNodes.First();

            if (importedRootNode == null)
            {
                return;
            }
            var childrenToAdd = importedRootNode.Children.ToArray();

            destinationContainer.AddChildRange(childrenToAdd);
        }
Пример #12
0
        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)
                {
                    AuthenticationRequestor = 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);
        }