示例#1
0
        private ConnectKinesisEventRecord ConvertRecordData(string recordData)
        {
            _logger.Trace("Beginning ConvertRecordData");

            EventRecordData recordDataObject;

            try
            {
                recordDataObject = JsonConvert.DeserializeObject <EventRecordData>(recordData);
            }
            catch (Exception e)
            {
                _logger.Error($"Exception deserializing recordData: {e}. Discarding recordData.");
                // This record doesn't match the EventRecordData format, return a value that
                // indicates that this record should be discarded.
                return(null);
            }

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

            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);
        }
        private EventRecordData ParseEvent(string recordData)
        {
            _logger.Trace("Beginning ParseEvent");

            EventRecordData recordDataObject;

            try
            {
                recordDataObject = JsonConvert.DeserializeObject <EventRecordData>(recordData);
            }
            catch (Exception e)
            {
                _logger.Error($"Exception deserializing recordData: {e}. Discarding recordData.");
                // This record doesn't match the EventRecordData format, return a value that
                // indicates that this record should be discarded.
                return(null);
            }

            _logger.Trace("Ending ParseEvent");
            return(recordDataObject);
        }