public string[] Truncate(string name) { if (name == null) { return(ConsoleConfigSection.GetConfig().Clean .Cast <NameValueConfigElement>() .Select(x => x.Name).ToArray()); } var stringType = ConsoleConfigSection.GetConfig().Clean .Cast <NameValueConfigElement>().First(x => x.Name == name).Value; var type = Type.GetType(stringType); if (type == null) { throw new Exception(stringType + " can not be resolved."); } var repoFinder = Context.Resolve <RepositoryFinder>(); var repo = repoFinder.CreateRepository(type); (repo.Item1 as IRepository).Truncate(); Writer.WriteLine(name + " truncated"); return(null); }
public string[] Restore(string name) { if (name == null) { return(ConsoleConfigSection.GetConfig().Restore .Cast <NameValueConfigElement>() .Select(x => x.Name).ToArray()); } var filename = String.Format(@"Restore{1}{0}.xml", name, Path.DirectorySeparatorChar); var stringType = ConsoleConfigSection.GetConfig().Restore .Cast <NameValueConfigElement>().First(x => x.Name == name).Value; var type = Type.GetType(stringType); if (type == null) { throw new Exception(stringType + " can not be resolved."); } if (File.Exists(filename)) { INHibernateFileBackupBase fileBackup = Context.Resolve(type) as INHibernateFileBackupBase; fileBackup.BackupFile = filename; fileBackup.ImportStrategy = BoxImporterStrategy.SkipExisting; fileBackup.Restore(); } else { Writer.WriteLine(filename + " not found"); } return(null); }
public string[] Export(string name) { if (name == null) { return(ConsoleConfigSection.GetConfig().Restore .Cast <NameValueConfigElement>() .Select(x => x.Name).ToArray()); } var filename = String.Format(@"Restore{1}{0}_exported.xml", name, Path.DirectorySeparatorChar); var stringType = ConsoleConfigSection.GetConfig().Restore .Cast <NameValueConfigElement>().First(x => x.Name == name).Value; var type = Type.GetType(stringType); if (type == null) { throw new Exception(stringType + " can not be resolved."); } if (File.Exists(filename)) { File.Delete(filename); } INHibernateFileBackupBase fileBackup = Context.Resolve(type) as INHibernateFileBackupBase; fileBackup.BackupFile = filename; fileBackup.Backup(); return(null); }