Esempio n. 1
0
        protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
        {
            string                         seriesUid   = _file.DataSet[DicomTags.SeriesInstanceUid].GetString(0, String.Empty);
            string                         sopUid      = _file.DataSet[DicomTags.SopInstanceUid].GetString(0, String.Empty);
            ImageSetDescriptor             imageSet    = new ImageSetDescriptor(_file.DataSet);
            ReconcileStudyQueueDescription queueDesc   = GetQueueEntryDescription(_storageLocation, _file);
            ReconcileStudyWorkQueueData    detailsData = new ReconcileStudyWorkQueueData
            {
                StoragePath = _reconcileImageStorage.GetFolderPath(),
                Details     = new ImageSetDetails(_file.DataSet)
            };

            detailsData.Details.InsertFile(_file);

            IInsertStudyIntegrityQueue          broker     = updateContext.GetBroker <IInsertStudyIntegrityQueue>();
            InsertStudyIntegrityQueueParameters parameters = new InsertStudyIntegrityQueueParameters
            {
                Description              = queueDesc.ToString(),
                StudyInstanceUid         = _storageLocation.StudyInstanceUid,
                ServerPartitionKey       = _storageLocation.ServerPartition.Key,
                StudyStorageKey          = _storageLocation.Key,
                StudyIntegrityReasonEnum = _reason,
                SeriesInstanceUid        = seriesUid,
                SeriesDescription        = sopUid,
                SopInstanceUid           =
                    _file.DataSet[DicomTags.SopInstanceUid].GetString(0,
                                                                      String
                                                                      .
                                                                      Empty),
                StudyData       = XmlUtils.SerializeAsXmlDoc(imageSet),
                Details         = XmlUtils.SerializeAsXmlDoc(detailsData),
                GroupID         = _uidGroup,
                UidRelativePath =
                    _reconcileImageStorage.GetSopRelativePath(
                        _file.DataSet[DicomTags.SopInstanceUid].ToString())
            };

            StudyIntegrityQueue item = broker.FindOne(parameters);

            if (item == null)
            {
                throw new ApplicationException("Unable to update reconcile queue");
            }

            _siqItem = item;
            if (!parameters.Inserted)
            {
                // Need to re-use the path that's already assigned for this entry
                ReconcileStudyWorkQueueData data = XmlUtils.Deserialize <ReconcileStudyWorkQueueData>(item.Details);
                data.Details.InsertFile(_file);

                XmlDocument updatedQueueDataXml = XmlUtils.SerializeAsXmlDoc(data);
                IStudyIntegrityQueueEntityBroker updateBroker = updateContext.GetBroker <IStudyIntegrityQueueEntityBroker>();
                StudyIntegrityQueueUpdateColumns columns      = new StudyIntegrityQueueUpdateColumns
                {
                    Details = updatedQueueDataXml
                };
                updateBroker.Update(item.GetKey(), columns);
            }
        }
Esempio n. 2
0
 private void LoadSIQEntries()
 {
     using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
     {
         IStudyIntegrityQueueEntityBroker broker = ctx.GetBroker <IStudyIntegrityQueueEntityBroker>();
         _siqEntries = new List <StudyIntegrityQueue>(broker.Find(new StudyIntegrityQueueSelectCriteria()));
     }
 }
        /// <summary>
        /// Finds all storage locations used for the study.
        /// </summary>
        protected void FindAllRelatedDirectories()
        {
            // Check the work queue for other entries
            IList <Model.WorkQueue> list;

            // NOTE: a local read context is used for lookup because we want to
            // release the lock on the rows asap.
            using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
            {
                IWorkQueueEntityBroker  broker   = ctx.GetBroker <IWorkQueueEntityBroker>();
                WorkQueueSelectCriteria criteria = new WorkQueueSelectCriteria();
                criteria.StudyStorageKey.EqualTo(WorkQueueItem.StudyStorageKey);
                list = broker.Find(criteria);
            }


            List <DirectoryInfo> dirs = new List <DirectoryInfo>();

            foreach (Model.WorkQueue item in list)
            {
                string path = GetWorkQueueSecondaryFolder(item);
                if (!string.IsNullOrEmpty(path))
                {
                    dirs.Add(new DirectoryInfo(path));
                }
            }

            // NOTE: Under normal operation, the SIQ entries should be
            // empty at this point because the Delete Study button is disabled otherwise.
            // This block of code is still needed just in case this DeleteStudy work queue entry
            // is inserted through different means.
            IList <StudyIntegrityQueue> siqList;

            using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
            {
                IStudyIntegrityQueueEntityBroker  broker   = ctx.GetBroker <IStudyIntegrityQueueEntityBroker>();
                StudyIntegrityQueueSelectCriteria criteria = new StudyIntegrityQueueSelectCriteria();
                criteria.StudyStorageKey.EqualTo(WorkQueueItem.StudyStorageKey);
                siqList = broker.Find(criteria);
            }

            foreach (StudyIntegrityQueue item in siqList)
            {
                string path = GetSIQItemStorageFolder(item);
                if (!string.IsNullOrEmpty(path))
                {
                    dirs.Add(new DirectoryInfo(path));
                }
            }


            _relatedDirectories = dirs;
        }
Esempio n. 4
0
        public int GetStudyIntegrityQueueCount(ServerEntityKey studyStorageKey)
        {
            Platform.CheckForNullReference(studyStorageKey, "storageKey");


            IStudyIntegrityQueueEntityBroker  integrityQueueBroker = HttpContext.Current.GetSharedPersistentContext().GetBroker <IStudyIntegrityQueueEntityBroker>();
            StudyIntegrityQueueSelectCriteria parms = new StudyIntegrityQueueSelectCriteria();

            parms.StudyStorageKey.EqualTo(studyStorageKey);

            return(integrityQueueBroker.Count(parms));
        }
Esempio n. 5
0
        public IList <StudyIntegrityQueue> GetStudyIntegrityQueueItems(ServerEntityKey studyStorageKey)
        {
            Platform.CheckForNullReference(studyStorageKey, "storageKey");


            IStudyIntegrityQueueEntityBroker  integrityQueueBroker = HttpContextData.Current.ReadContext.GetBroker <IStudyIntegrityQueueEntityBroker>();
            StudyIntegrityQueueSelectCriteria parms = new StudyIntegrityQueueSelectCriteria();

            parms.StudyStorageKey.EqualTo(studyStorageKey);

            return(integrityQueueBroker.Find(parms));
        }
Esempio n. 6
0
 /// <summary>
 /// Finds a list of <see cref="StudyIntegrityQueue"/> related to the specified <see cref="StudyStorage"/>.
 /// </summary>
 /// <param name="studyStorageKey"></param>
 /// <param name="filter">A delegate that will be used to filter the returned list. Pass in Null to get the entire list.</param>
 /// <returns>A list of  <see cref="StudyIntegrityQueue"/></returns>
 static public IList <StudyIntegrityQueue> FindSIQEntries(ServerEntityKey studyStorageKey, Predicate <StudyIntegrityQueue> filter)
 {
     using (ServerExecutionContext scope = new ServerExecutionContext())
     {
         IStudyIntegrityQueueEntityBroker  broker   = scope.PersistenceContext.GetBroker <IStudyIntegrityQueueEntityBroker>();
         StudyIntegrityQueueSelectCriteria criteria = new StudyIntegrityQueueSelectCriteria();
         criteria.StudyStorageKey.EqualTo(studyStorageKey);
         criteria.InsertTime.SortDesc(0);
         IList <StudyIntegrityQueue> list = broker.Find(criteria);
         if (filter != null)
         {
             CollectionUtils.Remove(list, filter);
         }
         return(list);
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Checks for the existinance of a SOP for a given Study in the <see cref="StudyIntegrityQueue"/>.
        /// </summary>
        /// <param name="studyStorageKey">The StudyStorage primary key</param>
        /// <param name="sopInstanceUid">The Sop Instance ot look for</param>
        /// <param name="seriesInstanceUid">The Series Instance Uid of the Sop</param>
        /// <returns>true if an entry exists, false if it doesn't</returns>
        static public bool StudyIntegrityUidExists(ServerEntityKey studyStorageKey, string seriesInstanceUid, string sopInstanceUid)
        {
            Platform.CheckForNullReference(studyStorageKey, "studyStorageKey");

            using (ServerExecutionContext scope = new ServerExecutionContext())
            {
                IStudyIntegrityQueueEntityBroker     broker            = scope.PersistenceContext.GetBroker <IStudyIntegrityQueueEntityBroker>();
                StudyIntegrityQueueUidSelectCriteria uidSelectCriteria = new StudyIntegrityQueueUidSelectCriteria();
                uidSelectCriteria.SeriesInstanceUid.EqualTo(seriesInstanceUid);
                uidSelectCriteria.SopInstanceUid.EqualTo(sopInstanceUid);
                StudyIntegrityQueueSelectCriteria selectCriteria = new StudyIntegrityQueueSelectCriteria();
                selectCriteria.StudyStorageKey.EqualTo(studyStorageKey);
                selectCriteria.StudyIntegrityQueueUidRelatedEntityCondition.Exists(uidSelectCriteria);

                return(broker.Count(selectCriteria) > 0);
            }
        }
Esempio n. 8
0
        private Study GetStudyAndQueues(StudyStorageLocation location, out int integrityQueueCount, out int workQueueCount)
        {
            using (IReadContext context = _store.OpenReadContext())
            {
                IStudyIntegrityQueueEntityBroker  integrityBroker   = context.GetBroker <IStudyIntegrityQueueEntityBroker>();
                StudyIntegrityQueueSelectCriteria integrityCriteria = new StudyIntegrityQueueSelectCriteria();
                integrityCriteria.StudyStorageKey.EqualTo(location.Key);
                integrityQueueCount = integrityBroker.Count(integrityCriteria);

                IWorkQueueEntityBroker  workBroker   = context.GetBroker <IWorkQueueEntityBroker>();
                WorkQueueSelectCriteria workCriteria = new WorkQueueSelectCriteria();
                workCriteria.StudyStorageKey.EqualTo(location.Key);
                workQueueCount = workBroker.Count(workCriteria);

                IStudyEntityBroker  procedure = context.GetBroker <IStudyEntityBroker>();
                StudySelectCriteria criteria  = new StudySelectCriteria();
                criteria.StudyStorageKey.EqualTo(location.Key);
                return(procedure.FindOne(criteria));
            }
        }
        /// <summary>
        /// Return snapshot of all related items in the Study Integrity Queue.
        /// </summary>
        /// <returns></returns>
        public IList <StudyIntegrityQueue> GetRelatedStudyIntegrityQueueItems()
        {
            lock (SyncRoot) // make this thread-safe
            {
                if (_integrityQueueItems == null)
                {
                    using (IReadContext ctx = _store.OpenReadContext())
                    {
                        IStudyIntegrityQueueEntityBroker integrityQueueBroker =
                            ctx.GetBroker <IStudyIntegrityQueueEntityBroker>();
                        StudyIntegrityQueueSelectCriteria parms = new StudyIntegrityQueueSelectCriteria();

                        parms.StudyStorageKey.EqualTo(GetKey());

                        _integrityQueueItems = integrityQueueBroker.Find(parms);
                    }
                }
            }
            return(_integrityQueueItems);
        }