public static DeletedStudyInfo CreateDeletedStudyInfo(StudyDeleteRecord record)
        {
            Filesystem fs = Filesystem.Load(record.FilesystemKey);

            StudyDeleteExtendedInfo extendedInfo = XmlUtils.Deserialize <StudyDeleteExtendedInfo>(record.ExtendedInfo);
            DeletedStudyInfo        info         = new DeletedStudyInfo
            {
                DeleteStudyRecord = record.GetKey(),
                RowKey            = record.GetKey().Key,
                StudyInstanceUid  = record.StudyInstanceUid,
                PatientsName      = record.PatientsName,
                AccessionNumber   = record.AccessionNumber,
                PatientId         = record.PatientId,
                StudyDate         = record.StudyDate,
                PartitionAE       = record.ServerPartitionAE,
                StudyDescription  = record.StudyDescription,
                BackupFolderPath  = fs.GetAbsolutePath(record.BackupPath),
                ReasonForDeletion = record.Reason,
                DeleteTime        = record.Timestamp,
                UserName          = extendedInfo.UserName,
                UserId            = extendedInfo.UserId
            };

            if (record.ArchiveInfo != null)
            {
                info.Archives = XmlUtils.Deserialize <DeletedStudyArchiveInfoCollection>(record.ArchiveInfo);
            }


            return(info);
        }
        public void Insert(Guid Guid, DateTime Timestamp, string Reason, string ServerPartitionAE, Guid FilesystemGUID,
                           string BackupPath, string StudyInstanceUid, string AccessionNumber, string PatientId,
                           string PatientsName, string StudyId, string StudyDescription, string StudyDate,
                           string StudyTime, string ArchiveInfo, string ExtendedInfo)
        {
            var item = new StudyDeleteRecord();

            item.Guid = Guid;

            item.Timestamp = Timestamp;

            item.Reason = Reason;

            item.ServerPartitionAE = ServerPartitionAE;

            item.FilesystemGUID = FilesystemGUID;

            item.BackupPath = BackupPath;

            item.StudyInstanceUid = StudyInstanceUid;

            item.AccessionNumber = AccessionNumber;

            item.PatientId = PatientId;

            item.PatientsName = PatientsName;

            item.StudyId = StudyId;

            item.StudyDescription = StudyDescription;

            item.StudyDate = StudyDate;

            item.StudyTime = StudyTime;

            item.ArchiveInfo = ArchiveInfo;

            item.ExtendedInfo = ExtendedInfo;


            item.Save(UserName);
        }
Пример #3
0
        public void OnStudyDeleted()
        {
            if (!Enabled)
            {
                return;
            }

            if (_context.WorkQueueItem.WorkQueueTypeEnum == WorkQueueTypeEnum.WebDeleteStudy)
            {
                Study study = _context.Study;

                if (study == null)
                {
                    Platform.Log(LogLevel.Info, "Not logging Study Delete information due to missing Study record for study: {0} on partition {1}",
                                 _context.StorageLocation.StudyInstanceUid,
                                 _context.ServerPartition.AeTitle);
                    return;
                }

                StudyStorageLocation storage = _context.StorageLocation;

                using (IUpdateContext updateContext = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
                {
                    // Setup the parameters
                    IStudyDeleteRecordEntityBroker broker = updateContext.GetBroker <IStudyDeleteRecordEntityBroker>();

                    StudyDeleteRecordUpdateColumns parms = new StudyDeleteRecordUpdateColumns();
                    parms.Timestamp = Platform.Time;
                    WebDeleteStudyLevelQueueData extendedInfo =
                        XmlUtils.Deserialize <WebDeleteStudyLevelQueueData>(_context.WorkQueueItem.Data);

                    parms.Reason = extendedInfo != null?
                                   extendedInfo.Reason:_context.WorkQueueItem.WorkQueueTypeEnum.LongDescription;

                    parms.ServerPartitionAE = _context.ServerPartition.AeTitle;
                    parms.FilesystemKey     = storage.FilesystemKey;

                    parms.AccessionNumber  = study.AccessionNumber;
                    parms.PatientId        = study.PatientId;
                    parms.PatientsName     = study.PatientsName;
                    parms.StudyInstanceUid = study.StudyInstanceUid;
                    parms.StudyDate        = study.StudyDate;
                    parms.StudyDescription = study.StudyDescription;
                    parms.StudyTime        = study.StudyTime;

                    parms.BackupPath = BackupZipFileRelativePath;

                    if (_archives != null && _archives.Count > 0)
                    {
                        parms.ArchiveInfo = XmlUtils.SerializeAsXmlDoc(_archives);
                    }

                    StudyDeleteExtendedInfo extInfo = new StudyDeleteExtendedInfo();
                    extInfo.ServerInstanceId = ServerPlatform.ServerInstanceId;
                    extInfo.UserId           = _context.UserId;
                    extInfo.UserName         = _context.UserName;
                    parms.ExtendedInfo       = XmlUtils.SerializeAsString(extInfo);

                    StudyDeleteRecord deleteRecord = broker.Insert(parms);
                    if (deleteRecord == null)
                    {
                        Platform.Log(LogLevel.Error, "Unexpected error when trying to create study delete record: {0} on partition {1}",
                                     study.StudyInstanceUid, _context.ServerPartition.Description);
                    }
                    else
                    {
                        updateContext.Commit();
                    }
                }
            }
        }