コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }