[fix:] inconsistency with config.json
This commit is contained in:
+14
-11
@@ -12,8 +12,8 @@ public class Settings
|
||||
public Customers customers = new();
|
||||
public PdfExportSettings pdfExport { get; set; } = new();
|
||||
|
||||
public string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"logofclient", "config.json");
|
||||
// public string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
// "logofclient", "config.json");
|
||||
|
||||
public Settings()
|
||||
{
|
||||
@@ -23,23 +23,22 @@ public class Settings
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"logofclient")))
|
||||
if (!Directory.Exists(Global._instance.config_path))
|
||||
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"logofclient"));
|
||||
if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
|
||||
// if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
|
||||
|
||||
var json = JsonConvert.SerializeObject(_instance);
|
||||
File.WriteAllText(_instance.settingsPath, json);
|
||||
File.WriteAllText(Path.Combine(Global._instance.config_path,"config.json"), json);
|
||||
}
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
|
||||
//if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
|
||||
|
||||
try
|
||||
{
|
||||
var contents = File.ReadAllText(_instance.settingsPath);
|
||||
var contents = File.ReadAllText(Path.Combine(Global._instance.config_path, "config.json"));
|
||||
_instance = JsonConvert.DeserializeObject<Settings>(contents);
|
||||
MainWindow._instance.RefreshCustomerItems();
|
||||
}
|
||||
@@ -80,11 +79,15 @@ public class Global
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
public string config_path { get; set; } = Path.Combine(
|
||||
public string config_path { get; } = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"logofclient",
|
||||
"config.json");
|
||||
"logofclient");
|
||||
|
||||
public void SetConfigPath(string path)
|
||||
{
|
||||
Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
|
||||
}
|
||||
public string wiki_storage_path { get; set; } = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"logofclient",
|
||||
|
||||
Reference in New Issue
Block a user