/// <summary>
        /// Handles the specified @event.
        /// </summary>
        /// <param name="event">The @event.</param>
        /// <returns></returns>
        public async Task Handle(TrialAddedEvent @event)
        {
            try
            {
                Scenario scenario = await this._scenarioService.GetScenario(@event.ScenarioId);

                List <EventDto> events         = @event.Events.OrderBy(e => e.Timestamp).ToList();
                int             currentTarget  = 1;
                EventDto        taskStartEvent = null;

                foreach (EventDto eventDto in events)
                {
                    if (taskStartEvent == null)
                    {
                        taskStartEvent = eventDto;
                    }

                    if (taskStartEvent != null && eventDto.Name == "MOUSE_CLICKED")
                    {
                        dynamic       taskStartProperties = taskStartEvent.Properties;
                        dynamic       eventProperties     = eventDto.Properties;
                        AssetQueryDto asset = scenario.Assets.First(a => a.Tag == $"Target {currentTarget}");

                        float distance = Vector2.Distance(
                            new Vector2((float)taskStartProperties.MouseX, (float)taskStartProperties.MouseY),
                            new Vector2((float)eventProperties.MouseX, (float)eventProperties.MouseY));
                        float width        = asset.Scale.X / 2.0f;
                        long  milliseconds = eventDto.Timestamp - taskStartEvent.Timestamp;

                        TrialAnalysis analysis = new TrialAnalysis
                        {
                            Distance     = distance,
                            Width        = width,
                            Milliseconds = milliseconds,
                            TrialId      = @event.TrialId,
                            UserId       = @event.UserId
                        };

                        await this._repository.Add(analysis);

                        taskStartEvent = null;
                    }
                }
            }
            catch (Exception ex)
            {
                this._logger.LogError(0, ex, ex.Message);
                throw;
            }
        }
        /// <summary>
        /// Adds the specified analysis.
        /// </summary>
        /// <param name="analysis">The analysis.</param>
        /// <returns></returns>
        public async Task Add(TrialAnalysis analysis)
        {
            using (SqlConnection connection = new SqlConnection(this._connectionString))
            {
                await connection.OpenAsync();

                string query = @"INSERT INTO trials VALUES (@TrialId, @UserId, @Distance, @Width, @Speed);";
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.Parameters.AddWithValue("@TrialId", analysis.TrialId);
                    command.Parameters.AddWithValue("@UserId", analysis.UserId);
                    command.Parameters.AddWithValue("@Distance", analysis.Distance);
                    command.Parameters.AddWithValue("@Width", analysis.Width);
                    command.Parameters.AddWithValue("@Speed", analysis.Milliseconds);

                    await command.ExecuteNonQueryAsync();
                }
            }
        }