示例#1
0
        public Models.BackupedFile GetLatestVersionWithTransferStatus(Models.BackupPlanFile planFile, params TransferStatus[] statuses)
        {
            Assert.IsNotNull(planFile);
            //Assert.IsFalse(IsTransient(Session, file));

            ICriteria crit = Session.CreateCriteria(PersistentType);

            string filePropertyName = this.GetPropertyName((Models.BackupedFile x) => x.File);

            crit.Add(Restrictions.Eq(filePropertyName, planFile));

            if (statuses != null && statuses.Length > 0)
            {
                string transferStatus = this.GetPropertyName((Models.BackupedFile x) => x.TransferStatus);
                crit.Add(Restrictions.Eq(transferStatus, TransferStatus.COMPLETED));
            }

            //string idPropertyName = this.GetPropertyName((Models.BackupedFile x) => x.Id);
            //crit.AddOrder(Order.Desc(idPropertyName));

            string fileLastWrittenAtPropertyName = this.GetPropertyName((Models.BackupedFile x) => x.FileLastWrittenAt);

            crit.AddOrder(Order.Desc(fileLastWrittenAtPropertyName));

            string backupPropertyName = this.GetPropertyName((Models.BackupedFile x) => x.Backup);

            crit.AddOrder(Order.Desc(backupPropertyName));

            crit.SetMaxResults(1);
            return(crit.UniqueResult <Models.BackupedFile>());           // May return null
        }
示例#2
0
 public Models.BackupedFile GetLatestVersionCompleted(Models.BackupPlanFile planFile)
 {
     return(GetLatestVersionWithTransferStatus(planFile, new TransferStatus[] { TransferStatus.COMPLETED }));
 }
示例#3
0
 // NOTE: This may return a version that has not COMPLETED the transfer.
 public Models.BackupedFile GetLatestVersion(Models.BackupPlanFile planFile)
 {
     return(GetLatestVersionWithTransferStatus(planFile));
 }