diff --git a/MTC_Sim/MTC_Sim/AdapterConf/PersistData.bin b/MTC_Sim/MTC_Sim/AdapterConf/PersistData.bin
deleted file mode 100644
index 6bac0fa..0000000
Binary files a/MTC_Sim/MTC_Sim/AdapterConf/PersistData.bin and /dev/null differ
diff --git a/MTC_Sim/MTC_Sim/AdapterConf/PersistData.mtc b/MTC_Sim/MTC_Sim/AdapterConf/PersistData.mtc
new file mode 100644
index 0000000..e69de29
diff --git a/MTC_Sim/MTC_Sim/App.config b/MTC_Sim/MTC_Sim/App.config
index 2e339c3..8e648c4 100644
--- a/MTC_Sim/MTC_Sim/App.config
+++ b/MTC_Sim/MTC_Sim/App.config
@@ -39,7 +39,7 @@
-
+
diff --git a/MTC_Sim/MTC_Sim/MTC-Adapter.csproj b/MTC_Sim/MTC_Sim/MTC-Adapter.csproj
index 094448b..0ce4dfb 100644
--- a/MTC_Sim/MTC_Sim/MTC-Adapter.csproj
+++ b/MTC_Sim/MTC_Sim/MTC-Adapter.csproj
@@ -175,7 +175,7 @@
App.config
-
+
PreserveNewest
diff --git a/MTC_Sim/MTC_Sim/MainForm.cs b/MTC_Sim/MTC_Sim/MainForm.cs
index 544665f..4db296a 100644
--- a/MTC_Sim/MTC_Sim/MainForm.cs
+++ b/MTC_Sim/MTC_Sim/MainForm.cs
@@ -393,7 +393,7 @@ namespace MTC_Adapter
{
get
{
- return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.bin", utils.CRS("XmlHistFilePath"), DateTime.Now);
+ return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.CRS("XmlHistFilePath"), DateTime.Now);
}
}
///
@@ -953,7 +953,7 @@ namespace MTC_Adapter
///
public void savePersistLayer(string filePath)
{
- utils.Write(agObj.persistenceLayer, filePath);
+ utils.WritePlain(agObj.persistenceLayer, filePath);
}
///
/// Carica da file l'oggetto di persistenza dati
@@ -963,7 +963,8 @@ namespace MTC_Adapter
{
// inizializzo prima di leggere...
agObj.persistenceLayer = new Dictionary();
- agObj.persistenceLayer = utils.Read(filePath);
+ agObj.persistenceLayer = utils.ReadPlain(filePath);
+ //agObj.persistenceLayer = utils.ReadBin(filePath);
}
#endregion
diff --git a/MTC_Sim/MTC_Sim/utils.cs b/MTC_Sim/MTC_Sim/utils.cs
index f24c104..928bfdc 100644
--- a/MTC_Sim/MTC_Sim/utils.cs
+++ b/MTC_Sim/MTC_Sim/utils.cs
@@ -209,7 +209,7 @@ namespace MTC_Adapter
///
///
///
- public static void Write(Dictionary dictionary, string file)
+ public static void WriteBin(Dictionary dictionary, string file)
{
using (FileStream fs = File.OpenWrite(file))
using (BinaryWriter writer = new BinaryWriter(fs))
@@ -229,11 +229,11 @@ namespace MTC_Adapter
///
///
///
- public static Dictionary Read(string file)
+ public static Dictionary ReadBin(string file)
{
var result = new Dictionary();
// verifico file esista...
- if(!File.Exists(file))
+ if (!File.Exists(file))
{
FileStream fs = File.Create(file);
fs.Close();
@@ -259,6 +259,37 @@ namespace MTC_Adapter
}
return result;
}
+
+ ///
+ /// Scrittura dictionary su file
+ ///
+ ///
+ ///
+ public static void WritePlain(Dictionary dictionary, string file)
+ {
+ string[] lines = dictionary.OrderBy(i => i.Key).Select(kvp => kvp.Key + ":" + kvp.Value).ToArray();
+ File.WriteAllLines(file, lines);
+ }
+ ///
+ /// Lettura dictionary da file
+ ///
+ ///
+ ///
+ public static Dictionary ReadPlain(string file)
+ {
+ var result = new Dictionary();
+ // verifico file esista...
+ if (!File.Exists(file))
+ {
+ FileStream fs = File.Create(file);
+ fs.Close();
+ }
+
+ string[] lines = File.ReadAllLines(file);
+ result = lines.Select(l => l.Split(':')).ToDictionary(a => a[0], a => a[1]);
+
+ return result;
+ }
}
///
/// Oggetto timing x archiviazione dati perfomances