Working on local user profile cache

Saving a new user.json for signed in users
This commit is contained in:
Lars Brubaker 2016-07-06 17:45:53 -07:00
parent 6c08b9421d
commit 90aa9f44cf
4 changed files with 45 additions and 4 deletions

View file

@ -147,6 +147,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
UserSettings.Instance.set("ActiveProfileID", printerID);
UserSettings.Instance.set("ActiveUserName", ApplicationController.Instance.GetSessionUsernameForFileSystem());
Instance = profile ?? ProfileManager.LoadEmptyProfile();
}

View file

@ -52,7 +52,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
get
{
return Path.Combine(ProfilesPath, "profiles.json");
string username = UserSettings.Instance.get("ActiveUserName");
return Path.Combine(ProfilesPath, string.IsNullOrEmpty(username) ? "profiles.json" : username + ".json");
}
}
@ -88,13 +90,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
if (File.Exists(profilesDBPath))
{
Instance = JsonConvert.DeserializeObject<ProfileManager>(File.ReadAllText(profilesDBPath));
Instance.Profiles.CollectionChanged += Profiles_CollectionChanged;
}
else // One time import
{
// Import classic db based profiles into local json files
DataStorage.ClassicDB.ClassicSqlitePrinterProfiles.ImportPrinters(Instance, ProfilesPath);
if (Path.GetFileName(profilesDBPath) == "profiles.json")
{
// Import classic db based profiles into local json files
DataStorage.ClassicDB.ClassicSqlitePrinterProfiles.ImportPrinters(Instance, ProfilesPath);
}
}
Instance.Profiles.CollectionChanged += Profiles_CollectionChanged;
}
public ProfileManager()