Example #1
0
        public async Task Load()
        {
            IsLoading.Value = true;
            try
            {
                await DbBackup.Execute();
            }
            catch (Exception ex)
            {
                MyLogger.Log("Exception occured on DB backup.", ex);
            }
            MyLogger.Log("Data loading...");
            DbContext = new AppDbContext();
            var cacheLoading = PortNumberCache.Load();
            var dbLoading    = Task.Run(async() =>
            {
                await SSHConnectionInfo.RefreshAll(DbContext);
                SSHConnectionInfo.All
                .ForEach(x => App.Current.Dispatcher.Invoke(() => SSHConnectionInfos.Items.Add(x)));
                DbContext.RDPConnectionInfos.ToList()
                .ForEach(x => App.Current.Dispatcher.Invoke(() => RDPConnectionInfos.Items.Add(x)));
                DbContext.InitSecurePasswords();
            });
            await Task.WhenAll(new[]
            {
                cacheLoading,
                dbLoading,
            });

            MyLogger.Log("Data loaded.");
            IsLoading.Value = false;
            InitConnectionInvokeTimer();
        }
Example #2
0
        public override async void Dispose()
        {
            SSHConnectionInfos.Dispose();
            Connections.Dispose();
            DbContext?.Dispose();
            await PortNumberCache.Save();

            base.Dispose();
        }