/// <summary> /// Inserts a move request to move one or more series 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="seriesInstanceUids">The Series Instance Uid of the series to be move.</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> MoveSeries(IUpdateContext context, ServerPartition partition, string studyInstanceUid, ServerEntityKey deviceKey, List<string> seriesInstanceUids, 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 = InsertMoveSeriesRequest(context, location, seriesInstanceUids, 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 move request"); if (!ServerHelper.UnlockStudy(location.Key)) throw new ApplicationException("Unable to unlock the study"); } } return entries; }
static public ExternalRequestQueue Load(IPersistenceContext read, ServerEntityKey key) { var broker = read.GetBroker <IExternalRequestQueueEntityBroker>(); ExternalRequestQueue theObject = broker.Load(key); return(theObject); }
/// <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; }
static public ExternalRequestQueue Insert(ExternalRequestQueue entity) { using (var update = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { ExternalRequestQueue newEntity = Insert(update, entity); update.Commit(); return(newEntity); } }
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); }
public UpdateWorkQueueCommand(DicomMessageBase message, StudyStorageLocation location, bool duplicate, WorkQueueData data=null, WorkQueueUidData uidData=null, ExternalRequestQueue request=null, WorkQueuePriorityEnum priority=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; _priority = priority; }
static public ExternalRequestQueue Insert(IUpdateContext update, ExternalRequestQueue entity) { var broker = update.GetBroker <IExternalRequestQueueEntityBroker>(); var updateColumns = new ExternalRequestQueueUpdateColumns(); updateColumns.RequestType = entity.RequestType; updateColumns.RequestXml = entity.RequestXml; updateColumns.InsertTime = entity.InsertTime; updateColumns.Revision = entity.Revision; updateColumns.DeletionTime = entity.DeletionTime; updateColumns.StateXml = entity.StateXml; updateColumns.OperationToken = entity.OperationToken; updateColumns.RequestId = entity.RequestId; updateColumns.ExternalRequestQueueStatusEnum = entity.ExternalRequestQueueStatusEnum; ExternalRequestQueue newEntity = broker.Insert(updateColumns); return(newEntity); }
/// <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); }
/// <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="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; }
public bool DeleteExternalRequestQueueItem(ExternalRequestQueue item) { return _adaptor.Delete(item.Key); }
static public ExternalRequestQueue Insert(IUpdateContext update, ExternalRequestQueue entity) { var broker = update.GetBroker<IExternalRequestQueueEntityBroker>(); var updateColumns = new ExternalRequestQueueUpdateColumns(); updateColumns.RequestType = entity.RequestType; updateColumns.RequestXml = entity.RequestXml; updateColumns.InsertTime = entity.InsertTime; updateColumns.Revision = entity.Revision; updateColumns.ScheduledTime = entity.ScheduledTime; updateColumns.DeletionTime = entity.DeletionTime; updateColumns.StateXml = entity.StateXml; updateColumns.OperationToken = entity.OperationToken; updateColumns.RequestId = entity.RequestId; updateColumns.ExternalRequestQueueStatusEnum = entity.ExternalRequestQueueStatusEnum; ExternalRequestQueue newEntity = broker.Insert(updateColumns); return newEntity; }
static public ExternalRequestQueue Insert(ExternalRequestQueue entity) { using (var update = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { ExternalRequestQueue newEntity = Insert(update, entity); update.Commit(); return newEntity; } }
/// <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; }
/// <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; }