TrakHound_Server.Plugins.Parts.PartInfo.Process C# (CSharp) Method

Process() public static method

public static Process ( PartCountEvent partCountEvent, GeneratedEvent gEvent, long _lastSequence ) : PartInfo
partCountEvent PartCountEvent
gEvent TrakHound_Server.Plugins.GeneratedEvents.GeneratedEvent
_lastSequence long
return PartInfo
        public static PartInfo Process(PartCountEvent partCountEvent, GeneratedEvent gEvent, long _lastSequence)
        {
            if (partCountEvent.ValueType == ValueType.CAPTURE_ITEM)
            {
                return ProcessCaptureItemMethod(partCountEvent, gEvent, _lastSequence);
            }
            else if (partCountEvent.ValueType == ValueType.STATIC_INCREMENT)
            {
                return ProcessStaticIncrementMethod(partCountEvent, gEvent, _lastSequence);
            }

            return null;
        }

Usage Example

Exemplo n.º 1
0
        private void ProcessGeneratedEvents(EventData data)
        {
            var gEventItems = (List <GeneratedEvent>)data.Data02;

            gEventItems = gEventItems.OrderBy(o => o.CurrentValue.Timestamp).ToList();

            var pc = Configuration.Get(configuration);

            if (pc != null)
            {
                var infos = new List <PartInfo>();

                foreach (var partCountEvent in pc.Events)
                {
                    var matchedItems = gEventItems.FindAll(x => x.EventName == partCountEvent.EventName && x.CurrentValue != null && x.PreviousValue != null);
                    foreach (var gEvent in matchedItems)
                    {
                        // Test if current event value matches configured EventName
                        if (gEvent.CurrentValue != null && gEvent.CurrentValue.Value == String_Functions.UppercaseFirst(partCountEvent.EventValue.Replace('_', ' ')))
                        {
                            bool match = true;

                            // Test if previous event value matches configured PreviousEventName
                            if (!string.IsNullOrEmpty(partCountEvent.PreviousEventValue))
                            {
                                match = gEvent.PreviousValue.Value == String_Functions.UppercaseFirst(partCountEvent.PreviousEventValue.Replace('_', ' '));
                            }

                            if (match)
                            {
                                lock (_lock)
                                {
                                    var partInfo = PartInfo.Process(partCountEvent, gEvent, lastSequence);
                                    if (partInfo != null)
                                    {
                                        infos.Add(partInfo);

                                        lastSequence = partInfo.Sequence;
                                        SaveStoredSequence(configuration, lastSequence);
                                    }
                                }
                            }
                        }
                    }

                    if (infos.Count > 0)
                    {
                        SendPartInfos(infos);
                    }
                }
            }
        }