/// <summary> /// Check if a filesystem is online. /// </summary> /// <param name="filesystemKey">The filesystem primary Key</param> /// <param name="reason">The reason the filesystem isn't online</param> /// <returns></returns> public bool CheckFilesystemOnline(ServerEntityKey filesystemKey, out string reason) { reason = string.Empty; lock (SyncLock) { ServerFilesystemInfo info; if (!_filesystemList.TryGetValue(filesystemKey, out info)) { LoadFilesystems(); _filesystemList.TryGetValue(filesystemKey, out info); } if (info != null) { if (!info.Online) { reason = "The filesystem is offline."; } return(info.Online); } } return(false); }
public WorkQueueUid( ServerEntityKey _workQueueKey_ , Boolean _failed_ , Boolean _duplicate_ , Int16 _failureCount_ , String _groupID_ , String _relativePath_ , String _extension_ , String _seriesInstanceUid_ , String _sopInstanceUid_ ) : base("WorkQueueUid") { WorkQueueKey = _workQueueKey_; Failed = _failed_; Duplicate = _duplicate_; FailureCount = _failureCount_; GroupID = _groupID_; RelativePath = _relativePath_; Extension = _extension_; SeriesInstanceUid = _seriesInstanceUid_; SopInstanceUid = _sopInstanceUid_; }
public WorkQueue( ServerEntityKey _serverPartitionKey_ ,ServerEntityKey _studyStorageKey_ ,WorkQueueTypeEnum _workQueueTypeEnum_ ,WorkQueueStatusEnum _workQueueStatusEnum_ ,WorkQueuePriorityEnum _workQueuePriorityEnum_ ,Int32 _failureCount_ ,DateTime _scheduledTime_ ,DateTime _insertTime_ ,DateTime? _lastUpdatedTime_ ,String _failureDescription_ ,XmlDocument _data_ ,ServerEntityKey _externalRequestQueueKey_ ,String _processorID_ ,String _groupID_ ,DateTime? _expirationTime_ ,ServerEntityKey _deviceKey_ ,ServerEntityKey _studyHistoryKey_ ) : base("WorkQueue") { ServerPartitionKey = _serverPartitionKey_; StudyStorageKey = _studyStorageKey_; WorkQueueTypeEnum = _workQueueTypeEnum_; WorkQueueStatusEnum = _workQueueStatusEnum_; WorkQueuePriorityEnum = _workQueuePriorityEnum_; FailureCount = _failureCount_; ScheduledTime = _scheduledTime_; InsertTime = _insertTime_; LastUpdatedTime = _lastUpdatedTime_; FailureDescription = _failureDescription_; Data = _data_; ExternalRequestQueueKey = _externalRequestQueueKey_; ProcessorID = _processorID_; GroupID = _groupID_; ExpirationTime = _expirationTime_; DeviceKey = _deviceKey_; StudyHistoryKey = _studyHistoryKey_; }
public bool Delete(ServerEntityKey key) { try { using (IUpdateContext context = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush)) { TIEntity update = context.GetBroker <TIEntity>(); if (!update.Delete(key)) { return(false); } context.Commit(); } return(true); } catch (Exception e) { Platform.Log(LogLevel.Error, e, "Unexpected exception updating {0}", typeof(TServerEntity)); throw; } }
public bool DeleteOrderItem(ServerEntityKey partitionKey, ServerEntityKey orderKey) { using (IUpdateContext updateContext = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { // Disconnect studies from order var studyBroker = updateContext.GetBroker <IStudyEntityBroker>(); var criteria = new StudySelectCriteria(); criteria.OrderKey.EqualTo(orderKey); criteria.ServerPartitionKey.EqualTo(partitionKey); var updateColumns = new StudyUpdateColumns { OrderKey = null }; studyBroker.Update(criteria, updateColumns); bool retValue = _adaptor.Delete(updateContext, orderKey); updateContext.Commit(); return(retValue); } }
public Series( ServerEntityKey _serverPartitionKey_ , ServerEntityKey _studyKey_ , String _seriesInstanceUid_ , String _modality_ , Int32 _numberOfSeriesRelatedInstances_ , String _performedProcedureStepStartDate_ , String _performedProcedureStepStartTime_ , String _sourceApplicationEntityTitle_ , String _seriesNumber_ , String _seriesDescription_ ) : base("Series") { ServerPartitionKey = _serverPartitionKey_; StudyKey = _studyKey_; SeriesInstanceUid = _seriesInstanceUid_; Modality = _modality_; NumberOfSeriesRelatedInstances = _numberOfSeriesRelatedInstances_; PerformedProcedureStepStartDate = _performedProcedureStepStartDate_; PerformedProcedureStepStartTime = _performedProcedureStepStartTime_; SourceApplicationEntityTitle = _sourceApplicationEntityTitle_; SeriesNumber = _seriesNumber_; SeriesDescription = _seriesDescription_; }
public Device( Boolean _dhcp_ , Boolean _enabled_ , Boolean _allowStorage_ , Boolean _acceptKOPR_ , Boolean _allowRetrieve_ , Boolean _allowQuery_ , Boolean _allowAutoRoute_ , Int16 _throttleMaxConnections_ , DateTime _lastAccessedTime_ , DeviceTypeEnum _deviceTypeEnum_ , ServerEntityKey _serverPartitionKey_ , String _aeTitle_ , Int32 _port_ , String _description_ , String _ipAddress_ , String _DefaultSCS_ ) : base("Device") { Dhcp = _dhcp_; Enabled = _enabled_; AllowStorage = _allowStorage_; AcceptKOPR = _acceptKOPR_; AllowRetrieve = _allowRetrieve_; AllowQuery = _allowQuery_; AllowAutoRoute = _allowAutoRoute_; ThrottleMaxConnections = _throttleMaxConnections_; LastAccessedTime = _lastAccessedTime_; DeviceTypeEnum = _deviceTypeEnum_; ServerPartitionKey = _serverPartitionKey_; AeTitle = _aeTitle_; Port = _port_; Description = _description_; IpAddress = _ipAddress_; DefaultSCS = _DefaultSCS_; }
public bool DeleteAlertItem(ServerEntityKey key) { return(_adaptor.Delete(key)); }
public void Delete(ServerEntityKey recordKey) { DeleteStudyRecordAdaptor adaptor = new DeleteStudyRecordAdaptor(); adaptor.Delete(recordKey); }
public DeleteFilesystemQueueCommand(ServerEntityKey storageLocationKey, ServerRuleApplyTimeEnum applyTime) : base("Delete FilesystemQueue") { _storageLocationKey = storageLocationKey; _applyTime = applyTime; }
/// <summary> /// Unlock a study for deletion. /// </summary> /// <param name="studyStorageKey"></param> /// <returns></returns> public static bool ReleaseDeletionLock(ServerEntityKey studyStorageKey) { return(ServerHelper.UnlockStudy(studyStorageKey)); }
/// <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> /// <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) { // 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); 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); }
/// <summary> /// Inserts a MoveStudy work queue entry /// </summary> /// <param name="context"></param> /// <param name="location"></param> /// <param name="seriesInstanceUids"></param> /// <param name="deviceKey"></param> /// <exception cref="ApplicationException">If the "DeleteSeries" Work Queue entry cannot be inserted.</exception> private static WorkQueue InsertMoveSeriesRequest(IUpdateContext context, StudyStorageLocation location, IEnumerable <string> seriesInstanceUids, ServerEntityKey deviceKey) { // Create a work queue entry and append the series instance uid into the WorkQueueUid table WorkQueue moveSeriesEntry = null; var broker = context.GetBroker <IInsertWorkQueue>(); foreach (string series in seriesInstanceUids) { InsertWorkQueueParameters criteria = new MoveSeriesWorkQueueParameters(location, series, deviceKey); moveSeriesEntry = broker.FindOne(criteria); if (moveSeriesEntry == null) { throw new ApplicationException( String.Format("Unable to insert a Move Series request for study {0}", location.StudyInstanceUid)); } } return(moveSeriesEntry); }
public bool Delete(IUpdateContext context, ServerEntityKey key) { TIEntity update = context.GetBroker <TIEntity>(); return(update.Delete(key)); }
static public ServerSopClass Load(IPersistenceContext read, ServerEntityKey key) { var broker = read.GetBroker<IServerSopClassEntityBroker>(); ServerSopClass theObject = broker.Load(key); return theObject; }
public Filesystem LoadFileSystem(ServerEntityKey key) { return(Filesystem.Load(key)); }
/// <summary> /// Constructor. /// </summary> /// <remarks> /// A rules engine will only load rules that apply at a specific time. The /// apply time is specified by the <paramref name="applyTime"/> parameter. /// </remarks> /// <param name="applyTime">An enumerated value as to when the rules shall apply.</param> /// <param name="serverPartitionKey">The Server Partition the rules engine applies to.</param> public ServerRulesEngine(ServerRuleApplyTimeEnum applyTime, ServerEntityKey serverPartitionKey) { _applyTime = applyTime; _serverPartitionKey = serverPartitionKey; Statistics = new RulesEngineStatistics(applyTime.Lookup, applyTime.LongDescription); }
/// <summary> /// Load from the database the configured transfer syntaxes /// </summary> /// <param name="read">a Read context</param> /// <param name="partitionKey">The partition to retrieve the transfer syntaxes for</param> /// <param name="encapsulated">true if searching for encapsulated syntaxes only</param> /// <returns>The list of syntaxes</returns> protected static IList <PartitionTransferSyntax> LoadTransferSyntaxes(IReadContext read, ServerEntityKey partitionKey, bool encapsulated) { var broker = read.GetBroker <IQueryServerPartitionTransferSyntaxes>(); var criteria = new PartitionTransferSyntaxQueryParameters { ServerPartitionKey = partitionKey }; IList <PartitionTransferSyntax> list = broker.Find(criteria); var returnList = new List <PartitionTransferSyntax>(); foreach (PartitionTransferSyntax syntax in list) { if (!syntax.Enabled) { continue; } TransferSyntax dicomSyntax = TransferSyntax.GetTransferSyntax(syntax.Uid); if (dicomSyntax.Encapsulated == encapsulated) { returnList.Add(syntax); } } return(returnList); }
/// <summary> /// Inserts work queue entry to process the duplicates. /// </summary> /// <param name="entryKey"><see cref="ServerEntityKey"/> of the <see cref="StudyIntegrityQueue"/> entry that has <see cref="StudyIntegrityReasonEnum"/> equal to <see cref="StudyIntegrityReasonEnum.Duplicate"/> </param> /// <param name="action"></param> public void Process(ServerEntityKey entryKey, ProcessDuplicateAction action) { DuplicateSopReceivedQueue entry = DuplicateSopReceivedQueue.Load(HttpContextData.Current.ReadContext, entryKey); Platform.CheckTrue(entry.StudyIntegrityReasonEnum == StudyIntegrityReasonEnum.Duplicate, "Invalid type of entry"); IList <StudyIntegrityQueueUid> uids = LoadDuplicateSopUid(entry); using (IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { ProcessDuplicateQueueEntryQueueData data = new ProcessDuplicateQueueEntryQueueData { Action = action, DuplicateSopFolder = entry.GetFolderPath(context), UserName = ServerHelper.CurrentUserName, }; LockStudyParameters lockParms = new LockStudyParameters { QueueStudyStateEnum = QueueStudyStateEnum.ReconcileScheduled, StudyStorageKey = entry.StudyStorageKey }; ILockStudy lockBbroker = context.GetBroker <ILockStudy>(); lockBbroker.Execute(lockParms); if (!lockParms.Successful) { throw new ApplicationException(lockParms.FailureReason); } IWorkQueueProcessDuplicateSopBroker broker = context.GetBroker <IWorkQueueProcessDuplicateSopBroker>(); WorkQueueProcessDuplicateSopUpdateColumns columns = new WorkQueueProcessDuplicateSopUpdateColumns { Data = XmlUtils.SerializeAsXmlDoc(data), GroupID = entry.GroupID, ScheduledTime = Platform.Time, ExpirationTime = Platform.Time.Add(TimeSpan.FromMinutes(15)), ServerPartitionKey = entry.ServerPartitionKey, WorkQueuePriorityEnum = WorkQueuePriorityEnum.Medium, StudyStorageKey = entry.StudyStorageKey, WorkQueueStatusEnum = WorkQueueStatusEnum.Pending }; WorkQueueProcessDuplicateSop processDuplicateWorkQueueEntry = broker.Insert(columns); IWorkQueueUidEntityBroker workQueueUidBroker = context.GetBroker <IWorkQueueUidEntityBroker>(); IStudyIntegrityQueueUidEntityBroker duplicateUidBroke = context.GetBroker <IStudyIntegrityQueueUidEntityBroker>(); foreach (StudyIntegrityQueueUid uid in uids) { WorkQueueUidUpdateColumns uidColumns = new WorkQueueUidUpdateColumns { Duplicate = true, Extension = ServerPlatform.DuplicateFileExtension, SeriesInstanceUid = uid.SeriesInstanceUid, SopInstanceUid = uid.SopInstanceUid, RelativePath = uid.RelativePath, WorkQueueKey = processDuplicateWorkQueueEntry.GetKey() }; workQueueUidBroker.Insert(uidColumns); duplicateUidBroke.Delete(uid.GetKey()); } IDuplicateSopEntryEntityBroker duplicateEntryBroker = context.GetBroker <IDuplicateSopEntryEntityBroker>(); duplicateEntryBroker.Delete(entry.GetKey()); context.Commit(); } }
/// <summary> /// Insert an EditStudy request. /// </summary> /// <param name="context"></param> /// <param name="studyStorageKey"></param> /// <param name="serverPartitionKey"></param> /// <param name="type"></param> /// <param name="updateItems"></param> /// <param name="reason"></param> /// <param name="user"></param> /// <param name="editType"></param> /// <returns></returns> private static WorkQueue InsertEditStudyRequest(IUpdateContext context, ServerEntityKey studyStorageKey, ServerEntityKey serverPartitionKey, WorkQueueTypeEnum type, List <UpdateItem> updateItems, string reason, string user, EditType editType) { var broker = context.GetBroker <IInsertWorkQueue>(); InsertWorkQueueParameters criteria = new EditStudyWorkQueueParameters(studyStorageKey, serverPartitionKey, type, updateItems, reason, user, editType); WorkQueue editEntry = broker.FindOne(criteria); if (editEntry == null) { throw new ApplicationException(string.Format("Unable to insert an Edit request of type {0} for study for user {1}", type.Description, user)); } return(editEntry); }
/// <summary> /// Insert an EditStudy request. /// </summary> /// <param name="context"></param> /// <param name="studyStorageKey"></param> /// <param name="serverPartitionKey"></param> /// <param name="type"></param> /// <param name="updateItems"></param> /// <param name="reason"></param> /// <param name="user"></param> /// <param name="editType"></param> /// <returns></returns> private static WorkQueue InsertExternalEditStudyRequest(IUpdateContext context, ServerEntityKey studyStorageKey, ServerEntityKey serverPartitionKey, WorkQueueTypeEnum type, List <UpdateItem> updateItems, string reason, string user, EditType editType) { var propertiesBroker = context.GetBroker <IWorkQueueTypePropertiesEntityBroker>(); var criteria = new WorkQueueTypePropertiesSelectCriteria(); criteria.WorkQueueTypeEnum.EqualTo(type); WorkQueueTypeProperties properties = propertiesBroker.FindOne(criteria); var broker = context.GetBroker <IWorkQueueEntityBroker>(); var insert = new WorkQueueUpdateColumns(); DateTime now = Platform.Time; var data = new EditStudyWorkQueueData { EditRequest = { TimeStamp = now, UserId = user, UpdateEntries = updateItems, Reason = reason, EditType = editType } }; insert.WorkQueueTypeEnum = type; insert.StudyStorageKey = studyStorageKey; insert.ServerPartitionKey = serverPartitionKey; insert.ScheduledTime = now; insert.ExpirationTime = now.AddSeconds(properties.ExpireDelaySeconds); insert.WorkQueueStatusEnum = WorkQueueStatusEnum.Pending; insert.WorkQueuePriorityEnum = properties.WorkQueuePriorityEnum; insert.Data = XmlUtils.SerializeAsXmlDoc(data); WorkQueue editEntry = broker.Insert(insert); if (editEntry == null) { throw new ApplicationException(string.Format("Unable to insert an Edit request of type {0} for study for user {1}", type.Description, user)); } return(editEntry); }
/// <summary> /// Returns a value indicating whether the filesystem with the specified key /// is writable. /// </summary> /// <param name="key"></param> /// <returns></returns> public bool IsWritable(ServerEntityKey key) { ServerFilesystemInfo fs = GetFilesystemInfo(key); return(fs.Writeable); }
public MoveSeriesWorkQueueParameters(StudyStorageLocation studyStorageLocation, string seriesInstanceUid, ServerEntityKey deviceKey) { DateTime now = Platform.Time; var data = new WebMoveSeriesLevelQueueData { Timestamp = now, UserId = ServerHelper.CurrentUserName }; //data.SeriesInstanceUids = new List<string> {seriesInstanceUid}; WorkQueueTypeEnum = WorkQueueTypeEnum.WebMoveStudy; StudyStorageKey = studyStorageLocation.Key; ServerPartitionKey = studyStorageLocation.ServerPartitionKey; ScheduledTime = now; SeriesInstanceUid = seriesInstanceUid; WorkQueueData = XmlUtils.SerializeAsXmlDoc(data); DeviceKey = deviceKey; }
/// <summary> /// Gets a list of authority groups that can access a given partition /// </summary> /// <param name="partitionKey">The partition</param> /// <param name="dataAccessGrupsOnly">True to find data access groups only; False to find all authority groups</param> /// <param name="allStudiesGroup">Returns a list of groups that have access to all studies</param> /// <returns></returns> public IList <AuthorityGroupDetail> GetAuthorityGroupsForPartition(ServerEntityKey partitionKey, bool dataAccessGrupsOnly, out IList <AuthorityGroupDetail> allStudiesGroup) { using (var service = new AuthorityRead()) { IList <AuthorityGroupDetail> groups = dataAccessGrupsOnly ? service.ListDataAccessAuthorityGroupDetails() : service.ListAllAuthorityGroupDetails(); IList <AuthorityGroupDetail> resultGroups = new List <AuthorityGroupDetail>(); var internalAllStudiesGroup = new List <AuthorityGroupDetail>(); CollectionUtils.ForEach( groups, delegate(AuthorityGroupDetail group) { bool allPartitions = false; bool allStudies = false; foreach (var token in group.AuthorityTokens) { if (token.Name.Equals(ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllPartitions)) { allPartitions = true; } else if (token.Name.Equals(ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllStudies)) { allStudies = true; } if (allPartitions && allStudies) { break; } } if (allPartitions && allStudies) { internalAllStudiesGroup.Add(group); return; } if (!allPartitions) { using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { var criteria = new ServerPartitionDataAccessSelectCriteria(); criteria.ServerPartitionKey.EqualTo(partitionKey); var dataCriteria = new DataAccessGroupSelectCriteria(); dataCriteria.AuthorityGroupOID.EqualTo(new ServerEntityKey("AuthorityGroupOID", new Guid(group.AuthorityGroupRef.ToString(false, false)))); dataCriteria.ServerPartitionDataAccessRelatedEntityCondition.Exists(criteria); var broker = readContext.GetBroker <IDataAccessGroupEntityBroker>(); if (broker.Count(dataCriteria) == 0) { return; } } } if (allStudies) { internalAllStudiesGroup.Add(group); return; } resultGroups.Add(group); }); allStudiesGroup = internalAllStudiesGroup; return(resultGroups); } }
public new static InconsistentDataSIQEntry Load(IPersistenceContext context, ServerEntityKey key) { return(new InconsistentDataSIQEntry(StudyIntegrityQueue.Load(context, key))); }
/// <summary> /// Lock a specific study for deletion. /// </summary> /// <param name="studyStorageKey"></param> /// <param name="failureReason">An english reason as to why the lock failed.</param> /// <returns>true if the study has been locked, falst if not.</returns> public static bool LockStudyForDeletion(ServerEntityKey studyStorageKey, out string failureReason) { return(ServerHelper.LockStudy(studyStorageKey, QueueStudyStateEnum.WebDeleteScheduled, out failureReason)); }
/// <summary> /// Load all of the instances in a given <see cref="StudyXml"/> file into the component for sending. /// </summary> /// <param name="studyXml">The <see cref="StudyXml"/> file to load from</param> /// <param name="context"></param> /// <param name="workQueueKey"></param> protected static void InsertWorkQueueUidFromStudyXml(StudyXml studyXml, IUpdateContext context, ServerEntityKey workQueueKey) { foreach (SeriesXml seriesXml in studyXml) { foreach (InstanceXml instanceXml in seriesXml) { WorkQueueUidUpdateColumns updateColumns = new WorkQueueUidUpdateColumns(); updateColumns.Duplicate = false; updateColumns.Failed = false; updateColumns.SeriesInstanceUid = seriesXml.SeriesInstanceUid; updateColumns.SopInstanceUid = instanceXml.SopInstanceUid; updateColumns.WorkQueueKey = workQueueKey; IWorkQueueUidEntityBroker broker = context.GetBroker <IWorkQueueUidEntityBroker>(); broker.Insert(updateColumns); } } }
public TServerEntity Get(ServerEntityKey key) { return(Get(HttpContext.Current.GetSharedPersistentContext(), key)); }
public ServerPartition GetServerPartition(ServerEntityKey key) { return(Get(key)); }
public new static DuplicateSopReceivedQueue Load(IPersistenceContext context, ServerEntityKey key) { return(new DuplicateSopReceivedQueue(StudyIntegrityQueue.Load(context, key))); }