private ConnectKinesisEventRecord ConvertRecordData(string json, EventRecordData eventRecord)
        {
            _logger.Trace("Beginning ConvertRecordData");

            // if this record doesn't include an agent ARN, assume it doesn't match the
            // required format. Discard it.
            if (String.IsNullOrEmpty(eventRecord?.AgentARN))
            {
                _logger.Info("recordData does not include AgentARN. Discarding recordData.");
                return(null);
            }

            ConnectKinesisEventRecord streamRecord = new ConnectKinesisEventRecord()
            {
                AgentARN                 = eventRecord.AgentARN,
                AgentUsername            = eventRecord.CurrentAgentSnapshot?.Configuration?.Username,
                LastEventType            = eventRecord.EventType,
                LastEventTimeStamp       = eventRecord.EventTimestamp,
                LastStateChangeTimeStamp = eventRecord.CurrentAgentSnapshot?.AgentStatus.StartTimestamp,
                CurrentState             = eventRecord.CurrentAgentSnapshot?.AgentStatus?.Name,
                RawAgentEventJSon        = json
            };

            _logger.Debug($"Event Type: {eventRecord.EventType} Agent Username: {streamRecord.AgentUsername} Current State: {streamRecord.CurrentState} Event Time: {streamRecord.LastEventTimeStamp} State Change Time: {streamRecord.LastStateChangeTimeStamp}");

            _logger.Trace("Ending ConvertRecordData");

            return(streamRecord);
        }
        private bool MatchFilter(EventRecordData eventRecord)
        {
            switch (_ahgFilterLevel)
            {
            case AHG_FILTER_LEVEL_DISABLED:
                return(true);

            case 1:
                return(MatchLevel(eventRecord?.CurrentAgentSnapshot?.Configuration?.AgentHierarchyGroups?.Level1?.Name));

            case 2:
                return(MatchLevel(eventRecord?.CurrentAgentSnapshot?.Configuration?.AgentHierarchyGroups?.Level2?.Name));

            case 3:
                return(MatchLevel(eventRecord?.CurrentAgentSnapshot?.Configuration?.AgentHierarchyGroups?.Level3?.Name));

            case 4:
                return(MatchLevel(eventRecord?.CurrentAgentSnapshot?.Configuration?.AgentHierarchyGroups?.Level4?.Name));

            case 5:
                return(MatchLevel(eventRecord?.CurrentAgentSnapshot?.Configuration?.AgentHierarchyGroups?.Level5?.Name));

            default:
                throw new Exception($"Invalid AHG Filter Level {_ahgFilterLevel}");
            }
        }
Exemple #3
0
        private ConnectKinesisEventRecord ConvertRecordData(string recordData)
        {
            _logger.Trace("Beginning ConvertRecordData");

            EventRecordData recordDataObject = JsonConvert.DeserializeObject <EventRecordData>(recordData);

            ConnectKinesisEventRecord streamRecord = new ConnectKinesisEventRecord()
            {
                AgentARN                 = recordDataObject.AgentARN,
                AgentUsername            = recordDataObject.CurrentAgentSnapshot?.Configuration?.Username,
                LastEventType            = recordDataObject.EventType,
                LastEventTimeStamp       = recordDataObject.EventTimestamp,
                LastStateChangeTimeStamp = recordDataObject.CurrentAgentSnapshot?.AgentStatus.StartTimestamp,
                CurrentState             = recordDataObject.CurrentAgentSnapshot?.AgentStatus?.Name,
                RawAgentEventJSon        = recordData
            };

            _logger.Debug($"Event Type: {recordDataObject.EventType} Agent Username: {streamRecord.AgentUsername} Current State: {streamRecord.CurrentState} Event Time: {streamRecord.LastEventTimeStamp} State Change Time: {streamRecord.LastStateChangeTimeStamp}");

            _logger.Trace("Ending ConvertRecordData");

            return(streamRecord);
        }