示例#1
0
        /// <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));
                }
            });
        }
示例#2
0
        /// <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));
                }
            });
        }