private void Initialize()
        {
            _study          = Study.Find(ServerExecutionContext.Current.ReadContext, _studyLocation.StudyInstanceUid, _partition);
            _curPatient     = _study.LoadPatient(ServerExecutionContext.Current.ReadContext);
            _oldPatientInfo = new PatientInfo
            {
                Name              = _curPatient.PatientsName,
                PatientId         = _curPatient.PatientId,
                IssuerOfPatientId = _curPatient.IssuerOfPatientId
            };

            _seriesInstanceUid = _file.DataSet[DicomTags.SeriesInstanceUid].ToString();
            var broker = ServerExecutionContext.Current.ReadContext.GetBroker <ISeriesEntityBroker>();
            var select = new SeriesSelectCriteria();

            select.SeriesInstanceUid.EqualTo(_seriesInstanceUid);
            select.ServerPartitionKey.EqualTo(_partition.Key);
            _curSeries = broker.FindOne(select);

            _newPatientInfo = new PatientInfo(_oldPatientInfo);
            _file.DataSet.LoadDicomFields(_newPatientInfo);

            _newPatient = FindPatient(_newPatientInfo, ServerExecutionContext.Current.ReadContext);
            _patientInfoIsNotChanged = _newPatientInfo.Equals(_oldPatientInfo);
        }
        /// <summary>
        /// Validates the state of the study.
        /// </summary>
        /// <param name="context">Name of the application</param>
        /// <param name="studyStorage">The study to validate</param>
        /// <param name="modes">Specifying what validation to execute</param>
        public void ValidateStudyState(String context, StudyStorageLocation studyStorage, StudyIntegrityValidationModes modes)
        {
            Platform.CheckForNullReference(studyStorage, "studyStorage");
            if (modes == StudyIntegrityValidationModes.None)
            {
                return;
            }

            using (var scope = new ServerExecutionContext())
            {
                // Force a re-load, the study may have changed if a delete happened.
                Study study = Study.Find(scope.PersistenceContext, studyStorage.Key);

                if (study != null)
                {
                    StudyXml studyXml = studyStorage.LoadStudyXml();

                    if (modes == StudyIntegrityValidationModes.Default ||
                        (modes & StudyIntegrityValidationModes.InstanceCount) == StudyIntegrityValidationModes.InstanceCount)
                    {
                        if (studyXml != null && studyXml.NumberOfStudyRelatedInstances != study.NumberOfStudyRelatedInstances)
                        {
                            var validationStudyInfo = new ValidationStudyInfo(study, studyStorage.ServerPartition);

                            throw new StudyIntegrityValidationFailure(
                                      ValidationErrors.InconsistentObjectCount, validationStudyInfo,
                                      String.Format("Number of instances in database and xml do not match: {0} vs {1}.",
                                                    study.NumberOfStudyRelatedInstances,
                                                    studyXml.NumberOfStudyRelatedInstances
                                                    ));
                        }
                    }
                }
            }
        }
Beispiel #3
0
        protected override void OnExecute(ServerCommandProcessor theProcessor, IUpdateContext updateContext)
        {
            Study study = _location.Study ?? Study.Find(updateContext, _location.Key);

            if (study.StudySizeInKB != _studySizeInKB)
            {
                IStudyEntityBroker broker     = updateContext.GetBroker <IStudyEntityBroker>();
                StudyUpdateColumns parameters = new StudyUpdateColumns()
                {
                    StudySizeInKB = _studySizeInKB
                };
                if (!broker.Update(study.Key, parameters))
                {
                    throw new ApplicationException("Unable to update study size in the database");
                }
            }
        }
Beispiel #4
0
        protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
        {
            if (_rebuildCommand != null)
            {
                _studySizeInKB = _rebuildCommand.StudyXml.GetStudySize() / KB;
            }

            Study study = _location.Study ?? Study.Find(updateContext, _location.Key);

            if (study != null && study.StudySizeInKB != _studySizeInKB)
            {
                var broker     = updateContext.GetBroker <IStudyEntityBroker>();
                var parameters = new StudyUpdateColumns
                {
                    StudySizeInKB = _studySizeInKB
                };
                if (!broker.Update(study.Key, parameters))
                {
                    throw new ApplicationException("Unable to update study size in the database");
                }
            }
        }