public IList <Models.BackupedFile> GetCompletedByStorageAccountAndPath(Models.StorageAccount account, string path, string version = null, bool ignoreCase = false) { Assert.IsNotNull(account); Assert.That(path, Is.Not.Null.Or.Empty); ICriteria crit = Session.CreateCriteria(PersistentType); string storageAccountPropertyName = this.GetPropertyName((Models.BackupedFile x) => x.StorageAccount); crit.Add(Restrictions.Eq(storageAccountPropertyName, account)); string transferStatusPropertyName = this.GetPropertyName((Models.BackupedFile x) => x.TransferStatus); crit.Add(Restrictions.Eq(transferStatusPropertyName, TransferStatus.COMPLETED)); if (version != null) { DateTime fileLastWrittenAt = DateTime.ParseExact(version, Models.BackupedFile.VersionFormat, CultureInfo.InvariantCulture); string fileLastWrittenAtPropertyName = this.GetPropertyName((Models.BackupedFile x) => x.FileLastWrittenAt); crit.Add(Restrictions.Eq(fileLastWrittenAtPropertyName, fileLastWrittenAt)); } string filePropertyName = this.GetPropertyName((Models.BackupedFile x) => x.File); string filePathPropertyName = this.GetPropertyName((Models.BackupPlanFile x) => x.Path); crit.CreateAlias(filePropertyName, "f"); SimpleExpression expr = Restrictions.Eq("f." + filePathPropertyName, path); if (ignoreCase) { expr = expr.IgnoreCase(); } crit.Add(expr); return(crit.List <Models.BackupedFile>()); }
//public BackupPlanFileRepository() //{ // BeforeInsert = (ITransaction tx, Models.BackupPlanFile instance) => // { // instance.CreatedAt = DateTime.UtcNow; // }; // BeforeUpdate = (ITransaction tx, Models.BackupPlanFile instance) => // { // instance.UpdatedAt = DateTime.UtcNow; // }; //} public IList <Models.BackupPlanFile> GetAllByStorageAccount(Models.StorageAccount account) { Assert.IsNotNull(account); ICriteria crit = Session.CreateCriteria(PersistentType); string storageAccountPropertyName = this.GetPropertyName((Models.BackupPlanFile x) => x.StorageAccount); crit.Add(Restrictions.Eq(storageAccountPropertyName, account)); return(crit.List <Models.BackupPlanFile>()); }
public Models.Synchronization GetLatestByStorageAccount(Models.StorageAccount account) { Assert.IsNotNull(account); ICriteria crit = Session.CreateCriteria(PersistentType); string storageAccountPropertyName = this.GetPropertyName((Models.Synchronization x) => x.StorageAccount); crit.Add(Restrictions.Eq(storageAccountPropertyName, account)); string idPropertyName = this.GetPropertyName((Models.Synchronization x) => x.Id); crit.AddOrder(Order.Desc(idPropertyName)); crit.SetMaxResults(1); return(crit.UniqueResult <Models.Synchronization>()); }
public Models.BackupPlanFile GetByStorageAccountAndPath(Models.StorageAccount account, string path, bool ignoreCase = false) { Assert.That(path, Is.Not.Null.Or.Empty); ICriteria crit = Session.CreateCriteria(PersistentType); string storageAccountPropertyName = this.GetPropertyName((Models.BackupPlanFile x) => x.StorageAccount); crit.Add(Restrictions.Eq(storageAccountPropertyName, account)); string pathPropertyName = this.GetPropertyName((Models.BackupPlanFile x) => x.Path); SimpleExpression expr = Restrictions.Eq(pathPropertyName, path); if (ignoreCase) { expr = expr.IgnoreCase(); } crit.Add(expr); return(crit.UniqueResult <Models.BackupPlanFile>()); }
public Models.BackupPlanPathNode GetByStorageAccountAndTypeAndPath(Models.StorageAccount account, Models.EntryType type, string path, bool ignoreCase = false) { Assert.IsNotNull(account); ICriteria crit = Session.CreateCriteria(PersistentType); string storageAccountPropertyName = this.GetPropertyName((Models.BackupPlanPathNode x) => x.StorageAccount); string typePropertyName = this.GetPropertyName((Models.BackupPlanPathNode x) => x.Type); string pathPropertyName = this.GetPropertyName((Models.BackupPlanPathNode x) => x.Path); crit.Add(Restrictions.Eq(storageAccountPropertyName, account)); crit.Add(Restrictions.Eq(typePropertyName, type)); SimpleExpression expr = Restrictions.Eq(pathPropertyName, path); if (ignoreCase) { expr = expr.IgnoreCase(); } crit.Add(expr); return(crit.UniqueResult <Models.BackupPlanPathNode>()); }