Esempio n. 1
0
        public void BackUpData(DateTime?fromDay, DateTime?toDay, BackUpStatus theRuningStatusInSession)
        {
            try
            {
                //写入迁移配置文件
                TransferService.StartLittleProcess(theRuningStatusInSession, TransferConfig.WriteConfigToString());
                TransferConfig.WriteConfig(this, fromDay, toDay);

                //配置所有过滤器
                TransferService.StartLittleProcess(theRuningStatusInSession, Utility._Process_ConfigFilter);
                ConfigAllRuleFitler();

                //每个数据库执行操作
                foreach (DbTransfer dt in _DbsToTransfer)
                {
                    dt.BackUpData(fromDay, toDay, theRuningStatusInSession);
                }

                //打包下载文件
                TransferService.StartLittleProcess(theRuningStatusInSession, Utility._Process_RarBackUpFile);
                string theBackUpSimpleName = string.Format("{0}{1}.rar", _DefaultBackUpDbName, Utility.GetTimeStamp());
                string theBackUpFullPath   = string.Format("{0}{1}", DiskOperations.DownLoadDirectory, theBackUpSimpleName);
                CommandRunner.RarDirectoryToFile(theBackUpFullPath, DiskOperations.DataTemp_ForBackUpDirectory);
                theRuningStatusInSession.SuccessFileName     = theBackUpSimpleName;
                theRuningStatusInSession.SuccessFullFileName = theBackUpFullPath;

                //清理无用的数据
                TransferService.StartLittleProcess(theRuningStatusInSession, Utility._Process_CleanNonUseData);
                CommandRunner.CleanUpDirectory(DiskOperations.DataTemp_ForBackUpDirectory);
                theRuningStatusInSession.AddInformationLine(DiskOperations.DelFilesFromDirectory(DiskOperations.DownLoadDirectory, _DefaultBackUpDbName, theBackUpFullPath, _DefaultDownloadFiles));

                //成功运行
                TransferService.SuccessFlag(theRuningStatusInSession);
            }
            catch (ApplicationException ae)
            {
                TryBackUpErrorClean();
                TransferService.FailedFlag(theRuningStatusInSession, ae.Message);
            }
            catch (Exception e)
            {
                TryBackUpErrorClean();
                TransferService.ErrorFlag(theRuningStatusInSession, e.Message);
            }
        }
Esempio n. 2
0
        public static void RestoreData(string theRarFile, RestoreStatus theRuningStatusInSession)
        {
            StartFlag(theRuningStatusInSession);

            try
            {
                //读入静态配置表
                StartLittleProcess(theRuningStatusInSession, StaticConfigTable.ReadToTableToString());
                StaticConfigTable.ReadToTable();

                //准备所需文件夹
                StartLittleProcess(theRuningStatusInSession, DiskOperations.PrepareForRestoreToString());
                DiskOperations.PrepareForRestore();

                //检查Rar压缩器
                StartLittleProcess(theRuningStatusInSession, CommandRunner.CheckRarReadyToString());
                CommandRunner.CheckRarReady();

                //配置日志对象
                StartLittleProcess(theRuningStatusInSession, TransferDataLogManager.TryConfigLogObjToString());
                TransferDataLogManager.TryConfigLogObj();

                //解析Rar数据
                StartLittleProcess(theRuningStatusInSession, TransferConfig.AnalyseRarDataToString());
                DateTime?    fromDay;
                DateTime?    toDay;
                TransferRule theTransferRule = TransferConfig.AnalyseRarData(theRarFile, out fromDay, out toDay, DiskOperations.DataTemp_ForRestoreDirectory, false, false);

                //根据规则起另外线程开始工作
                RestoreProcess rp = StartRestore;
                rp.BeginInvoke(theTransferRule, fromDay, toDay, theRuningStatusInSession, null, null);
            }
            catch (ApplicationException ae)
            {
                FailedFlag(theRuningStatusInSession, ae.Message);
            }
        }
Esempio n. 3
0
 public static TransferRule AnalyseRarData(string theRarFile, out DateTime?fromDay, out DateTime?toDay)
 {
     StaticConfigTable.ReadToTable();
     DiskOperations.PrepareForBackUp();
     return(TransferConfig.AnalyseRarData(theRarFile, out fromDay, out toDay, DiskOperations.TempDirectory, true, true));
 }