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;
            //}
        }