예제 #1
0
 private void MigrateStatistics(EsentPersistentDictionary cacheStore, string key, Statistics statistics)
 {
     var entryKey = key.SubstringAfter("_");
     switch (entryKey)
     {
         case "TotalFilesTransferred":
             statistics.TotalFilesTransferred = cacheStore.Get<int>(key);
             break;
         case "TotalBytesTransferred":
             statistics.TotalBytesTransferred = cacheStore.Get<long>(key);
             break;
         case "TotalTimeSpentWithTransfer":
             statistics.TotalTimeSpentWithTransfer = cacheStore.Get<TimeSpan>(key);
             break;
         case "TotalUsageTime":
             statistics.TotalUsageTime = cacheStore.Get<TimeSpan>(key);
             break;
         case "ApplicationStarted":
             statistics.ApplicationStarted = cacheStore.Get<int>(key);
             break;
         case "ApplicationCrashed":
             statistics.ApplicationCrashed = cacheStore.Get<int>(key);
             break;
     }
 }
예제 #2
0
        public StatisticsViewModel(ICacheManager cacheManager, IDbContext dbContext)
        {
            UsageStart = DateTime.Now;
            CommandUsage = new Dictionary<string, int>();
            ServerUsage = new Dictionary<FtpServerType, int>();

            _cacheManager = cacheManager;
            _dbContext = dbContext;
            using(var db = _dbContext.Open())
            {
                _statistics = db.Get<Statistics>().First();
            }
            DelegateCommand.BeforeAction = CountCommandUsage;
            EventAggregator.GetEvent<OpenNestedPaneEvent>().Subscribe(OnPaneOpen);
        }
예제 #3
0
        private EsentPersistentDictionary MigrateEsentToDatabase()
        {
            EsentPersistentDictionary cacheStore = null;
            var statistics = new Statistics();
            var userSettings = new UserSettings();
            var sw = new Stopwatch();
            sw.Start();
            using (var db = _dbContext.Open(true))
            {
                if (EsentExists())
                {
                    this.NotifyProgressStarted();
                    cacheStore = new EsentPersistentDictionary(_esentDir);
                    UpgradeEsentToLatestVersion(cacheStore);
                    var keys = cacheStore.Keys;
                    SetItemsCount(keys.Length);
                    foreach (var key in keys)
                    {
                        var prefix = key.SubstringBefore("_");
                        switch (prefix)
                        {
                            case "CacheEntry":
                                MigrateCacheItem(cacheStore, db, key);
                                break;
                            case "FtpConnection":
                                MigrateFtpConnection(cacheStore, db, key);
                                break;
                            case "Stat":
                                MigrateStatistics(cacheStore, key, statistics);
                                break;
                            case "WarningMessage":
                                MigrateIgnoredMessages(db, key);
                                break;
                            default:
                                MigrateUserSettings(cacheStore, key, userSettings);
                                break;
                        }
                        IncrementItemsMigrated();
                    }
                }
                db.Insert(statistics);
                db.Insert(userSettings);
            }
            sw.Stop();
            Debug.WriteLine("[MIGRATION] Database created in {0}", sw.Elapsed);

            if (Directory.Exists(_esentDir))
            {
                foreach (var postData in Directory.GetFiles(Path.Combine(_esentDir, "post")))
                {
                    File.Move(postData, Path.Combine(App.PostDirectory, Path.GetFileName(postData)));
                }
            }
            if (cacheStore != null) this.NotifyProgressFinished();
            return cacheStore;
        }