Пример #1
0
        public IEnumerable <Backup> GetBackups()
        {
            var repository = new BackupRepository();
            var output     = repository.Get();

            return(output);
        }
Пример #2
0
        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);
        }