コード例 #1
0
ファイル: HsmArchive.cs プロジェクト: ronmark1/ClearCanvas-1
        /// <summary>
        /// Start the archive.
        /// </summary>
        /// <param name="archive">The <see cref="PartitionArchive"/> to start.</param>
        public override void Start(PartitionArchive archive)
        {
            HsmPath = string.Empty;

            PartitionArchive = archive;

            LoadServerPartition();

            //Hsm Archive specific Xml data.
            XmlElement element = archive.ConfigurationXml.DocumentElement;

            if (element != null)
            {
                foreach (XmlElement node in element.ChildNodes)
                {
                    if (node.Name.Equals("RootDir"))
                    {
                        HsmPath = node.InnerText;
                    }
                }
            }

            // Start the restore service
            _restoreService = new HsmRestoreService("HSM Restore", this);
            _restoreService.StartService();

            // If not "readonly", start the archive service.
            if (!PartitionArchive.ReadOnly)
            {
                _archiveService = new HsmArchiveService("HSM Archive", this);
                _archiveService.StartService();
            }
        }
コード例 #2
0
        /// <summary>
        /// Start the archive.
        /// </summary>
        /// <param name="archive">The <see cref="PartitionArchive"/> to start.</param>
        public override void Start(PartitionArchive archive)
        {
            _partitionArchive = archive;

            LoadServerPartition();

            _nasPath = string.Empty;

            //Nas Archive specific Xml data.
            XmlElement element = archive.ConfigurationXml.DocumentElement;

            foreach (XmlElement node in element.ChildNodes)
            {
                switch (node.Name)
                {
                case "RootDir": _nasPath = node.InnerText; break;

                case "MinimumAvailableSpace": MinimumAvailableSpace = long.Parse(node.InnerText); break;
                }
            }

            // Start the restore service
            _restoreService = new NasRestoreService("NAS Restore", this);
            _restoreService.StartService();

            // If not "readonly", start the archive service.
            if (!_partitionArchive.ReadOnly)
            {
                _archiveService = new NasArchiveService("NAS Archive", this);
                _archiveService.StartService();
            }
        }
コード例 #3
0
        public ArchiveStudyCommand(StudyStorageLocation storageLocation, string hsmPath, string tempPath, PartitionArchive archive)
        {
            _storageLocation = storageLocation;
            _hsmPath         = hsmPath;
            _tempPath        = tempPath;
            _archive         = archive;

            CreateSubCommands();
        }
コード例 #4
0
        public void OnStudyDeleting()
        {
            if (!Enabled)
            {
                return;
            }

            StudyStorageLocation        storage  = _context.StorageLocation;
            IList <ArchiveStudyStorage> archives = StudyStorageLocation.GetArchiveLocations(storage.GetKey());

            if (archives != null && archives.Count > 0)
            {
                _archives = new DeletedStudyArchiveInfoCollection();
                foreach (ArchiveStudyStorage archive in archives)
                {
                    DeletedStudyArchiveInfo archiveInfo = new DeletedStudyArchiveInfo();
                    archiveInfo.ArchiveTime = archive.ArchiveTime;
                    archiveInfo.ArchiveXml  = archive.ArchiveXml;

                    archiveInfo.PartitionArchiveRef = PartitionArchive.Load(archive.PartitionArchiveKey).GetKey().Key;
                    archiveInfo.TransferSyntaxUid   = archive.ServerTransferSyntax.Uid;
                    _archives.Add(archiveInfo);
                }
            }



            // only backup if study is manually deleted
            if (_context.WorkQueueItem.WorkQueueTypeEnum == WorkQueueTypeEnum.WebDeleteStudy)
            {
                using (var processor = new ServerCommandProcessor("Backup deleted study"))
                {
                    string path = _context.Filesystem.ResolveAbsolutePath(BackupSubPath);

                    Platform.Log(LogLevel.Info, "Saving a copy of the study to {0}...", path);

                    var mkdir = new CreateDirectoryCommand(path);
                    processor.AddCommand(mkdir);

                    var zip = new ZipStudyFolderCommand(storage.GetStudyPath(), BackupFullPath);
                    processor.AddCommand(zip);

                    if (!processor.Execute())
                    {
                        throw new ApplicationException(String.Format("Unable to backup study: {0}", processor.FailureReason));
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Update the partition whose GUID and new information are specified in <paramref name="partition"/>.
        ///
        /// </summary>
        /// <param name="partition"></param>
        /// <returns></returns>
        public bool UpdatePartition(PartitionArchive partition)
        {
            Platform.Log(LogLevel.Info, "Updating partition archive : Type = {0} , Description = {1}", partition.ArchiveTypeEnum.Description, partition.Description);

            bool result = _archiveAdapter.Update(partition);

            if (result)
            {
                Platform.Log(LogLevel.Info, "Updated partition archive : Type = {0} , Description = {1}", partition.ArchiveTypeEnum.Description, partition.Description);
            }
            else
            {
                Platform.Log(LogLevel.Info, "Failed to update partition archive : Type = {0} , Description = {1}", partition.ArchiveTypeEnum.Description, partition.Description);
            }

            return(result);
        }
コード例 #6
0
        /// <summary>
        /// Add a partition in the database.
        /// </summary>
        /// <param name="partition"></param>
        public bool AddPartition(PartitionArchive partition)
        {
            Platform.Log(LogLevel.Info, "Adding new partition archive : Type = {0} , Description = {1}", partition.ArchiveTypeEnum.Description, partition.Description);

            bool result = _archiveAdapter.AddPartitionArchive(partition);

            if (result)
            {
                Platform.Log(LogLevel.Info, "Added new partition archive : Type = {0} , Description = {1}", partition.ArchiveTypeEnum.Description, partition.Description);
            }
            else
            {
                Platform.Log(LogLevel.Info, "Failed to add new partition archive : Type = {0} , Description = {1}", partition.ArchiveTypeEnum.Description, partition.Description);
            }

            return(result);
        }
コード例 #7
0
ファイル: ArchiveTestForm.cs プロジェクト: yjsyyyjszf/CC13.2
        public string GetArchivePath(PartitionArchive archive)
        {
            var element = archive.ConfigurationXml.DocumentElement;

            if (element != null)
            {
                foreach (XmlElement node in element.ChildNodes)
                {
                    if (node.Name.Equals("RootDir"))
                    {
                        return(node.InnerText);
                    }
                }
            }

            return(null);
        }
        public void RunApplication(string[] args)
        {
            using (IUpdateContext updateContext = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                IPartitionArchiveEntityBroker  partitionBroker   = updateContext.GetBroker <IPartitionArchiveEntityBroker>();
                PartitionArchiveSelectCriteria partitionCriteria = new PartitionArchiveSelectCriteria();

                partitionCriteria.Enabled.EqualTo(true);
                partitionCriteria.ReadOnly.EqualTo(false);
                PartitionArchive activePartition = partitionBroker.FindOne(partitionCriteria);
                if (activePartition == null)
                {
                    Platform.Log(LogLevel.Error, "No active ArchivePartition were found.");
                    return;
                }

                partitionCriteria.ReadOnly.EqualTo(true);
                IList <ServerEntityKey> partitionKeys = new List <ServerEntityKey>();
                foreach (PartitionArchive partition in partitionBroker.Find(partitionCriteria))
                {
                    partitionKeys.Add(partition.Key);
                }

                IArchiveQueueEntityBroker  queueBroker   = updateContext.GetBroker <IArchiveQueueEntityBroker>();
                ArchiveQueueSelectCriteria queueCriteria = new ArchiveQueueSelectCriteria();
                queueCriteria.ArchiveQueueStatusEnum.In(new ArchiveQueueStatusEnum[] { ArchiveQueueStatusEnum.Failed, ArchiveQueueStatusEnum.Pending });
                queueCriteria.PartitionArchiveKey.In(partitionKeys);

                ArchiveQueueUpdateColumns queueColumns = new ArchiveQueueUpdateColumns()
                {
                    PartitionArchiveKey    = activePartition.Key,
                    ArchiveQueueStatusEnum = ArchiveQueueStatusEnum.Pending,
                    ProcessorId            = "",
                    ScheduledTime          = Platform.Time
                };

                if (queueBroker.Update(queueCriteria, queueColumns))
                {
                    updateContext.Commit();
                }
            }
        }
コード例 #9
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)));
        }
コード例 #10
0
        public void Insert(Guid Guid, Guid ServerPartitionGUID, short ArchiveTypeEnum, string Description, bool Enabled,
                           bool ReadOnlyX, int ArchiveDelayHours, string ConfigurationXml)
        {
            var item = new PartitionArchive();

            item.Guid = Guid;

            item.ServerPartitionGUID = ServerPartitionGUID;

            item.ArchiveTypeEnum = ArchiveTypeEnum;

            item.Description = Description;

            item.Enabled = Enabled;

            item.ReadOnlyX = ReadOnlyX;

            item.ArchiveDelayHours = ArchiveDelayHours;

            item.ConfigurationXml = ConfigurationXml;


            item.Save(UserName);
        }
コード例 #11
0
 public abstract void Start(PartitionArchive archive);
コード例 #12
0
 /// <summary>
 /// Delete the specified partition
 ///
 /// </summary>
 /// <param name="partition"></param>
 /// <returns></returns>
 public bool Delete(PartitionArchive partition)
 {
     return(_archiveAdapter.Delete(partition.GetKey()));
 }
コード例 #13
0
        public override void Start(PartitionArchive archive)
        {
            _partitionArchive = archive;

            throw new NotImplementedException();
        }
コード例 #14
0
 public PartitionArchiveService(IImageServerArchivePlugin archive, PartitionArchive partitionArchive, ServerPartition partition)
 {
     _archive          = archive;
     _partitionArchive = partitionArchive;
     _serverPartition  = partition;
 }
コード例 #15
0
        /// <summary>
        /// Check the currently configured archives and plugins to see if any have been disabled.
        /// </summary>
        private void CheckConfiguredArchives()
        {
            IList <ServerPartition> partitionList = LoadPartitions();

            lock (_syncLock)
            {
                IList <PartitionArchiveService> partitionsToDelete = new List <PartitionArchiveService>();

                foreach (PartitionArchiveService archiveService in _archiveServiceList)
                {
                    archiveService.PartitionArchive = PartitionArchive.Load(archiveService.PartitionArchive.GetKey());
                    if (!archiveService.PartitionArchive.Enabled)
                    {
                        Platform.Log(LogLevel.Info, "PartitionArchive {0} has been disabled, stopping plugin.", archiveService.PartitionArchive.Description);
                        archiveService.ArchivePlugin.Stop();
                        partitionsToDelete.Add(archiveService);
                    }
                    else
                    {
                        bool bFound = false;
                        foreach (ServerPartition serverPartition in partitionList)
                        {
                            if (serverPartition.GetKey().Equals(archiveService.ServerPartition.GetKey()) && serverPartition.Enabled)
                            {
                                bFound = true;
                                break;
                            }
                        }

                        if (!bFound)
                        {
                            Platform.Log(LogLevel.Info, "Partition was deleted or disabled, shutting down archive server {0}",
                                         archiveService.ServerPartition.Description);
                            archiveService.ArchivePlugin.Stop();
                            partitionsToDelete.Add(archiveService);
                        }
                    }
                }

                // Remove the services from our internal list.
                foreach (PartitionArchiveService archivePlugin in partitionsToDelete)
                {
                    _archiveServiceList.Remove(archivePlugin);
                }

                // Load the current extension list
                ImageServerArchiveExtensionPoint ep = new ImageServerArchiveExtensionPoint();
                ExtensionInfo[] extensionInfoList   = ep.ListExtensions();


                // Scan the current list of enabled partition archives to see if any
                // new archives have been added
                foreach (PartitionArchive partitionArchive in LoadEnabledPartitionArchives())
                {
                    ServerPartition newPartition = ServerPartition.Load(partitionArchive.ServerPartitionKey);

                    if (!newPartition.Enabled)
                    {
                        continue;
                    }

                    bool bFound = false;
                    foreach (PartitionArchiveService service in _archiveServiceList)
                    {
                        if (!partitionArchive.GetKey().Equals(service.PartitionArchive.GetKey()))
                        {
                            continue;
                        }

                        // Reset the context partition, incase its changed.
                        service.PartitionArchive = partitionArchive;

                        bFound = true;
                        break;
                    }

                    if (!bFound)
                    {
                        // No match, scan the current extensions for a matching extension
                        // to run the service
                        foreach (ExtensionInfo extensionInfo in extensionInfoList)
                        {
                            IImageServerArchivePlugin archive =
                                (IImageServerArchivePlugin)ep.CreateExtension(new ClassNameExtensionFilter(extensionInfo.FormalName));

                            if (archive.ArchiveType.Equals(partitionArchive.ArchiveTypeEnum))
                            {
                                PartitionArchiveService service = new PartitionArchiveService(archive, partitionArchive, newPartition);
                                Platform.Log(LogLevel.Info, "Detected PartitionArchive was added, starting archive {0}", partitionArchive.Description);
                                service.ArchivePlugin.Start(partitionArchive);
                                _archiveServiceList.Add(service);
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #16
0
ファイル: ArchiveTestForm.cs プロジェクト: yjsyyyjszf/CC13.2
 public DeleteAllArchiveQueueItemCommand(StudyStorage studyStorage, PartitionArchive archive)
     : base("Delete Archive Queue items")
 {
     _archive      = archive;
     _studyStorage = studyStorage;
 }