Ejemplo n.º 1
0
        /// <summary>
        /// Inserts a WebDeleteStudy work queue entry that deletes specific SOP Instances within the study.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="location"></param>
        /// <param name="seriesInstanceUid"></param>
        /// <param name="sopInstanceUid"></param>
        /// <param name="reason"></param>
        /// <param name="externalRequest"></param>
        public static WorkQueue InsertDeleteInstanceRequest(IUpdateContext context, StudyStorageLocation location,
                                                            string seriesInstanceUid, string sopInstanceUid,
                                                            string reason, ExternalRequestQueue externalRequest = null)
        {
            var broker = context.GetBroker <IInsertWorkQueue>();

            DateTime now = Platform.Time;

            var criteria = new InsertWorkQueueParameters
            {
                WorkQueueTypeEnum  = WorkQueueTypeEnum.WebDeleteStudy,
                StudyStorageKey    = location.Key,
                ServerPartitionKey = location.ServerPartitionKey,
                ScheduledTime      = now,
                SeriesInstanceUid  = seriesInstanceUid,
                SopInstanceUid     = sopInstanceUid,
                WorkQueueData      = XmlUtils.SerializeAsXmlDoc(
                    new WebDeleteInstanceLevelQueueData
                {
                    Reason    = reason,
                    Timestamp = now,
                    UserId    = ServerHelper.CurrentUserId,
                    UserName  = ServerHelper.CurrentUserName
                }),
            };

            if (externalRequest != null)
            {
                criteria.ExternalRequestQueueKey = externalRequest.Key;
            }

            return(broker.FindOne(criteria));
        }
 /// <summary>
 /// Creates an instance of <see cref="SopInstanceProcessorContext"/>
 /// </summary>
 /// <param name="commandProcessor">The <see cref="ServerCommandProcessor"/> used in the context</param>
 /// <param name="studyLocation">The <see cref="StudyStorageLocation"/> of the study being processed</param>
 /// <param name="uidGroup">A String value respresenting the group of SOP instances which are being processed.</param>
 /// <param name="request">An external request that may have triggered this item.</param>
 public SopInstanceProcessorContext(ServerCommandProcessor commandProcessor, StudyStorageLocation studyLocation,
                                    string uidGroup, ExternalRequestQueue request = null)
 {
     _commandProcessor = commandProcessor;
     _studyLocation    = studyLocation;
     _group            = uidGroup;
     _request          = request;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates an instance of <see cref="SopInstanceImporterContext"/> to be used
 /// by <see cref="SopInstanceImporter"/>
 /// </summary>
 /// <param name="contextId">The ID assigned to the context. This will be used as the name of storage folder in case of duplicate.</param>
 /// <param name="sourceAe">Source AE title of the image(s) to be imported</param>
 /// <param name="partition">The <see cref="ServerPartition"/> which the image(s) will be imported to</param>
 /// <param name="request">An external request that triggered this operation.</param>
 public SopInstanceImporterContext(string contextId, string sourceAe, ServerPartition partition,
                                   ExternalRequestQueue request = null)
 {
     Platform.CheckForEmptyString(contextId, "contextID");
     Platform.CheckForNullReference(partition, "partition");
     _contextID = contextId;
     _sourceAE  = sourceAe;
     _partition = partition;
     _request   = request;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructs an instance of <see cref="ExternalRequestQueueSummary"/> based on a <see cref="ExternalRequestQueue"/> object.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        /// <remark>
        /// </remark>
        private ExternalRequestQueueSummary CreateExternalRequestQueueSummary(ExternalRequestQueue item)
        {
            var summary = new ExternalRequestQueueSummary
            {
                TheExternalRequestQueue = item,
                ThePartition            = Partition,
                Request = ImageServerSerializer.DeserializeExternalRequest(item.RequestXml)
            };

            return(summary);
        }
        public UpdateWorkQueueCommand(DicomMessageBase message, StudyStorageLocation location, bool duplicate, WorkQueueData data = null, WorkQueueUidData uidData = null, ExternalRequestQueue request = null)
            : base("Update/Insert a WorkQueue Entry")
        {
            Platform.CheckForNullReference(message, "Dicom Message object");
            Platform.CheckForNullReference(location, "Study Storage Location");

            _message         = message;
            _storageLocation = location;
            _duplicate       = duplicate;
            _data            = data;
            _request         = request;
            _uidData         = uidData;
        }
        public bool ResetExternalRequestQueueItem(ExternalRequestQueue item)
        {
            if (!item.ExternalRequestQueueStatusEnum.Equals(ExternalRequestQueueStatusEnum.Failed))
            {
                return(false);
            }
            var update = new ExternalRequestQueueUpdateColumns
            {
                ExternalRequestQueueStatusEnum = ExternalRequestQueueStatusEnum.Pending,
                Revision = item.Revision + 1
            };
            var criteria = new ExternalRequestQueueSelectCriteria();

            criteria.Key.EqualTo(item.Key);
            criteria.Revision.EqualTo(item.Revision);
            return(_adaptor.Update(criteria, update));
        }
Ejemplo n.º 7
0
        private IList <ExternalRequestQueue> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            resultCount = 0;

            if (maximumRows == 0)
            {
                return(new List <ExternalRequestQueue>());
            }

            if (SearchKeys != null)
            {
                IList <ExternalRequestQueue> archiveQueueList = new List <ExternalRequestQueue>();
                foreach (ServerEntityKey key in SearchKeys)
                {
                    archiveQueueList.Add(ExternalRequestQueue.Load(key));
                }

                resultCount = archiveQueueList.Count;

                return(archiveQueueList);
            }

            var criteria = new ExternalRequestQueueSelectCriteria();

            if (!string.IsNullOrEmpty(RequestType))
            {
                criteria.RequestType.EqualTo(RequestType);
            }

            if (StatusEnum != null)
            {
                criteria.ExternalRequestQueueStatusEnum.EqualTo(StatusEnum);
            }

            criteria.InsertTime.SortDesc(0);

            IList <ExternalRequestQueue> list = _searchController.FindExternalRequestQueue(criteria, startRowIndex,
                                                                                           maximumRows);

            resultCount = _searchController.Count(criteria);

            return(list);
        }
 public bool DeleteExternalRequestQueueItem(ExternalRequestQueue item)
 {
     return(_adaptor.Delete(item.Key));
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Inserts a WebDeleteStudy request for a specific Study
        /// </summary>
        /// <param name="updateContext">The database context to insert under.</param>
        /// <param name="location">The StudyStorageLocation of the study to delete.</param>
        /// <param name="requestDescription">A description of the reason for the delete.</param>
        /// <param name="externalRequest">An optional external request that triggered this deletion</param>
        /// <returns>The inserted WorkQueue entry</returns>
        public static WorkQueue InsertDeleteStudyRequest(IUpdateContext updateContext, StudyStorageLocation location, string requestDescription, ExternalRequestQueue externalRequest = null)
        {
            var extendedData = new WebDeleteStudyLevelQueueData
            {
                Level    = DeletionLevel.Study,
                Reason   = requestDescription,
                UserId   = ServerHelper.CurrentUserId,
                UserName = ServerHelper.CurrentUserName
            };

            var insertParms = new InsertWorkQueueParameters
            {
                WorkQueueTypeEnum  = WorkQueueTypeEnum.WebDeleteStudy,
                ServerPartitionKey = location.ServerPartitionKey,
                StudyStorageKey    = location.Key,
                ScheduledTime      = Platform.Time,
                WorkQueueData      = XmlUtils.SerializeAsXmlDoc(extendedData)
            };

            if (externalRequest != null)
            {
                insertParms.ExternalRequestQueueKey = externalRequest.Key;
            }

            var insertWorkQueue = updateContext.GetBroker <IInsertWorkQueue>();

            return(insertWorkQueue.FindOne(insertParms));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Inserts a move request to move one or more Sops in a study.
        /// </summary>
        /// <param name="context">The persistence context used for database connection.</param>
        /// <param name="partition">The <see cref="ServerPartition"/> where the study resides</param>
        /// <param name="studyInstanceUid">The Study Instance Uid of the study</param>
        /// <param name="deviceKey">The Key of the device to move the series to.</param>
        /// <param name="seriesInstanceUid">The Series Instance Uid of the series to be move.</param>
        /// <param name="sopInstanceUids"></param>
        /// <param name="externalRequest">Optional <see cref="ExternalRequestQueue"/> entry that triggered this move</param>
        /// <returns>A MoveSeries <see cref="WorkQueue"/> entry inserted into the system.</returns>
        /// <exception cref="InvalidStudyStateOperationException"></exception>
        public static IList <WorkQueue> MoveInstance(IUpdateContext context, ServerPartition partition, string studyInstanceUid, string seriesInstanceUid, ServerEntityKey deviceKey, List <string> sopInstanceUids, ExternalRequestQueue externalRequest = null)
        {
            // Find all location of the study in the system and insert series delete request
            IList <StudyStorageLocation> storageLocations = StudyStorageLocation.FindStorageLocations(partition.Key, studyInstanceUid);
            IList <WorkQueue>            entries          = new List <WorkQueue>();

            foreach (StudyStorageLocation location in storageLocations)
            {
                try
                {
                    // insert a move series request
                    WorkQueue request = InsertMoveInstanceRequest(context, location, seriesInstanceUid, sopInstanceUids, deviceKey, externalRequest);
                    Debug.Assert(request.WorkQueueTypeEnum.Equals(WorkQueueTypeEnum.WebMoveStudy));
                    entries.Add(request);
                }
                catch (Exception ex)
                {
                    Platform.Log(LogLevel.Error, ex, "Errors occurred when trying to insert sop level move request");
                    if (!ServerHelper.UnlockStudy(location.Key))
                    {
                        throw new ApplicationException("Unable to unlock the study");
                    }
                }
            }

            return(entries);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Inserts a MoveSopInstance work queue entry
        /// </summary>
        /// <param name="context"></param>
        /// <param name="location"></param>
        /// <param name="seriesInstanceUid"></param>
        /// <param name="sopInstanceUids"></param>
        /// <param name="deviceKey"></param>
        /// <param name="externalRequest"></param>
        /// <exception cref="ApplicationException">If the "DeleteSeries" Work Queue entry cannot be inserted.</exception>
        private static WorkQueue InsertMoveInstanceRequest(IUpdateContext context, StudyStorageLocation location, string seriesInstanceUid, IEnumerable <string> sopInstanceUids, ServerEntityKey deviceKey, ExternalRequestQueue externalRequest)
        {
            // Create a work queue entry and append the series instance uid into the WorkQueueUid table

            WorkQueue moveSopInstance = null;
            var       broker          = context.GetBroker <IInsertWorkQueue>();

            foreach (string sop in sopInstanceUids)
            {
                InsertWorkQueueParameters criteria = new MoveInstanceWorkQueueParameters(location, seriesInstanceUid, sop, deviceKey);
                if (externalRequest != null)
                {
                    criteria.ExternalRequestQueueKey = externalRequest.Key;
                }

                moveSopInstance = broker.FindOne(criteria);
                if (moveSopInstance == null)
                {
                    throw new ApplicationException(
                              String.Format("Unable to insert a Move Sop Instance request for study {0}", location.StudyInstanceUid));
                }
            }

            return(moveSopInstance);
        }