/// <summary> /// Save current state to permanent storage. /// </summary> public static void Save() { ExceptionUtility.Try(() => { LogUtility.LogMessage("Saving cache."); var cacheObj = new JsonCacheObject() { Metadata = ApplicationMetadata, Devices = _cachedDevices.Select((r) => r.Value.Device).ToList(), Commands = _commandProgresses.Values.ToList(), ServerVersion = ServiceContainer.ServerVersion.ToString() }; lock (_syncLock) { FileUtility.WriteAllText(_filePath, JsonUtility.Serialize(cacheObj)); } }); }
/// <summary> /// Save current state to permanent storage. /// </summary> public static void Save() { ExceptionUtility.Try(() => { LogUtility.LogMessage("Saving UserCache."); var cacheObj = new JsonCacheObject() { User = CurrentUser }; if (cacheObj.User != null) { cacheObj.User = (User)cacheObj.User.Clone(); cacheObj.User.Password = new AesUtility().EncryptToString(cacheObj.User.Password); } lock (_syncLock) { FileUtility.WriteAllText(_filePath, JsonUtility.Serialize(cacheObj)); } }); }