public void OnCompleted(WebDeleteProcessorContext context, IList <Series> series) { if (series.Count > 0) { Platform.Log(LogLevel.Info, "Logging history.."); DateTime now = Platform.Time; using (IUpdateContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush)) { IStudyHistoryEntityBroker broker = ctx.GetBroker <IStudyHistoryEntityBroker>(); StudyHistoryUpdateColumns columns = new StudyHistoryUpdateColumns(); columns.InsertTime = Platform.Time; columns.StudyHistoryTypeEnum = StudyHistoryTypeEnum.SeriesDeleted; columns.StudyStorageKey = context.StorageLocation.Key; columns.DestStudyStorageKey = context.StorageLocation.Key; columns.StudyData = XmlUtils.SerializeAsXmlDoc(_studyInfo); SeriesDeletionChangeLog changeLog = new SeriesDeletionChangeLog(); changeLog.TimeStamp = now; changeLog.Reason = context.Reason; changeLog.UserId = context.UserId; changeLog.UserName = context.UserName; changeLog.Series = CollectionUtils.Map(series, delegate(Series ser) { ServerEntityAttributeProvider seriesWrapper = new ServerEntityAttributeProvider(ser); return(new SeriesInformation(seriesWrapper)); }); columns.ChangeDescription = XmlUtils.SerializeAsXmlDoc(changeLog); StudyHistory history = broker.Insert(columns); if (history != null) { ctx.Commit(); } } } }
public void EventHandler(object sender, StudyEditedEventArgs e) { IPersistentStore store = PersistentStoreRegistry.GetDefaultStore(); using (IUpdateContext ctx = store.OpenUpdateContext(UpdateContextSyncMode.Flush)) { Platform.Log(LogLevel.Info, "Logging study history record..."); IStudyHistoryEntityBroker broker = ctx.GetBroker<IStudyHistoryEntityBroker>(); StudyHistoryUpdateColumns recordColumns = CreateStudyHistoryRecord(e); StudyHistory entry = broker.Insert(recordColumns); if (entry != null) ctx.Commit(); else throw new ApplicationException("Unable to log study history record"); } }
protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext) { IStudyHistoryEntityBroker historyUpdateBroker = updateContext.GetBroker <IStudyHistoryEntityBroker>(); StudyHistoryUpdateColumns parms = new StudyHistoryUpdateColumns { DestStudyStorageKey = _destStudy.Key }; if (_map != null) { // replace the mapping in the history StudyReconcileDescriptor changeLog = XmlUtils.Deserialize <StudyReconcileDescriptor>(_studyHistory.ChangeDescription); changeLog.SeriesMappings = new System.Collections.Generic.List <SeriesMapping>(_map.GetSeriesMappings()); parms.ChangeDescription = XmlUtils.SerializeAsXmlDoc(changeLog); } historyUpdateBroker.Update(_studyHistory.Key, parms); }
/// <summary> /// Finds a list of <see cref="StudyHistory"/> records of the specified <see cref="StudyHistoryTypeEnum"/> /// for the specified <see cref="StudyStorage"/>. /// </summary> /// <param name="studyStorage"></param> /// <returns></returns> /// <param name="types"></param> static public IList <StudyHistory> FindStudyHistories(StudyStorage studyStorage, IEnumerable <StudyHistoryTypeEnum> types) { // Use of ExecutionContext to re-use db connection if possible using (ServerExecutionContext scope = new ServerExecutionContext()) { IStudyHistoryEntityBroker broker = scope.PersistenceContext.GetBroker <IStudyHistoryEntityBroker>(); StudyHistorySelectCriteria criteria = new StudyHistorySelectCriteria(); criteria.StudyStorageKey.EqualTo(studyStorage.Key); criteria.StudyHistoryTypeEnum.EqualTo(StudyHistoryTypeEnum.StudyReconciled); if (types != null) { criteria.StudyHistoryTypeEnum.In(types); } criteria.InsertTime.SortAsc(0); IList <StudyHistory> historyList = broker.Find(criteria); return(historyList); } }
public static StudyHistory CreateStudyHistoryRecord(IUpdateContext updateContext, StudyStorageLocation primaryStudyLocation, StudyStorageLocation secondaryStudyLocation, StudyHistoryTypeEnum type, object entryInfo, object changeLog) { StudyHistoryUpdateColumns columns = new StudyHistoryUpdateColumns { InsertTime = Platform.Time, StudyHistoryTypeEnum = type, StudyStorageKey = primaryStudyLocation.GetKey(), DestStudyStorageKey = secondaryStudyLocation != null ? secondaryStudyLocation.GetKey() : primaryStudyLocation.GetKey(), StudyData = XmlUtils.SerializeAsXmlDoc(entryInfo) ?? new XmlDocument(), ChangeDescription = XmlUtils.SerializeAsXmlDoc(changeLog) ?? new XmlDocument() }; IStudyHistoryEntityBroker broker = updateContext.GetBroker <IStudyHistoryEntityBroker>(); return(broker.Insert(columns)); }
private void LogHistory(ImageSetDetails details) { IPersistentStore store = PersistentStoreRegistry.GetDefaultStore(); using (IUpdateContext ctx = store.OpenUpdateContext(UpdateContextSyncMode.Flush)) { Platform.Log(LogLevel.Info, "Logging study history record..."); IStudyHistoryEntityBroker broker = ctx.GetBroker <IStudyHistoryEntityBroker>(); StudyHistoryUpdateColumns recordColumns = CreateStudyHistoryRecord(details); StudyHistory entry = broker.Insert(recordColumns); if (entry != null) { ctx.Commit(); } else { throw new ApplicationException("Unable to log study history record"); } } HistoryLogged = true; }