diff --git a/csharp/App/SodiStoreMax/src/Program.cs b/csharp/App/SodiStoreMax/src/Program.cs index 1b460898e..066e9fc99 100644 --- a/csharp/App/SodiStoreMax/src/Program.cs +++ b/csharp/App/SodiStoreMax/src/Program.cs @@ -819,22 +819,22 @@ internal static class Program sc.ResetAlarmsAndWarnings = true; } - private static void InsertIntoJson(Dictionary jsonDict, String[] keys, string value) + private static void InsertIntoJson(Dictionary jsonDict, String[] keys, String value) { - Dictionary currentDict = jsonDict; - for (int i = 1; i < keys.Length; i++) // Start at 1 to skip empty root + var currentDict = jsonDict; + for (Int16 i = 1; i < keys.Length; i++) // Start at 1 to skip empty root { - string key = keys[i]; + var key = keys[i]; if (!currentDict.ContainsKey(key)) { - currentDict[key] = new Dictionary(); + currentDict[key] = new Dictionary(); } if (i == keys.Length - 1) // Last key, store the value { - if (!value.Contains(",") && double.TryParse(value, out double doubleValue)) // Try to parse value as a number + if (!value.Contains(",") && double.TryParse(value, out Double doubleValue)) // Try to parse value as a number { currentDict[key] = Math.Round(doubleValue, 2); // Round to 2 decimal places @@ -846,7 +846,7 @@ internal static class Program } else { - currentDict = (Dictionary)currentDict[key]; + currentDict = (Dictionary)currentDict[key]; } } @@ -862,16 +862,16 @@ internal static class Program { if (string.IsNullOrWhiteSpace(line)) continue; - string[] parts = line.Split(';'); - string keyPath = parts[0]; - string value = parts[1]; - string unit = parts.Length > 2 ? parts[2].Trim() : ""; + var parts = line.Split(';'); + var keyPath = parts[0]; + var value = parts[1]; + var unit = parts.Length > 2 ? parts[2].Trim() : ""; //Console.WriteLine(line); // Console.WriteLine($"Key: {keyPath}, Value: {value}, Unit: {unit}"); InsertIntoJson(jsonData, keyPath.Split('/'), value); } - string jsonOutput = JsonConvert.SerializeObject(jsonData, Formatting.None); + var jsonOutput = JsonConvert.SerializeObject(jsonData, Formatting.None); jsonOutput.LogInfo(); await RestApiSavingFile(csv); @@ -903,7 +903,7 @@ internal static class Program var compressedBytes = CompresseBytes(jsonToSend); // Encode the compressed byte array as a Base64 string - string base64String = Convert.ToBase64String(compressedBytes); + var base64String = Convert.ToBase64String(compressedBytes); // Create StringContent from Base64 string var stringContent = new StringContent(base64String, Encoding.UTF8, "application/base64"); @@ -984,7 +984,7 @@ internal static class Program Directory.CreateDirectory(directoryPath); } - string filePath = Path.Combine(directoryPath, "status.csv"); + var filePath = Path.Combine(directoryPath, "status.csv"); await File.WriteAllTextAsync(filePath, csv.SplitLines().Where(l => !l.Contains("Secret")).JoinLines()); }