コード例 #1
0
        protected void LoadStudy()
        {
            if (String.IsNullOrEmpty(_studyInstanceUid))
            {
                return;
            }

            if (_partition == null)
            {
                return;
            }


            StudyAdaptor        studyAdaptor = new StudyAdaptor();
            StudySelectCriteria criteria     = new StudySelectCriteria();

            criteria.StudyInstanceUid.EqualTo(_studyInstanceUid);
            criteria.ServerPartitionKey.EqualTo(Partition.GetKey());
            Study study = studyAdaptor.GetFirst(HttpContextData.Current.ReadContext, criteria);

            if (study != null)
            {
                _study = StudySummaryAssembler.CreateStudySummary(HttpContextData.Current.ReadContext, study);
            }
            else
            {
                StudyNotFoundException exception = new StudyNotFoundException(_studyInstanceUid);
                ExceptionHandler.ThrowException(exception);
            }

            StudyDetailsPanel.Study = _study;
            StudyDetailsPanel.DataBind();
        }
コード例 #2
0
        /// <summary>
        /// Gets a list of <see cref="StudySummary"/> correspeonding to the studies currently selected
        /// </summary>
        /// <returns></returns>
        private void LoadSelectedStudies()
        {
            _selectedStudies = new List <StudySummary>();

            string[] selectedKeys = StudyListControl.SelectedDataKeys;
            if (selectedKeys != null)
            {
                foreach (var key in selectedKeys)
                {
                    // Note: the selected study may not be on the current the page.
                    // This can happens for example when some of the studies which appear before it are deleted from the system.
                    // For this reason, if the selected study does not appear on the current page, we need to load the studies from the database
                    StudySummary studySummary;
                    if (!TryFindStudySummaryOnCurrentPage(key, out studySummary))
                    {
                        var persistentContext = HttpContext.Current.GetSharedPersistentContext();
                        var study             = Study.Load(persistentContext, new ServerEntityKey("Study", key));
                        if (study != null)
                        {
                            studySummary = StudySummaryAssembler.CreateStudySummary(persistentContext, study);
                        }
                    }

                    if (studySummary != null)
                    {
                        _selectedStudies.Add(studySummary);
                    }
                }
            }
        }
コード例 #3
0
ファイル: StudyController.cs プロジェクト: hksonngan/Xian
        /// <summary>
        /// Delete a Study.
        /// </summary>
        public void DeleteStudy(ServerEntityKey studyKey, string reason)
        {
            StudySummary study = StudySummaryAssembler.CreateStudySummary(HttpContextData.Current.ReadContext, Study.Load(HttpContextData.Current.ReadContext, studyKey));

            if (study.IsReconcileRequired)
            {
                throw new ApplicationException(
                          String.Format("Deleting the study is not allowed at this time : there are items to be reconciled."));

                // NOTE: another check will occur when the delete is actually processed
            }


            using (IUpdateContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                LockStudyParameters lockParms = new LockStudyParameters
                {
                    QueueStudyStateEnum = QueueStudyStateEnum.WebDeleteScheduled,
                    StudyStorageKey     = study.TheStudyStorage.Key
                };
                ILockStudy broker = ctx.GetBroker <ILockStudy>();
                broker.Execute(lockParms);
                if (!lockParms.Successful)
                {
                    throw new ApplicationException(String.Format("Unable to lock the study : {0}", lockParms.FailureReason));
                }


                InsertWorkQueueParameters insertParms = new InsertWorkQueueParameters
                {
                    WorkQueueTypeEnum  = WorkQueueTypeEnum.WebDeleteStudy,
                    ServerPartitionKey = study.ThePartition.Key,
                    StudyStorageKey    = study.TheStudyStorage.Key,
                    ScheduledTime      = Platform.Time
                };

                WebDeleteStudyLevelQueueData extendedData = new WebDeleteStudyLevelQueueData
                {
                    Level    = DeletionLevel.Study,
                    Reason   = reason,
                    UserId   = ServerHelper.CurrentUserId,
                    UserName = ServerHelper.CurrentUserName
                };
                insertParms.WorkQueueData = XmlUtils.SerializeAsXmlDoc(extendedData);
                IInsertWorkQueue insertWorkQueue = ctx.GetBroker <IInsertWorkQueue>();

                if (insertWorkQueue.FindOne(insertParms) == null)
                {
                    throw new ApplicationException("DeleteStudy failed");
                }


                ctx.Commit();
            }
        }
コード例 #4
0
ファイル: StudyController.cs プロジェクト: yjsyyyjszf/CC13.2
        /// <summary>
        /// Delete a Study.
        /// </summary>
        public void DeleteStudy(ServerEntityKey studyKey, string reason)
        {
            StudySummary study = StudySummaryAssembler.CreateStudySummary(HttpContext.Current.GetSharedPersistentContext(), Study.Load(HttpContext.Current.GetSharedPersistentContext(), studyKey));

            if (study.IsReconcileRequired)
            {
                throw new ApplicationException(
                          String.Format("Deleting the study is not allowed at this time : there are items to be reconciled."));

                // NOTE: another check will occur when the delete is actually processed
            }

            using (IUpdateContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                StudyDeleteHelper.DeleteStudy(ctx, study.ThePartition, study.StudyInstanceUid, reason);
                ctx.Commit();
            }
        }
コード例 #5
0
        private static IList <StudySummary> LoadStudies(WebViewerInitParams initParams)
        {
            ValidateParameters(initParams);

            var controller       = new StudyController();
            var partitionAdapter = new ServerPartitionDataAdapter();
            StudySelectCriteria studyCriteria;
            var                 partitionCriteria = new ServerPartitionSelectCriteria();
            ServerPartition     partition         = null;
            IList <Study>       studies;
            List <StudySummary> totalStudies = new List <StudySummary>();

            if (!string.IsNullOrEmpty(initParams.AeTitle))
            {
                partitionCriteria.AeTitle.EqualTo(initParams.AeTitle);
                IList <ServerPartition> partitions = partitionAdapter.GetServerPartitions(partitionCriteria);
                if (partitions.Count == 1)
                {
                    partition = partitions[0];
                }
            }

            foreach (string patientId in initParams.PatientIds)
            {
                studyCriteria = new StudySelectCriteria();
                if (partition != null)
                {
                    studyCriteria.ServerPartitionKey.EqualTo(partition.Key);
                }
                SetStringCondition(studyCriteria.PatientId, patientId);
                studyCriteria.StudyDate.SortDesc(0);
                studies = controller.GetStudies(studyCriteria);

                foreach (Study study in studies)
                {
                    totalStudies.Add(StudySummaryAssembler.CreateStudySummary(HttpContextData.Current.ReadContext, study));
                }
            }

            foreach (string accession in initParams.AccessionNumbers)
            {
                studyCriteria = new StudySelectCriteria();
                if (partition != null)
                {
                    studyCriteria.ServerPartitionKey.EqualTo(partition.Key);
                }
                SetStringCondition(studyCriteria.AccessionNumber, accession);
                studyCriteria.StudyDate.SortDesc(0);
                studies = controller.GetStudies(studyCriteria);

                foreach (Study study in studies)
                {
                    totalStudies.Add(StudySummaryAssembler.CreateStudySummary(HttpContextData.Current.ReadContext, study));
                }
            }

            if (initParams.StudyInstanceUids.Count > 0)
            {
                studyCriteria = new StudySelectCriteria();
                if (partition != null)
                {
                    studyCriteria.ServerPartitionKey.EqualTo(partition.Key);
                }
                studyCriteria.StudyInstanceUid.In(initParams.StudyInstanceUids);
                studyCriteria.StudyDate.SortDesc(0);
                studies = controller.GetStudies(studyCriteria);

                foreach (Study study in studies)
                {
                    totalStudies.Add(StudySummaryAssembler.CreateStudySummary(HttpContextData.Current.ReadContext, study));
                }
            }

            totalStudies.Sort((a, b) => a.StudyDate.CompareTo(b.StudyDate) * -1);

            return(totalStudies);
        }