Пример #1
0
        protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
        {
            var broker   = updateContext.GetBroker <IArchiveQueueEntityBroker>();
            var criteria = new ArchiveQueueSelectCriteria();

            criteria.PartitionArchiveKey.EqualTo(_archive.GetKey());
            criteria.StudyStorageKey.EqualTo(_studyStorage.GetKey());
            broker.Delete(criteria);
        }
Пример #2
0
        /// <summary>
        /// Determine if the specified partition can be deleted. If studies are scheduled
        /// to be archived on that partition or studies are already archived on that partition,
        /// then the partition may not be deleted.
        ///
        /// </summary>
        /// <param name="partition"></param>
        /// <returns></returns>
        public bool CanDelete(PartitionArchive partition)
        {
            ArchiveQueueAdaptor        archiveQueueAdaptor = new ArchiveQueueAdaptor();
            ArchiveQueueSelectCriteria selectCriteria      = new ArchiveQueueSelectCriteria();

            selectCriteria.PartitionArchiveKey.EqualTo(partition.GetKey());

            ArchiveStudyStorageAdaptor        archiveStudyStorageAdaptor = new ArchiveStudyStorageAdaptor();
            ArchiveStudyStorageSelectCriteria criteria = new ArchiveStudyStorageSelectCriteria();

            criteria.PartitionArchiveKey.EqualTo(partition.GetKey());

            int queueItems   = archiveQueueAdaptor.GetCount(selectCriteria);
            int storageItems = 0;

            // only check if we need to.
            if (queueItems == 0)
            {
                storageItems = archiveStudyStorageAdaptor.GetCount(criteria);
            }

            return(!((queueItems > 0) || (storageItems > 0)));
        }
Пример #3
0
        /// <summary>
        /// Get a list of restore candidates for the archive.
        /// </summary>
        /// <remarks>
        /// Note that at the current time only one cadidate is returned at a time.
        /// </remarks>
        /// <returns>A restore candidate.  null will be returned if no candidates exist.</returns>
        public virtual RestoreQueue GetRestoreCandidate()
        {
            RestoreQueue queueItem;

            using (IUpdateContext updateContext = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                QueryRestoreQueueParameters parms = new QueryRestoreQueueParameters();

                parms.PartitionArchiveKey    = _partitionArchive.GetKey();
                parms.ProcessorId            = ServerPlatform.ProcessorId;
                parms.RestoreQueueStatusEnum = RestoreQueueStatusEnum.Pending;
                IQueryRestoreQueue broker = updateContext.GetBroker <IQueryRestoreQueue>();

                // Stored procedure only returns 1 result.
                queueItem = broker.FindOne(parms);

                if (queueItem != null)
                {
                    updateContext.Commit();
                }
            }

            return(queueItem);
        }
Пример #4
0
        private void CreateSubCommands()
        {
            _archiveXml = new XmlDocument();
            _studyXml   = _storageLocation.LoadStudyXml();
            string studyFolder = _storageLocation.GetStudyPath();

            // Create the study date folder
            _zipFilename = Path.Combine(_hsmPath, _storageLocation.StudyFolder);
            AddSubCommand(new CreateDirectoryCommand(_zipFilename));

            // Create a folder for the study
            _zipFilename = Path.Combine(_zipFilename, _storageLocation.StudyInstanceUid);
            AddSubCommand(new CreateDirectoryCommand(_zipFilename));

            // Save the archive data in the study folder, based on a filename with a date / time stamp
            string filename = String.Format("{0}.zip", Platform.Time.ToString("yyyy-MM-dd-HHmm"));

            _zipFilename = Path.Combine(_zipFilename, filename);


            // Create the Xml data to store in the ArchiveStudyStorage table telling
            // where the archived study is located.
            XmlElement hsmArchiveElement = _archiveXml.CreateElement("HsmArchive");

            _archiveXml.AppendChild(hsmArchiveElement);
            XmlElement studyFolderElement = _archiveXml.CreateElement("StudyFolder");

            hsmArchiveElement.AppendChild(studyFolderElement);
            studyFolderElement.InnerText = _storageLocation.StudyFolder;
            XmlElement filenameElement = _archiveXml.CreateElement("Filename");

            hsmArchiveElement.AppendChild(filenameElement);
            filenameElement.InnerText = filename;
            XmlElement studyInstanceUidElement = _archiveXml.CreateElement("Uid");

            hsmArchiveElement.AppendChild(studyInstanceUidElement);
            studyInstanceUidElement.InnerText = _storageLocation.StudyInstanceUid;

            // Create the Zip file
            var zipStudyCommand = new CreateStudyZipCommand(_zipFilename, _studyXml, studyFolder, _tempPath)
            {
                ForceCompress = this.ForceCompress
            };

            zipStudyCommand.ProgressUpdated += (s, e) => EventsHelper.Fire(this.ProgressUpdated, this, e);
            AddSubCommand(zipStudyCommand);

            // Update the database.
            AddSubCommand(new InsertArchiveStudyStorageCommand(_storageLocation.GetKey(), _archive.GetKey(), _storageLocation.ServerTransferSyntaxKey, _archiveXml));
        }
Пример #5
0
 /// <summary>
 /// Delete the specified partition
 ///
 /// </summary>
 /// <param name="partition"></param>
 /// <returns></returns>
 public bool Delete(PartitionArchive partition)
 {
     return(_archiveAdapter.Delete(partition.GetKey()));
 }