private void ButtonBackupServer_Click(object sender, RoutedEventArgs e) { if (ListServers.SelectedItem == null) { return; } var server = ListServers.SelectedItem as Server; var files = FtpManager.DownloadWorldFiles(server); var backups = DataManager.BackupFtpFiles(server, files); // replace backups in memory App.Backups.Clear(); foreach (var b in backups) { App.Backups.Add(b); } // save files to backup location BackupDataManager.SaveData(backups); // associate the backups and servers with one another from the new backup App.AssociateCollections(); return; }
private void InitializeAppData() { //deserialize application data Servers = new BetterObservableCollection <Server>(ServerDataManager.LoadData()); Backups = new BetterObservableCollection <Backup>(BackupDataManager.LoadData()); //associate servers/backups with one another based on ID's AssociateCollections(); //add event listeners to save each time server collection changes. Servers.CollectionChanged += PersistantData_Changed; Backups.CollectionChanged += PersistantData_Changed; }
protected override void OnStart(string[] args) { System.Diagnostics.Debugger.Launch(); DataManager.InitializeSettings(); //init settings in case the service runs before the desktop app //load in current servers and backups List <Server> servers = ServerDataManager.LoadData(); List <Backup> backups = BackupDataManager.LoadData(); //Set up file watcher InitFileWatcher(); //set up timers based on servers InitBackupTimers(servers); }
private void OnTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) { Server server = ((ServerBackupTimer)sender).Server; ModalMessage("backing up server: " + server.NameAndDescription); //download file from ftp server var files = FtpManager.DownloadWorldFiles(server); //Write downloaded world files to disk, also cleans up old files and backup entries var backups = DataManager.BackupFtpFiles(server, files); //save backup metadata to disk BackupDataManager.SaveData(backups); ModalMessage("backup complete - " + backups.Count + " backups added"); }