コード例 #1
0
        private void RestoreFilesystem()
        {
            if (!RequiresRollback || !_initialized || _backupDir == null)
            {
                return;
            }

            if (NewStudyPath == _oldStudyPath)
            {
                // Study folder was not changed. Files were overwritten.

                // restore header
                Platform.Log(LogLevel.Info, "Restoring old study header...");

                FileUtils.Copy(Path.Combine(_backupDir, _study.StudyInstanceUid + ".xml"), _oldStudyLocation.GetStudyXmlPath(), true);
                FileUtils.Copy(Path.Combine(_backupDir, _study.StudyInstanceUid + ".xml.gz"),
                               _oldStudyLocation.GetCompressedStudyXmlPath(), true);

                // restore updated SOPs
                Platform.Log(LogLevel.Info, "Restoring old study folder... {0} sop need to be restored", _updatedSopList.Count);
                int restoredCount = 0;
                foreach (InstanceInfo sop in _updatedSopList)
                {
                    string backupSopPath = Path.Combine(_backupDir, sop.SopInstanceUid + ServerPlatform.DicomFileExtension);

                    FileUtils.Copy(backupSopPath, _oldStudyLocation.GetSopInstancePath(sop.SeriesInstanceUid, sop.SopInstanceUid), true);

                    restoredCount++;
                    Platform.Log(ServerPlatform.InstanceLogLevel, "Restored SOP {0} [{1} of {2}]", sop.SopInstanceUid, restoredCount,
                                 _updatedSopList.Count);

                    SimulateErrors();
                }

                if (restoredCount > 0)
                {
                    Platform.Log(LogLevel.Info, "{0} SOP(s) have been restored.", restoredCount);
                }
            }
            else
            {
                // Different study folder was used. Original folder must be kept around
                // because we are rolling back.
                _deleteOriginalFolder = false;
            }
        }