Пример #1
0
        /// <summary>
        /// Process the <see cref="ServiceLock"/> item.
        /// </summary>
        /// <param name="item"></param>
        protected override void OnProcess(Model.ServiceLock item)
        {
            PersistentStoreRegistry.GetDefaultStore();

            using (ServerExecutionContext context = new ServerExecutionContext())
            {
                IServerPartitionEntityBroker  broker   = context.ReadContext.GetBroker <IServerPartitionEntityBroker>();
                ServerPartitionSelectCriteria criteria = new ServerPartitionSelectCriteria();
                criteria.AeTitle.SortAsc(0);

                _partitions = broker.Find(criteria);
            }

            ServerFilesystemInfo info = FilesystemMonitor.Instance.GetFilesystemInfo(item.FilesystemKey);

            Platform.Log(LogLevel.Info, "Starting rebuilding of Study XML files for filesystem: {0}", info.Filesystem.Description);

            TraverseFilesystemStudies(info.Filesystem);

            item.ScheduledTime = item.ScheduledTime.AddDays(1);

            if (CancelPending)
            {
                Platform.Log(LogLevel.Info,
                             "FilesystemRebuildXml of {0} has been canceled, rescheduling.  Note that the entire Filesystem will be rebuilt again.",
                             info.Filesystem.Description);
                UnlockServiceLock(item, true, Platform.Time.AddMinutes(1));
            }
            else
            {
                UnlockServiceLock(item, false, Platform.Time.AddDays(1));
            }

            Platform.Log(LogLevel.Info, "Completed rebuilding of the Study XML files for filesystem: {0}", info.Filesystem.Description);
        }
        /// <summary>
        /// Load the list of currently configured <see cref="ServerPartition"/> instances.
        /// </summary>
        /// <returns>The partition list.</returns>
        private static IList <ServerPartition> LoadPartitions()
        {
            //Get partitions
            IPersistentStore store = PersistentStoreRegistry.GetDefaultStore();

            using (IReadContext read = store.OpenReadContext())
            {
                IServerPartitionEntityBroker  broker   = read.GetBroker <IServerPartitionEntityBroker>();
                ServerPartitionSelectCriteria criteria = new ServerPartitionSelectCriteria();
                return(broker.Find(criteria));
            }
        }
Пример #3
0
        public ImageServerData()
        {
            using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
            {
                TotalStudiesCount = 0;

                IServerPartitionEntityBroker partitionBroker = context.GetBroker <IServerPartitionEntityBroker>();
                var partitions = partitionBroker.Find(new ServerPartitionSelectCriteria());
                foreach (ServerPartition partition in partitions)
                {
                    TotalStudiesCount += partition.StudyCount;
                }

                IDeviceEntityBroker  deviceBroker = context.GetBroker <IDeviceEntityBroker>();
                DeviceSelectCriteria criteria     = new DeviceSelectCriteria();
                criteria.Enabled.EqualTo(true);
                ActiveDeviceCount += deviceBroker.Count(criteria);
            }
        }
Пример #4
0
        /// <summary>
        /// Internal method for loading partition information fromt he database.
        /// </summary>
        private void LoadPartitions()
        {
            bool changed = false;

            lock (_partitionsLock)
            {
                try
                {
                    Dictionary <string, ServerPartition> templist = new Dictionary <string, ServerPartition>();
                    IPersistentStore store = PersistentStoreRegistry.GetDefaultStore();
                    using (IReadContext ctx = store.OpenReadContext())
                    {
                        IServerPartitionEntityBroker  broker   = ctx.GetBroker <IServerPartitionEntityBroker>();
                        ServerPartitionSelectCriteria criteria = new ServerPartitionSelectCriteria();
                        IList <ServerPartition>       list     = broker.Find(criteria);
                        foreach (ServerPartition partition in list)
                        {
                            if (IsChanged(partition))
                            {
                                changed = true;
                            }

                            templist.Add(partition.AeTitle, partition);
                        }
                    }

                    _partitions = templist;

                    if (changed && _changedListener != null)
                    {
                        EventsHelper.Fire(_changedListener, this, new ServerPartitionChangedEventArgs(this));
                    }
                }
                catch (Exception ex)
                {
                    Platform.Log(LogLevel.Error, ex,
                                 "Unexpected exception when loading partitions, possible database error.  Operation will be retried later");
                }
            }// lock
        }