示例#1
0
        protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
        {
            // Update StudyStatusEnum in the StudyStorageTable
            IStudyStorageEntityBroker studyStorageUpdate        = updateContext.GetBroker <IStudyStorageEntityBroker>();
            StudyStorageUpdateColumns studyStorageUpdateColumns = new StudyStorageUpdateColumns();

            studyStorageUpdateColumns.StudyStatusEnum = _newStatus;
            studyStorageUpdate.Update(_location.Key, studyStorageUpdateColumns);

            // Update ServerTransferSyntaxGUID in FilesystemStudyStorage
            IFilesystemStudyStorageEntityBroker filesystemUpdate        = updateContext.GetBroker <IFilesystemStudyStorageEntityBroker>();
            FilesystemStudyStorageUpdateColumns filesystemUpdateColumns = new FilesystemStudyStorageUpdateColumns();

            filesystemUpdateColumns.ServerTransferSyntaxKey = _newSyntax.Key;
            filesystemUpdate.Update(_location.FilesystemStudyStorageKey, filesystemUpdateColumns);
        }
示例#2
0
        static public StudyStorage Insert(IUpdateContext update, StudyStorage entity)
        {
            var broker        = update.GetBroker <IStudyStorageEntityBroker>();
            var updateColumns = new StudyStorageUpdateColumns();

            updateColumns.ServerPartitionKey  = entity.ServerPartitionKey;
            updateColumns.StudyInstanceUid    = entity.StudyInstanceUid;
            updateColumns.InsertTime          = entity.InsertTime;
            updateColumns.LastAccessedTime    = entity.LastAccessedTime;
            updateColumns.WriteLock           = entity.WriteLock;
            updateColumns.ReadLock            = entity.ReadLock;
            updateColumns.StudyStatusEnum     = entity.StudyStatusEnum;
            updateColumns.QueueStudyStateEnum = entity.QueueStudyStateEnum;
            StudyStorage newEntity = broker.Insert(updateColumns);

            return(newEntity);
        }
        protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
        {
            // Check if the File is the same syntax as the
            TransferSyntax fileSyntax = _file.TransferSyntax;
            TransferSyntax dbSyntax   = TransferSyntax.GetTransferSyntax(_location.TransferSyntaxUid);

            // Check if the syntaxes match the location
            if ((!fileSyntax.Encapsulated && !dbSyntax.Encapsulated) ||
                (fileSyntax.LosslessCompressed && dbSyntax.LosslessCompressed) ||
                (fileSyntax.LossyCompressed && dbSyntax.LossyCompressed))
            {
                // no changes necessary, just return;
                return;
            }

            // Select the Server Transfer Syntax
            var syntaxCriteria = new ServerTransferSyntaxSelectCriteria();
            var syntaxBroker   = updateContext.GetBroker <IServerTransferSyntaxEntityBroker>();

            syntaxCriteria.Uid.EqualTo(fileSyntax.UidString);

            ServerTransferSyntax serverSyntax = syntaxBroker.FindOne(syntaxCriteria);

            if (serverSyntax == null)
            {
                Platform.Log(LogLevel.Error, "Unable to load ServerTransferSyntax for {0}.  Unable to update study status.", fileSyntax.Name);
                return;
            }

            // Get the FilesystemStudyStorage update broker ready
            var filesystemStudyStorageEntityBroker = updateContext.GetBroker <IFilesystemStudyStorageEntityBroker>();
            var filesystemStorageUpdate            = new FilesystemStudyStorageUpdateColumns();
            var filesystemStorageCritiera          = new FilesystemStudyStorageSelectCriteria();

            filesystemStorageUpdate.ServerTransferSyntaxKey = serverSyntax.Key;
            filesystemStorageCritiera.StudyStorageKey.EqualTo(_location.Key);

            // Get the StudyStorage update broker ready
            var studyStorageBroker =
                updateContext.GetBroker <IStudyStorageEntityBroker>();
            var             studyStorageUpdate = new StudyStorageUpdateColumns();
            StudyStatusEnum statusEnum         = _location.StudyStatusEnum;

            if (fileSyntax.LossyCompressed)
            {
                studyStorageUpdate.StudyStatusEnum = statusEnum = StudyStatusEnum.OnlineLossy;
            }
            else if (fileSyntax.LosslessCompressed)
            {
                studyStorageUpdate.StudyStatusEnum = statusEnum = StudyStatusEnum.OnlineLossless;
            }

            studyStorageUpdate.LastAccessedTime = Platform.Time;

            if (!filesystemStudyStorageEntityBroker.Update(filesystemStorageCritiera, filesystemStorageUpdate))
            {
                Platform.Log(LogLevel.Error, "Unable to update FilesystemQueue row: Study {0}, Server Entity {1}",
                             _location.StudyInstanceUid, _location.ServerPartitionKey);
            }
            else if (!studyStorageBroker.Update(_location.GetKey(), studyStorageUpdate))
            {
                Platform.Log(LogLevel.Error, "Unable to update StudyStorage row: Study {0}, Server Entity {1}",
                             _location.StudyInstanceUid, _location.ServerPartitionKey);
            }
            else
            {
                // Update the location, so the next time we come in here, we don't try and update the database
                // for another sop in the study.
                _location.StudyStatusEnum         = statusEnum;
                _location.TransferSyntaxUid       = fileSyntax.UidString;
                _location.ServerTransferSyntaxKey = serverSyntax.Key;
            }
        }