/// <summary> /// Creats a new file system. /// </summary> /// <param name="filesystem"></param> public bool AddFileSystem(Filesystem filesystem) { bool ok; // This filesystem update must be used, because the stored procedure does some // additional work on insert. using (IUpdateContext ctx = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush)) { IInsertFilesystem insert = ctx.GetBroker <IInsertFilesystem>(); FilesystemInsertParameters parms = new FilesystemInsertParameters(); parms.Description = filesystem.Description; parms.Enabled = filesystem.Enabled; parms.FilesystemPath = filesystem.FilesystemPath; parms.ReadOnly = filesystem.ReadOnly; parms.TypeEnum = filesystem.FilesystemTierEnum; parms.WriteOnly = filesystem.WriteOnly; parms.HighWatermark = filesystem.HighWatermark; parms.LowWatermark = filesystem.LowWatermark; Filesystem newFilesystem = insert.FindOne(parms); ok = newFilesystem != null; if (ok) { ctx.Commit(); } } return(ok); }
public override RestoreQueue GetRestoreCandidate() { RestoreQueue queueItem; using (IUpdateContext updateContext = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush)) { QueryRestoreQueueParameters parms = new QueryRestoreQueueParameters(); parms.PartitionArchiveKey = _partitionArchive.GetKey(); parms.ProcessorId = ServerPlatform.ProcessorId; parms.RestoreQueueStatusEnum = RestoreQueueStatusEnum.Restoring; IQueryRestoreQueue broker = updateContext.GetBroker <IQueryRestoreQueue>(); // Stored procedure only returns 1 result. queueItem = broker.FindOne(parms); if (queueItem != null) { updateContext.Commit(); } } if (queueItem == null) { using (IUpdateContext updateContext = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush)) { RestoreQueueSelectCriteria criteria = new RestoreQueueSelectCriteria(); criteria.RestoreQueueStatusEnum.EqualTo(RestoreQueueStatusEnum.Restoring); IRestoreQueueEntityBroker restoreQueueBroker = updateContext.GetBroker <IRestoreQueueEntityBroker>(); if (restoreQueueBroker.Count(criteria) > HsmSettings.Default.MaxSimultaneousRestores) { return(null); } QueryRestoreQueueParameters parms = new QueryRestoreQueueParameters(); parms.PartitionArchiveKey = _partitionArchive.GetKey(); parms.ProcessorId = ServerPlatform.ProcessorId; parms.RestoreQueueStatusEnum = RestoreQueueStatusEnum.Pending; IQueryRestoreQueue broker = updateContext.GetBroker <IQueryRestoreQueue>(); parms.RestoreQueueStatusEnum = RestoreQueueStatusEnum.Pending; queueItem = broker.FindOne(parms); if (queueItem != null) { updateContext.Commit(); } } } return(queueItem); }
/// <summary> /// Creats a new server parition. /// </summary> /// <param name="partition"></param> /// <param name="groupsWithAccess"> </param> public bool AddServerPartition(ServerPartition partition, List <string> groupsWithAccess) { bool ok; using (IUpdateContext ctx = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush)) { var insert = ctx.GetBroker <IInsertServerPartition>(); var parms = new ServerPartitionInsertParameters { AeTitle = partition.AeTitle, Description = partition.Description, Enabled = partition.Enabled, PartitionFolder = partition.PartitionFolder, Port = partition.Port, DefaultRemotePort = partition.DefaultRemotePort, AutoInsertDevice = partition.AutoInsertDevice, AcceptAnyDevice = partition.AcceptAnyDevice, DuplicateSopPolicyEnum = partition.DuplicateSopPolicyEnum, MatchPatientsName = partition.MatchPatientsName, MatchPatientId = partition.MatchPatientId, MatchPatientsBirthDate = partition.MatchPatientsBirthDate, MatchAccessionNumber = partition.MatchAccessionNumber, MatchIssuerOfPatientId = partition.MatchIssuerOfPatientId, MatchPatientsSex = partition.MatchPatientsSex, AuditDeleteStudy = partition.AuditDeleteStudy, AcceptLatestReport = partition.AcceptLatestReport }; try { ServerPartition insertPartition = insert.FindOne(parms); ok = insertPartition != null; UpdateDataAccess(ctx, insertPartition, groupsWithAccess); } catch (Exception e) { Platform.Log(LogLevel.Error, e, "Error while inserting server partition."); ok = false; } if (ok) { ctx.Commit(); } } return(ok); }
public bool Update(ServerPartition partition, List <string> groupsWithAccess) { using (IUpdateContext context = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush)) { var parms = new ServerPartitionUpdateColumns { AeTitle = partition.AeTitle, Description = partition.Description, Enabled = partition.Enabled, PartitionFolder = partition.PartitionFolder, Port = partition.Port, AcceptAnyDevice = partition.AcceptAnyDevice, AutoInsertDevice = partition.AutoInsertDevice, DefaultRemotePort = partition.DefaultRemotePort, DuplicateSopPolicyEnum = partition.DuplicateSopPolicyEnum, MatchPatientsName = partition.MatchPatientsName, MatchPatientId = partition.MatchPatientId, MatchPatientsBirthDate = partition.MatchPatientsBirthDate, MatchAccessionNumber = partition.MatchAccessionNumber, MatchIssuerOfPatientId = partition.MatchIssuerOfPatientId, MatchPatientsSex = partition.MatchPatientsSex, AuditDeleteStudy = partition.AuditDeleteStudy, AcceptLatestReport = partition.AcceptLatestReport }; var broker = context.GetBroker <IServerPartitionEntityBroker>(); if (!broker.Update(partition.Key, parms)) { return(false); } UpdateDataAccess(context, partition, groupsWithAccess); context.Commit(); return(true); } }