Ejemplo n.º 1
0
        private DataTable GetValuesDataTable(AuditEvent auditEvent, AuditEventType auditEventType)
        {
            DataTable dataTable = new DataTable();

            _ = dataTable.Columns.Add("Item", typeof(String));
            _ = dataTable.Columns.Add("Value", typeof(String));

            // Add standard header
            AddValuesRow(dataTable, "Time", auditEvent.TimeCreated.ToString());
            AddValuesRow(dataTable, "Event ID", auditEvent.ID);
            AddValuesRow(dataTable, "Event", auditEventType.Description);

            // Add other values
            foreach (AuditEventValue auditEventValue in auditEvent.Values)
            {
                AuditEventValueType auditEventValueType = _auditEventValueTypeRepository.GetByID(auditEventValue.TypeID);
                //if (!auditEventValueType.Internal)
                //{
                AuditEventValueConverter auditEventValueConverter = _valueConverters.Find(current => current.Handles(auditEventValue.TypeID));
                if (auditEventValueConverter != null)
                {
                    AddValuesRow(dataTable, auditEventValueType.Description, auditEventValueConverter.ValueConverter.Convert(auditEventValue.Value, auditEventValueType.Type, typeof(String)).ToString());
                }
                else
                {
                    AddValuesRow(dataTable, auditEventValueType.Description, auditEventValue.Value.ToString());
                }
            }
            return(dataTable);
        }
Ejemplo n.º 2
0
        protected DataTable GetValuesDataTable(AuditEvent auditEvent, Run run, AuditEventType auditEventType, string subEvent, AuditEventValueTypeRepository auditEventValueTypeRepository,
                                               List <AuditEventValueConverter> valueConverters)
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("Item", typeof(String));
            dataTable.Columns.Add("Value", typeof(String));

            //string runUrl = string.Format(@"{0}/#/manage-runs", _frontendUrl);

            // Add standard header
            //AddValuesRow(dataTable, "Time", auditEvent.TimeCreated.ToString());
            //AddValuesRow(dataTable, "Event ID", auditEvent.ID);
            //AddValuesRow(dataTable, "Event", string.IsNullOrEmpty(subEvent) ? auditEventType.Description : string.Format("{0} - {1}", auditEventType.Description, subEvent));

            // Add values from Run ID
            if (run != null)
            {
                AddValuesRow(dataTable, "Run", string.Format("{0} ({1})", run.Description, run.Id.ToString()));
                //AddValuesRow(dataTable, "Description", run.Description);
                //AddValuesRow(dataTable, "Date Range", string.Format("{0} - {1}", run.StartDateTime.ToString(), run.EndDateTime.ToString()));
                //AddValuesRow(dataTable, "Created", run.CreatedDateTime.ToString());
                AddValuesRow(dataTable, "Executed", run.ExecuteStartedDateTime == null ? "n/a" : run.ExecuteStartedDateTime.Value.ToString());
                if (run.CompletedScenarios.Count == run.Scenarios.Count && run.LastScenarioCompletedDateTime != null)
                {
                    AddValuesRow(dataTable, "Completed", run.LastScenarioCompletedDateTime.Value.ToString());
                }
            }

            // Add other values
            HashSet <int> valueTypesDone = new HashSet <int>()
            {
                AuditEventValueTypes.GamePlanRunID, AuditEventValueTypes.GamePlanPipelineEventID, AuditEventValueTypes.GamePlanAutoBookEventID
            };

            foreach (AuditEventValue auditEventValue in auditEvent.Values)
            {
                if (!valueTypesDone.Contains(auditEventValue.TypeID))   // Ignore values done above
                {
                    AuditEventValueType auditEventValueType = auditEventValueTypeRepository.GetByID(auditEventValue.TypeID);
                    if (!auditEventValueType.Internal)
                    {
                        AuditEventValueConverter auditEventValueConverter = valueConverters.Find(current => current.Handles(auditEventValue.TypeID));
                        if (auditEventValueConverter != null)
                        {
                            AddValuesRow(dataTable, auditEventValueType.Description, auditEventValueConverter.ValueConverter.Convert(auditEventValue.Value, auditEventValueType.Type, typeof(String)).ToString());
                        }
                        else
                        {
                            AddValuesRow(dataTable, auditEventValueType.Description, auditEventValue.Value.ToString());
                        }
                    }
                }
            }
            return(dataTable);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deserializes value
        /// </summary>
        /// <param name="valueTypeId"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private AuditEventValue DeserializeValue(int valueTypeId, string value)
        {
            AuditEventValueType      valueType = _auditEventValueTypeRepository.GetByID(valueTypeId);
            AuditEventValueConverter converter = _valueConverters.Find(item => item.Handles(valueTypeId));

            var auditEventValue = new AuditEventValue()
            {
                TypeID = Convert.ToInt32(valueTypeId),
                Value  = converter == null ? value : converter.ValueConverter.Convert(value, value.GetType(), valueType.Type)
            };

            return(auditEventValue);
        }
Ejemplo n.º 4
0
        protected string GetValueDescription(AuditEvent auditEvent, int valueTypeId, AuditEventValueTypeRepository auditEventValueTypeRepository, List <AuditEventValueConverter> valueConverters)
        {
            string          eventDescription = "";
            AuditEventValue auditEventValue  = auditEvent.GetValueByValueTypeId(valueTypeId);

            if (auditEventValue != null && auditEventValue.Value != null)
            {
                AuditEventValueType      auditEventValueType      = auditEventValueTypeRepository.GetByID(auditEventValue.TypeID);
                AuditEventValueConverter auditEventValueConverter = valueConverters.Find(current => current.Handles(auditEventValue.TypeID));
                if (auditEventValueConverter != null)   // Sanity check
                {
                    eventDescription = auditEventValueConverter.ValueConverter.Convert(auditEventValue.Value, auditEventValueType.Type, typeof(String)).ToString();
                }
            }
            return(eventDescription);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Serializes value
        /// </summary>
        /// <param name="auditEventValue"></param>
        /// <returns></returns>
        private string SerializeValue(AuditEventValue auditEventValue)
        {
            if (auditEventValue.Value is null)
            {
                return("null");
            }

            AuditEventValueType      valueType = _auditEventValueTypeRepository.GetByID(auditEventValue.TypeID);
            AuditEventValueConverter converter = _valueConverters.Find(current => current.Handles(auditEventValue.TypeID));

            if (converter != null)
            {
                return(converter.ValueConverter.Convert(auditEventValue.Value, valueType.Type, typeof(string)).ToString());
            }
            return(auditEventValue.Value.ToString());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Posts message to MS Teams channel
        /// </summary>
        /// <param name="auditEvent"></param>
        /// <param name="auditEventType"></param>
        /// <param name="postMessageSettings"></param>
        public void PostMessage(AuditEvent auditEvent, AuditEventType auditEventType, MSTeamsPostMessageSettings postMessageSettings)
        {
            StringBuilder title = new StringBuilder(auditEventType.Description);

            StringBuilder message = new StringBuilder(auditEventType.Description);

            foreach (AuditEventValue auditEventValue in auditEvent.Values)
            {
                AuditEventValueType auditEventValueType = _auditEventValueTypeRepository.GetByID(auditEventValue.TypeID);
                if (auditEventValueType.Type == typeof(String))
                {
                    _ = message.Append("; ");
                    _ = message.Append(string.Format("{0}={1}", auditEventValueType.Description, auditEventValue.Value.ToString()));
                }
            }

            // Post message
            _msTeamsREST.PostSimpleMessage(postMessageSettings.Url, "", message.ToString());
        }
Ejemplo n.º 7
0
        public string Format(AuditEvent auditEvent)
        {
            AuditEventType auditEventType = _auditEventTypeRepository.GetByID(auditEvent.EventTypeID);
            StringBuilder  serialized     = new StringBuilder(string.Format("{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}{0}", _delimiter, auditEvent.ID, auditEvent.TimeCreated.ToString("o"), auditEvent.TenantID, auditEvent.UserID, auditEvent.Source, auditEventType.Description));
            int            valueCount     = 0;

            foreach (AuditEventValue auditEventValue in auditEvent.Values)
            {
                AuditEventValueType auditEventValueType = _auditEventValueTypeRepository.GetByID(auditEventValue.TypeID);
                if (auditEventValueType.Type == typeof(String))
                {
                    valueCount++;
                    if (valueCount > 1)
                    {
                        _ = serialized.Append("; ");
                    }
                    _ = serialized.Append(string.Format("{0}={1}", auditEventValueType.Description, auditEventValue.Value.ToString()));
                }
            }
            return(serialized.ToString());
        }
Ejemplo n.º 8
0
        private DataTable GetValuesDataTable(AuditEvent auditEvent, AuditEventType auditEventType, string subEvent, AuditEventValueTypeRepository auditEventValueTypeRepository)
        {
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("Item", typeof(String));
            dataTable.Columns.Add("Value", typeof(String));

            // Add standard header
            AddValuesRow(dataTable, "Time", auditEvent.TimeCreated.ToString());
            AddValuesRow(dataTable, "Event ID", auditEvent.ID);
            AddValuesRow(dataTable, "Event", string.IsNullOrEmpty(subEvent) ? auditEventType.Description : string.Format("{0} - {1}", auditEventType.Description, subEvent));

            // Add other values
            HashSet <int> valueTypesDone = new HashSet <int>()
            {
                AuditEventValueTypes.GamePlanRunID, AuditEventValueTypes.GamePlanPipelineEventID, AuditEventValueTypes.GamePlanAutoBookEventID
            };

            foreach (AuditEventValue auditEventValue in auditEvent.Values)
            {
                if (!valueTypesDone.Contains(auditEventValue.TypeID))   // Ignore values done above
                {
                    AuditEventValueType auditEventValueType = auditEventValueTypeRepository.GetByID(auditEventValue.TypeID);
                    if (!auditEventValueType.Internal)
                    {
                        AuditEventValueConverter auditEventValueConverter = _valueConverters.Find(current => current.Handles(auditEventValue.TypeID));
                        if (auditEventValueConverter != null)
                        {
                            AddValuesRow(dataTable, auditEventValueType.Description, auditEventValueConverter.ValueConverter.Convert(auditEventValue.Value, auditEventValueType.Type, typeof(String)).ToString());
                        }
                        else
                        {
                            AddValuesRow(dataTable, auditEventValueType.Description, auditEventValue.Value.ToString());
                        }
                    }
                }
            }
            return(dataTable);
        }
 public void Update(AuditEventValueType auditEventValueType) => throw new NotImplementedException();