protected internal virtual void InitActivityInstanceEvent(HistoricActivityInstanceEventEntity evt, MigratingActivityInstance migratingActivityInstance, IHistoryEventType eventType) { IPvmScope eventSource = migratingActivityInstance.TargetScope; string activityInstanceId = migratingActivityInstance.ActivityInstanceId; MigratingActivityInstance parentInstance = (MigratingActivityInstance)migratingActivityInstance.Parent; string parentActivityInstanceId = null; if (parentInstance != null) { parentActivityInstanceId = parentInstance.ActivityInstanceId; } ExecutionEntity execution = migratingActivityInstance.ResolveRepresentativeExecution(); InitActivityInstanceEvent(evt, execution, eventSource, activityInstanceId, parentActivityInstanceId, eventType); }
protected internal virtual void InitActivityInstanceEvent(HistoricActivityInstanceEventEntity evt, ExecutionEntity execution, IPvmScope eventSource, string activityInstanceId, string parentActivityInstanceId, IHistoryEventType eventType) { evt.Id = activityInstanceId; evt.EventType = eventType.EventName; evt.ActivityInstanceId = activityInstanceId; evt.ParentActivityInstanceId = parentActivityInstanceId; evt.ProcessDefinitionId = execution.ProcessDefinitionId; evt.ProcessInstanceId = execution.ProcessInstanceId; evt.ExecutionId = execution.Id; evt.TenantId = execution.TenantId; ProcessDefinitionEntity definition = execution.GetProcessDefinition(); if (definition != null) { evt.ProcessDefinitionKey = definition.Key; } evt.ActivityId = eventSource.Id; evt.ActivityName = (string)eventSource.GetProperty("name"); evt.ActivityType = (string)eventSource.GetProperty("type"); // update sub process reference ExecutionEntity subProcessInstance = execution.GetSubProcessInstance(); if (subProcessInstance != null) { evt.CalledProcessInstanceId = subProcessInstance.Id; } // update sub case reference //CaseExecutionEntity subCaseInstance = execution.GetSubCaseInstance(); //if (subCaseInstance != null) //{ // evt.CalledCaseInstanceId = subCaseInstance.Id; //} }
protected internal virtual void InitActivityInstanceEvent(HistoricActivityInstanceEventEntity evt, ExecutionEntity execution, IHistoryEventType eventType) { IPvmScope eventSource = execution.Activity; if (eventSource == null) { eventSource = (IPvmScope)execution.EventSource; } string activityInstanceId = execution.ActivityInstanceId; string parentActivityInstanceId = null; ExecutionEntity parentExecution = (ExecutionEntity)execution.Parent; if (parentExecution != null && CompensationBehavior.IsCompensationThrowing(parentExecution) && execution.Activity != null) { parentActivityInstanceId = CompensationBehavior.GetParentActivityInstanceId(execution); } else { parentActivityInstanceId = execution.ParentActivityInstanceId; } InitActivityInstanceEvent(evt, execution, eventSource, activityInstanceId, parentActivityInstanceId, eventType); }
protected internal virtual void InitHistoricIncidentEvent(Event.HistoricIncidentEntity evt, IIncident incident, IHistoryEventType eventType) { // init properties evt.Id = incident.Id; evt.ProcessDefinitionId = incident.ProcessDefinitionId; evt.ProcessInstanceId = incident.ProcessInstanceId; evt.ExecutionId = incident.ExecutionId; evt.CreateTime = incident.IncidentTimestamp; evt.IncidentType = incident.IncidentType; evt.ActivityId = incident.ActivityId; evt.CauseIncidentId = incident.CauseIncidentId; evt.RootCauseIncidentId = incident.RootCauseIncidentId; evt.Configuration = incident.Configuration; evt.IncidentMessage = incident.IncidentMessage; evt.TenantId = incident.TenantId; evt.JobDefinitionId = incident.JobDefinitionId; IncidentEntity incidentEntity = (IncidentEntity)incident; ProcessDefinitionEntity definition = incidentEntity.ProcessDefinition; if (definition != null) { evt.ProcessDefinitionKey = definition.Key; } // init event type evt.EventType = eventType.EventName; // init state IIncidentState incidentState = IncidentStateFields.Deleted; if (HistoryEventTypes.IncidentDelete == eventType) { incidentState = IncidentStateFields.Deleted; } else if (HistoryEventTypes.IncidentResolve.Equals(eventType)) { incidentState = IncidentStateFields.Resolved; } evt.IncidentState = incidentState.StateCode; }
protected internal virtual void InitHistoricVariableUpdateEvt(HistoricVariableUpdateEventEntity evt, VariableInstanceEntity variableInstance, IHistoryEventType eventType) { // init properties evt.EventType = eventType.EventName; evt.TimeStamp = ClockUtil.CurrentTime; evt.VariableInstanceId = variableInstance.Id; evt.ProcessInstanceId = variableInstance.ProcessInstanceId; evt.ExecutionId = variableInstance.ExecutionId; evt.CaseInstanceId = variableInstance.CaseInstanceId; evt.CaseExecutionId = variableInstance.CaseExecutionId; evt.TaskId = variableInstance.TaskId; evt.Revision = variableInstance.Revision; evt.VariableName = variableInstance.Name; evt.SerializerName = variableInstance.SerializerName; evt.TenantId = variableInstance.TenantId; ExecutionEntity execution = variableInstance.Execution; if (execution != null) { ProcessDefinitionEntity definition = execution.GetProcessDefinition(); if (definition != null) { evt.ProcessDefinitionId = definition.Id; evt.ProcessDefinitionKey = definition.Key; } } //CaseExecutionEntity caseExecution = variableInstance.CaseExecution; //if (caseExecution != null) //{ // CaseDefinitionEntity definition = (CaseDefinitionEntity)caseExecution.CaseDefinition; // if (definition != null) // { // evt.CaseDefinitionId = definition.Id; // evt.CaseDefinitionKey = definition.Key; // } //} // copy value evt.TextValue = variableInstance.TextValue; evt.TextValue2 = variableInstance.TextValue2; evt.DoubleValue = variableInstance.DoubleValue; evt.LongValue = variableInstance.LongValue; if (variableInstance.ByteArrayId != null) { evt.ByteValue = variableInstance.ByteArrayValue; //evt.Value = variableInstance.Value; //evt.ByteArrayValue = variableInstance.ByteArrayValue; var r = evt.Value; } }
protected internal virtual void InitTaskInstanceEvent(HistoricTaskInstanceEventEntity evt, TaskEntity taskEntity, IHistoryEventType eventType) { string processDefinitionKey = null; ProcessDefinitionEntity definition = taskEntity.ProcessDefinition; if (definition != null) { processDefinitionKey = definition.Key; } string processDefinitionId = taskEntity.ProcessDefinitionId; string processInstanceId = taskEntity.ProcessInstanceId; string executionId = taskEntity.ExecutionId; string caseDefinitionKey = null; //CaseDefinitionEntity caseDefinition = taskEntity.CaseDefinition; //if (caseDefinition != null) //{ // caseDefinitionKey = caseDefinition.Key; //} string caseDefinitionId = taskEntity.CaseDefinitionId; string caseExecutionId = taskEntity.CaseExecutionId; string caseInstanceId = taskEntity.CaseInstanceId; string tenantId = taskEntity.TenantId; evt.Id = taskEntity.Id; evt.EventType = eventType.EventName; evt.TaskId = taskEntity.Id; evt.ProcessDefinitionKey = processDefinitionKey; evt.ProcessDefinitionId = processDefinitionId; evt.ProcessInstanceId = processInstanceId; evt.ExecutionId = executionId; evt.CaseDefinitionKey = caseDefinitionKey; evt.CaseDefinitionId = caseDefinitionId; evt.CaseExecutionId = caseExecutionId; evt.CaseInstanceId = caseInstanceId; evt.Assignee = taskEntity.Assignee; evt.Description = taskEntity.Description; evt.DueDate = taskEntity.DueDate; evt.FollowUpDate = taskEntity.FollowUpDate; evt.Name = taskEntity.Name; evt.Owner = taskEntity.Owner; evt.ParentTaskId = taskEntity.ParentTaskId; evt.Priority = taskEntity.Priority; evt.TaskDefinitionKey = taskEntity.TaskDefinitionKey; evt.TenantId = tenantId; ExecutionEntity execution = taskEntity.GetExecution(); if (execution != null) { evt.ActivityInstanceId = execution.ActivityInstanceId; } }
protected internal virtual void InitProcessInstanceEvent(HistoricProcessInstanceEventEntity evt, ExecutionEntity execution, IHistoryEventType eventType) { string processDefinitionId = execution.ProcessDefinitionId; string processInstanceId = execution.ProcessInstanceId; string executionId = execution.Id; // the given execution is the process instance! string caseInstanceId = execution.CaseInstanceId; string tenantId = execution.TenantId; ProcessDefinitionEntity definition = execution.GetProcessDefinition(); string processDefinitionKey = null; if (definition != null) { processDefinitionKey = definition.Key; } evt.Id = processInstanceId; evt.EventType = eventType.EventName; evt.ProcessDefinitionKey = processDefinitionKey; evt.ProcessDefinitionId = processDefinitionId; evt.ProcessInstanceId = processInstanceId; evt.ExecutionId = executionId; evt.BusinessKey = execution.ProcessBusinessKey; evt.CaseInstanceId = caseInstanceId; evt.TenantId = tenantId; //if (execution.GetSuperCaseExecution() != null) //{ // evt.SuperCaseInstanceId = execution.GetSuperCaseExecution().CaseInstanceId; //} if (execution.SuperExecution != null) { evt.SuperProcessInstanceId = execution.SuperExecution.ProcessInstanceId; } }