public async Task <FileVersionerResults> DoVersion(Models.Backup backup, LinkedList <string> filePaths, bool newVersion) { Assert.IsNotNull(backup); Assert.AreEqual(TransferStatus.RUNNING, backup.Status); Assert.IsNotNull(filePaths); Results.Reset(); await ExecuteOnBackround(() => { ISession session = NHibernateHelper.GetSession(); try { BackupRepository daoBackup = new BackupRepository(session); BackupPlanFileRepository daoBackupPlanFile = new BackupPlanFileRepository(session); Backup = daoBackup.Get(backup.Id); IList <Models.BackupPlanFile> list = newVersion ? daoBackupPlanFile.GetAllByBackupPlan(Backup.BackupPlan) : daoBackupPlanFile.GetAllPendingByBackup(Backup); AllFilesFromPlan = list.ToDictionary <Models.BackupPlanFile, string>(p => p.Path); Execute(Backup, filePaths, newVersion); Save(session); } catch (Exception ex) { string message = string.Format("File versioning FAILED with an exception: {0}", ex.Message); Results.OnError(this, message); logger.Log(LogLevel.Error, ex, message); throw ex; } finally { //session.Close(); if (session.IsConnected) { session.Disconnect(); } } }, CancellationToken); return(Results); }
public async Task <FileVersionerResults> DoRestore(Models.Restore restore, LinkedList <CustomVersionedFile> files, bool newRestore) { Assert.IsNotNull(restore); Assert.AreEqual(TransferStatus.RUNNING, restore.Status); Assert.IsNotNull(files); Results.Reset(); await ExecuteOnBackround(() => { RestoreRepository daoRestore = new RestoreRepository(); Restore = daoRestore.Get(restore.Id); RestorePlanFileRepository daoRestorePlanFile = new RestorePlanFileRepository(); AllFilesFromPlan = daoRestorePlanFile.GetAllByPlan(restore.RestorePlan).ToDictionary <Models.RestorePlanFile, string>(p => p.Path); Execute(restore, files, newRestore); Save(); }, CancellationToken); return(Results); }