protected override void OnExecute(CommandProcessor theProcessor) { // Setup the insert parameters string seriesInstanceUid = _file.DataSet[DicomTags.SeriesInstanceUid].GetString(0, string.Empty); string sopinstanceUid = _file.MediaStorageSopInstanceUid; FileSize = 0; var finfo = new FileInfo(_file.Filename); if (finfo.Exists) { FileSize = finfo.Length; } // Save the collection for undo purposes SeriesXml seriesXml = _stream[seriesInstanceUid]; if (seriesXml != null) { InstanceXml instanceXml = seriesXml[sopinstanceUid]; if (instanceXml != null) { _saveCollection = instanceXml.Collection; } } if (false == _stream.RemoveFile(_file)) { Platform.Log(LogLevel.Warn, "SOP was unexpectedly not in XML Study Descriptor for file: {0}", _file.Filename); } if (false == _stream.AddFile(_file, FileSize, _outputSettings)) { Platform.Log(LogLevel.Error, "Unexpected error adding SOP to XML Study Descriptor for file {0}", _file.Filename); throw new ApplicationException("Unexpected error adding SOP to XML Study Descriptor for SOP: " + _file.MediaStorageSopInstanceUid); } // Write it back out. We flush it out with every added image so that if a failure happens, // we can recover properly. WriteStudyStream( Path.Combine(_studyStorageLocation.GetStudyPath(), _studyStorageLocation.StudyInstanceUid + ".xml"), Path.Combine(_studyStorageLocation.GetStudyPath(), _studyStorageLocation.StudyInstanceUid + ".xml.gz"), _stream); }
protected override void OnUndo() { Platform.Log(LogLevel.Info, "Undoing InsertStudyXmlCommand"); _stream.RemoveFile(_file); string streamFile = Path.Combine(_studyStorageLocation.GetStudyPath(), _studyStorageLocation.StudyInstanceUid + ".xml"); string gzStreamFile = streamFile + ".gz"; WriteStudyStream(streamFile, gzStreamFile, _stream); }
protected override void OnExecute(CommandProcessor commandProcessor) { _studyXml.RemoveFile(_file); // flush it into disk // Write it back out. We flush it out with every added image so that if a failure happens, // we can recover properly. string streamFile = _studyLocation.GetStudyXmlPath(); string gzStreamFile = streamFile + ".gz"; WriteStudyStream(streamFile, gzStreamFile, _studyXml); }
protected override void OnUndo() { if (!_duplicate) { _studyXml.RemoveFile(_file); if (_writeFile) { bool fileCreated; _studyStorageLocation.SaveStudyXml(_studyXml, out fileCreated); } } }