Beispiel #1
0
 public void Save(UsageStore store)
 {
     try
     {
         var json = store.ToJson(lowerCase: true);
         path.WriteAllText(json, Encoding.UTF8);
     }
     catch (Exception ex)
     {
         LogHelper.Instance.Error(ex, "SaveUsage Error: \"{0}\"", path);
     }
 }
Beispiel #2
0
        private void SaveUsage(UsageStore store)
        {
            var pathString = storePath.ToString();

            Logger.Trace("SaveUsage: \"{0}\"", pathString);

            try
            {
                var json = SimpleJson.SerializeObject(store);
                storePath.WriteAllText(json, Encoding.UTF8);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "SaveUsage Error: \"{0}\"", pathString);
            }
        }
Beispiel #3
0
        private void WriteCacheToDisk()
        {
            logger.Trace("WriteCacheToDisk Count:{0} Path:{1}", connectionCache.Count, cachePath.ToString());

            var connectionCacheItems =
                connectionCache.Select(
                    pair =>
                    new ConnectionCacheItem {
                Host     = pair.Value.Host.ToString(),
                Username = pair.Value.Username
            }).ToArray();

            var json = SimpleJson.SerializeObject(connectionCacheItems);

            cachePath.WriteAllText(json);
        }
Beispiel #4
0
        private void SaveConnectionsToDisk(bool raiseChangedEvent = true)
        {
            try
            {
                var json = connections.Values.ToJson();
                cachePath.WriteAllText(json);
            }
            catch (IOException ex)
            {
                logger.Error(ex, "Error writing connection cache: {0}", cachePath);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error serializing connection cache: {0}", cachePath);
            }

            if (raiseChangedEvent)
            {
                ConnectionsChanged?.Invoke();
            }
        }
Beispiel #5
0
        private void SaveConnectionsToDisk(bool raiseChangedEvent = true)
        {
            //logger.Trace("WriteCacheToDisk Count:{0} Path:{1}", connectionCache.Count, cachePath.ToString());
            try
            {
                var json = connections.Values.ToJson();
                cachePath.WriteAllText(json);
            }
            catch (IOException ex)
            {
                logger.Error(ex, "Error writing connection cache: {0}", cachePath);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error serializing connection cache: {0}", cachePath);
            }

            if (raiseChangedEvent)
            {
                ConnectionsChanged?.Invoke();
            }
        }