Пример #1
0
        private GetStudyEntriesResult GetStudyEntries(GetStudyEntriesRequest request)
        {
            using (var context = new DataAccessContext())
            {
                var entries = context.GetStudyStoreQuery().GetStudyEntries(request.Criteria);

                var criteria = (request.Criteria ?? new StudyEntry()).Study ?? new StudyRootStudyIdentifier();
                AuditHelper.LogQueryIssued(null, null, EventSource.CurrentUser, EventResult.Success,
                    SopClass.StudyRootQueryRetrieveInformationModelFindUid, criteria.ToDicomAttributeCollection());
                
                return new GetStudyEntriesResult { StudyEntries = entries };
            }
        }
Пример #2
0
        public GetStudyEntriesResult GetStudyEntries(GetStudyEntriesRequest request)
        {
            Platform.CheckForNullReference(request, "request");
            if (request.Criteria == null)
                request.Criteria = new StudyEntry();

            if (request.Criteria.Study == null)
                request.Criteria.Study = new StudyRootStudyIdentifier();

            return new GetStudyEntriesResult
                       {
                           StudyEntries = _studyRootQuery.StudyQuery(request.Criteria.Study)
                            .Select(identifier => new StudyEntry { Study = identifier }).ToList()
                       };
        }
Пример #3
0
 public abstract GetStudyEntriesResult GetStudyEntries(GetStudyEntriesRequest request);
Пример #4
0
        /// <summary>
        /// Figure out which studies have been deleted and/or updated.
        /// </summary>
        private void ProcessChangedStudiesAsync(out DateTime? queryStartTime, out List<string> deletedStudyUids, out List<StudyEntry> updatedStudies)
        {
            deletedStudyUids = new List<string>();
            updatedStudies = new List<StudyEntry>();
            queryStartTime = null;
            DateTime now = DateTime.Now;

            var fiveSeconds = TimeSpan.FromSeconds(5);
            var rapidChangeInterval = TimeSpan.FromMilliseconds(300);

            lock (_syncLock)
            {
                if (_queryingForUpdates)
                    return; //Already querying.

                //Nothing to query for? Return.
                if (_setChangedStudies.Count == 0 || !_lastStudyChangeTime.HasValue)
                    return;

                bool studiesChanging = now - _lastStudyChangeTime.Value < rapidChangeInterval;
                if (studiesChanging)
                {
                    //Many DIFFERENT studies are changing in very rapid succession. Delay until it settles down, which usually isn't long.
                    Platform.Log(LogLevel.Debug, "Studies are still actively changing - delaying update.");
                    return;
                }
                
                if (!_hastenUpdateQuery)
                {
                    bool updatedRecently = _lastUpdateQueryEndTime.HasValue && now - _lastUpdateQueryEndTime < fiveSeconds;
                    if (updatedRecently)
                    {
                        //We just finished an update query less than 5 seconds ago.
                        Platform.Log(LogLevel.Debug, "Studies were updated within the last 5 seconds - delaying update.");
                        return;
                    }
                }

                //Reset this before the immediate query.
                _hastenUpdateQuery = false;

                //Add everything to the deleted list.
                deletedStudyUids.AddRange(_setChangedStudies.Keys);
                _setChangedStudies.Clear();

                //We are officially querying for updates.
                _queryingForUpdates = true;
            }

            queryStartTime = now;
            string studyUids = DicomStringHelper.GetDicomStringArray(deletedStudyUids);

            try
            {
                var clock = new CodeClock();
                clock.Start();
             
                var criteria = new StudyRootStudyIdentifier { StudyInstanceUid = studyUids };
                var request = new GetStudyEntriesRequest { Criteria = new StudyEntry { Study = criteria } };
                
                IList<StudyEntry> entries = null;
                
                //We're doing it this way here because it's local only.
                Platform.GetService<IStudyStoreQuery>(s => entries = s.GetStudyEntries(request).StudyEntries);

                foreach (var entry in entries)
                {
                    //If we got a result back, then it's not deleted.
                    deletedStudyUids.Remove(entry.Study.StudyInstanceUid);
                    updatedStudies.Add(entry);
                }

                clock.Stop();
                Platform.Log(LogLevel.Debug, "Study update query took {0}.", clock);
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e);
            }
            finally
            {
                lock (_syncLock)
                {
                    //Finished querying for updates.
                    _queryingForUpdates = false;
                    _lastUpdateQueryEndTime = now;
                }
            }
        }
Пример #5
0
 GetStudyEntriesResult IStudyStoreQuery.GetStudyEntries(GetStudyEntriesRequest request)
 {
     return ServiceProxyHelper.Call(GetStudyEntries, request);
 }
 public GetStudyEntriesResult GetStudyEntries(GetStudyEntriesRequest request)
 {
     return new GetStudyEntriesResult {StudyEntries = StudyEntries};
 }