private static GeneratedEvent ProcessEvent(Event e, Instance instance) { // Process Event using InstanceData Return eventReturn = e.Process(instance); if (e.PreviousValue == null) e.PreviousValue = e.Default.Copy(); if (e.CurrentValue != null) { e.PreviousValue = e.CurrentValue.Copy(); e.PreviousValue.Id = e.CurrentValue.Id; } if (eventReturn != e.CurrentValue) { e.CurrentValue = eventReturn.Copy(); e.CurrentValue.ChangedTimeStamp = instance.Timestamp; e.CurrentValue.ChangedSequence = instance.Sequence; } e.CurrentValue.TimeStamp = instance.Timestamp; e.CurrentValue.Sequence = instance.Sequence; // Set Duration if (e.CurrentValue.TimeStamp > DateTime.MinValue && e.PreviousValue.TimeStamp > DateTime.MinValue) { eventReturn.Duration = (e.CurrentValue.TimeStamp - e.PreviousValue.TimeStamp).TotalSeconds; } else { eventReturn.Duration = 0; } // Create new GeneratedEvent object var result = new GeneratedEvent(); result.EventName = e.Name; result.PreviousValue = new ValueData(e.PreviousValue); result.CurrentValue = new ValueData(e.CurrentValue); result.CaptureItems.AddRange(e.CurrentValue.CaptureItems); return result; }