/// <summary> /// general history event insert behavior </summary> protected internal virtual void insertOrUpdate(HistoryEvent historyEvent) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager dbEntityManager = getDbEntityManager(); DbEntityManager dbEntityManager = DbEntityManager; if (isInitialEvent(historyEvent)) { dbEntityManager.insert(historyEvent); } else { if (dbEntityManager.getCachedEntity(historyEvent.GetType(), historyEvent.Id) == null) { if (historyEvent is HistoricScopeInstanceEvent) { // if this is a scope, get start time from existing event in DB HistoricScopeInstanceEvent existingEvent = (HistoricScopeInstanceEvent)dbEntityManager.selectById(historyEvent.GetType(), historyEvent.Id); if (existingEvent != null) { HistoricScopeInstanceEvent historicScopeInstanceEvent = (HistoricScopeInstanceEvent)historyEvent; historicScopeInstanceEvent.StartTime = existingEvent.StartTime; } } if (string.ReferenceEquals(historyEvent.Id, null)) { // dbSqlSession.insert(historyEvent); } else { dbEntityManager.merge(historyEvent); } } } }
/// <summary> /// general history event insert behavior /// </summary> protected internal virtual void InsertOrUpdate(HistoryEvent historyEvent) { log.LogDebug("InsertOrUpdateEF缓存:", historyEvent.GetType().Name + " id:" + historyEvent.Id, historyEvent); if (IsInitialEvent(historyEvent)) { Insert(historyEvent); } else { //throw new NotImplementedException(); //TODO CachedEntity改了原始逻辑 //if (dbEntityManager.getCachedEntity(historyEvent.getClass(), historyEvent.getId()) == null) //if (repository.Get(historyEvent.Id) == null) //{ if (historyEvent is HistoricScopeInstanceEvent) { // if this is a scope, get start time from existing event in DB HistoricScopeInstanceEvent existingEvent = Get(historyEvent); if (existingEvent != null) { HistoricScopeInstanceEvent historicScopeInstanceEvent = (HistoricScopeInstanceEvent)historyEvent; historicScopeInstanceEvent.StartTime = existingEvent.StartTime; } } else { } if (historyEvent.Id == null) { //源码如此 //dbSqlSession.insert(historyEvent); } else { Update(historyEvent); //throw new NotImplementedException(); //dbEntityManager.merge(historyEvent); } } }