Exemplo n.º 1
0
        internal void RestoreData(DateTime?fromDay, DateTime?toDay, RestoreStatus theRuningStatusInSession)
        {
            //备份源数据库
            TransferService.StartLittleProcess(theRuningStatusInSession, string.Format("{0}{1}", Utility._Process_BackUpDb, _DbName));
            string targetName = string.Format("{0}{1}{2}.bak", DiskOperations.DbBackUp_ForRestoreDirectory, _DbName, Utility.GetTimeStamp());

            SqlCommandRunner.BackUpDb(_DbName, targetName);

            //删减数据库备份
            TransferService.StartLittleProcess(theRuningStatusInSession, string.Format("{0}", Utility._Process_DelNonuseDbBackUp));
            theRuningStatusInSession.AddInformationLine(DiskOperations.DelFilesFromDirectory(DiskOperations.DbBackUp_ForRestoreDirectory, _DbName, targetName, _DefaultBackUpDbCount));

            //拷贝下载的数据库用于数据还原
            string copyDbName = _DbName + _ForRestoreCopyDbSuffix;
            string downLoadDbBackUpFullName = string.Format("{0}{1}{2}.bak", DiskOperations.DataTemp_ForRestoreDirectory, _DbName, _OrginCopyDbSuffix);

            TransferService.StartLittleProcess(theRuningStatusInSession, string.Format("{0}{1}", Utility._Process_CopyDb, copyDbName));
            SqlCommandRunner.RestoreDbFromFile(copyDbName, DiskOperations.TempDirectory, downLoadDbBackUpFullName);

            //每一个表的数据还原
            foreach (TableTransfer tt in _TablesToTransfer)
            {
                tt.RestoreData(fromDay, toDay, theRuningStatusInSession);
            }

            //删除无用的数据库拷贝
            TransferService.StartLittleProcess(theRuningStatusInSession, string.Format("{0}{1}", Utility._Process_DelNonUseDb, copyDbName));
            SqlCommandRunner.DeleteDb(copyDbName);
        }
Exemplo n.º 2
0
 internal void RestoreData(DateTime? fromDay, DateTime? toDay, RestoreStatus theRuningStatusInSession)
 {
     TransferService.StartLittleProcess(theRuningStatusInSession, string.Format("{0}{1}", Utility._Process_RestoreTable, _TableName));
     theRuningStatusInSession.AddInformationLine(_TableFilter.RestoreTableData(fromDay, toDay));
 }