public override IEventLogEntryEntity GenerateEventLogEntry(CommandContext <IEventLogEntryEntity> commandContext)
        {
            IActivitiEntityEvent activitiEntityEvent = (IActivitiEntityEvent)@event;

            ITaskEntity task = (ITaskEntity)activitiEntityEvent.Entity;
            IDictionary <string, object> data = handleCommonTaskFields(task);

            long duration = timeStamp.Value.Ticks - task.CreateTime.Value.Ticks;

            PutInMapIfNotNull(data, FieldsFields.DURATION, duration);

            if (@event is IActivitiEntityWithVariablesEvent)
            {
                IActivitiEntityWithVariablesEvent activitiEntityWithVariablesEvent = (IActivitiEntityWithVariablesEvent)@event;
                if (activitiEntityWithVariablesEvent.Variables != null && activitiEntityWithVariablesEvent.Variables.Count > 0)
                {
                    IDictionary <string, object> variableMap = new Dictionary <string, object>();
                    foreach (object variableName in activitiEntityWithVariablesEvent.Variables.Keys)
                    {
                        PutInMapIfNotNull(variableMap, (string)variableName, activitiEntityWithVariablesEvent.Variables[variableName.ToString()]);
                    }
                    if (activitiEntityWithVariablesEvent.LocalScope)
                    {
                        PutInMapIfNotNull(data, FieldsFields.LOCAL_VARIABLES, variableMap);
                    }
                    else
                    {
                        PutInMapIfNotNull(data, FieldsFields.VARIABLES, variableMap);
                    }
                }
            }

            return(CreateEventLogEntry(task.ProcessDefinitionId, task.ProcessInstanceId, task.ExecutionId, task.Id, data));
        }
        public override IEventLogEntryEntity GenerateEventLogEntry(CommandContext <IEventLogEntryEntity> commandContext)
        {
            IActivitiEntityWithVariablesEvent eventWithVariables = (IActivitiEntityWithVariablesEvent)@event;
            IExecutionEntity processInstanceEntity = (IExecutionEntity)eventWithVariables.Entity;

            IDictionary <string, object> data = new Dictionary <string, object>();

            PutInMapIfNotNull(data, FieldsFields.ID, processInstanceEntity.Id);
            PutInMapIfNotNull(data, FieldsFields.BUSINESS_KEY, processInstanceEntity.BusinessKey);
            PutInMapIfNotNull(data, FieldsFields.PROCESS_DEFINITION_ID, processInstanceEntity.ProcessDefinitionId);
            PutInMapIfNotNull(data, FieldsFields.NAME, processInstanceEntity.Name);
            PutInMapIfNotNull(data, FieldsFields.CREATE_TIME, timeStamp);

            if (eventWithVariables.Variables != null && eventWithVariables.Variables.Count > 0)
            {
                IDictionary <string, object> variableMap = new Dictionary <string, object>();
                foreach (object variableName in eventWithVariables.Variables.Keys)
                {
                    PutInMapIfNotNull(variableMap, (string)variableName, eventWithVariables.Variables[variableName.ToString()]);
                }
                PutInMapIfNotNull(data, FieldsFields.VARIABLES, variableMap);
            }

            return(CreateEventLogEntry(TYPE, processInstanceEntity.ProcessDefinitionId, processInstanceEntity.Id, null, null, data));
        }