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>()); }
protected static SimpleExpression GetEqualityExpression( [NotNull] string propertyName, [CanBeNull] object value, bool ignoreCase) { Assert.ArgumentNotNullOrEmpty(propertyName, nameof(propertyName)); SimpleExpression expression = Restrictions.Eq(propertyName, value); if (ignoreCase) { expression.IgnoreCase(); } return(expression); }
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>()); }
//public RestoredFileRepository() //{ // BeforeInsert = (ITransaction tx, Models.RestoredFile instance) => // { // instance.UpdatedAt = DateTime.UtcNow; // }; // BeforeUpdate = (ITransaction tx, Models.RestoredFile instance) => // { // instance.UpdatedAt = DateTime.UtcNow; // }; //} public Models.RestoredFile GetByRestoreAndPath(Models.Restore restore, string path, bool ignoreCase = false) { Assert.IsNotNull(restore); Assert.That(path, Is.Not.Null.Or.Empty); ICriteria crit = Session.CreateCriteria(PersistentType); string restorePropertyName = this.GetPropertyName((Models.RestoredFile x) => x.Restore); string filePropertyName = this.GetPropertyName((Models.RestoredFile x) => x.File); string filePathPropertyName = this.GetPropertyName((Models.RestorePlanFile x) => x.Path); crit.CreateAlias(filePropertyName, "f"); crit.Add(Restrictions.Eq(restorePropertyName, restore)); SimpleExpression expr = Restrictions.Eq("f." + filePathPropertyName, path); if (ignoreCase) { expr = expr.IgnoreCase(); } crit.Add(expr); return(crit.UniqueResult <Models.RestoredFile>()); }
public IList <Models.BackupedFile> GetCompleteByPlanAndPath(Models.BackupPlan plan, string path, bool ignoreCase = false) { Assert.IsNotNull(plan); Assert.That(path, Is.Not.Null.Or.Empty); ICriteria crit = Session.CreateCriteria(PersistentType); // By status string transferStatusPropertyName = this.GetPropertyName((Models.BackupedFile x) => x.TransferStatus); crit.Add(Restrictions.Eq(transferStatusPropertyName, TransferStatus.COMPLETED)); // By plan string backupPlanPropertyName = this.GetPropertyName((Models.Backup x) => x.BackupPlan); string backupPropertyName = this.GetPropertyName((Models.BackupedFile x) => x.Backup); crit.CreateAlias(backupPropertyName, "bp"); crit.Add(Restrictions.Eq("bp." + backupPlanPropertyName, plan)); // By path 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); // Order string idPropertyName = this.GetPropertyName((Models.BackupedFile x) => x.Id); crit.AddOrder(Order.Desc(idPropertyName)); return(crit.List <Models.BackupedFile>()); }