diff --git a/mRemoteV1/Config/Connections/ConnectionsSaver.cs b/mRemoteV1/Config/Connections/ConnectionsSaver.cs
index 4bfc1680..55f22ce7 100644
--- a/mRemoteV1/Config/Connections/ConnectionsSaver.cs
+++ b/mRemoteV1/Config/Connections/ConnectionsSaver.cs
@@ -74,13 +74,13 @@ namespace mRemoteNG.Config.Connections
SaveToSQL();
break;
case Format.mRCSV:
- SaveToCsv();
+ SaveToMremotengFormattedCsv();
break;
case Format.vRDvRE:
SaveToVRE();
break;
case Format.vRDCSV:
- SaveTovRDCSV();
+ SaveToRemoteDesktop2008FormattedCsv();
break;
default:
SaveToXml();
@@ -573,7 +573,7 @@ namespace mRemoteNG.Config.Connections
}
}
- private void SaveToCsv()
+ private void SaveToMremotengFormattedCsv()
{
var csvConnectionsSerializer = new CsvConnectionsSerializerMremotengFormat { SaveSecurity = SaveSecurity };
var dataProvider = new FileDataProvider(ConnectionFileName);
@@ -582,60 +582,13 @@ namespace mRemoteNG.Config.Connections
}
#region vRD CSV
-
- private StreamWriter csvWr;
- private void SaveTovRDCSV()
- {
- if (Runtime.IsConnectionsFileLoaded == false)
- {
- return;
- }
- var tN = (TreeNode)RootTreeNode.Clone();
- var tNC = tN.Nodes;
- csvWr = new StreamWriter(ConnectionFileName);
- SaveNodevRDCSV(tNC);
- csvWr.Close();
- }
-
- private void SaveNodevRDCSV(TreeNodeCollection tNC)
- {
- foreach (TreeNode node in tNC)
- {
- if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Connection)
- {
- ConnectionInfo curConI = (ConnectionInfo)node.Tag;
-
- if (curConI.Protocol == ProtocolType.RDP)
- {
- WritevRDCSVLine(curConI);
- }
- }
- else if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Container)
- {
- SaveNodevRDCSV(node.Nodes);
- }
- }
- }
-
- private void WritevRDCSVLine(ConnectionInfo con)
- {
- string nodePath = con.TreeNode.FullPath;
-
- int firstSlash = nodePath.IndexOf("\\", StringComparison.Ordinal);
- nodePath = nodePath.Remove(0, firstSlash + 1);
- int lastSlash = nodePath.LastIndexOf("\\", StringComparison.Ordinal);
-
- if (lastSlash > 0)
- {
- nodePath = nodePath.Remove(lastSlash);
- }
- else
- {
- nodePath = "";
- }
-
- csvWr.WriteLine(con.Name + ";" + con.Hostname + ";" + con.MacAddress + ";;" + Convert.ToString(con.Port) + ";" + Convert.ToString(con.UseConsoleSession) + ";" + nodePath);
- }
+ private void SaveToRemoteDesktop2008FormattedCsv()
+ {
+ var csvSerializer = new CsvConnectionsSerializerRemoteDesktop2008Format();
+ var dataProvider = new FileDataProvider(ConnectionFileName);
+ var csvContent = csvSerializer.Serialize(ConnectionTreeModel);
+ dataProvider.Save(csvContent);
+ }
#endregion
#region vRD VRE
diff --git a/mRemoteV1/Config/Connections/CsvConnectionsSerializerRemoteDesktop2008Format.cs b/mRemoteV1/Config/Connections/CsvConnectionsSerializerRemoteDesktop2008Format.cs
new file mode 100644
index 00000000..06582c46
--- /dev/null
+++ b/mRemoteV1/Config/Connections/CsvConnectionsSerializerRemoteDesktop2008Format.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Linq;
+using mRemoteNG.App;
+using mRemoteNG.Connection;
+using mRemoteNG.Connection.Protocol;
+using mRemoteNG.Container;
+using mRemoteNG.Tree;
+using mRemoteNG.Tree.Root;
+
+
+namespace mRemoteNG.Config.Connections
+{
+ public class CsvConnectionsSerializerRemoteDesktop2008Format : ISerializer
+ {
+ private string _csv = "";
+
+ public string Serialize(ConnectionTreeModel connectionTreeModel)
+ {
+ var rootNode = (RootNodeInfo)connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
+ return SerializeToCsv(rootNode);
+ }
+
+ private string SerializeToCsv(RootNodeInfo rootNodeInfo)
+ {
+ if (Runtime.IsConnectionsFileLoaded == false)
+ return "";
+
+ _csv = "";
+ SerializeNodesRecursive(rootNodeInfo);
+ return _csv;
+ }
+
+ private void SerializeNodesRecursive(ContainerInfo containerInfo)
+ {
+ foreach (var child in containerInfo.Children)
+ {
+ if (child is ContainerInfo)
+ SerializeNodesRecursive((ContainerInfo)child);
+ else if (child.Protocol == ProtocolType.RDP)
+ SerializeConnectionInfo(child);
+ }
+ }
+
+ private void SerializeConnectionInfo(ConnectionInfo con)
+ {
+ var nodePath = con.TreeNode.FullPath;
+
+ var firstSlash = nodePath.IndexOf("\\", StringComparison.Ordinal);
+ nodePath = nodePath.Remove(0, firstSlash + 1);
+ var lastSlash = nodePath.LastIndexOf("\\", StringComparison.Ordinal);
+
+ nodePath = lastSlash > 0 ? nodePath.Remove(lastSlash) : "";
+
+ _csv += con.Name + ";" + con.Hostname + ";" + con.MacAddress + ";;" + con.Port + ";" + con.UseConsoleSession + ";" + nodePath + Environment.NewLine;
+ }
+ }
+}
\ No newline at end of file
diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj
index 0d536fd3..0520f86e 100644
--- a/mRemoteV1/mRemoteV1.csproj
+++ b/mRemoteV1/mRemoteV1.csproj
@@ -128,6 +128,7 @@
+