Beispiel #1
0
 private void Apply(RecentReportCreatedEvent recentReportCreated)
 {
     Name             = recentReportCreated.Name;
     Parameters       = recentReportCreated.Parameters;
     SystemAccountKey = recentReportCreated.SystemAccountKey;
     Assessment       = recentReportCreated.Assessment;
     RunDate          = recentReportCreated.RunDate;
 }
Beispiel #2
0
        /// <summary>
        ///     Handles the message provided.
        /// </summary>
        /// <param name="message">The message to be handled.</param>
        public void Handle(RecentReportCreatedEvent message)
        {
            using (var connection = _connectionFactory.CreateConnection())
            {
                var parametersAssessmentScoreOverTime = message.Parameters as AssessmentScoreOverTimeParameters;

                const string CompleteQuery     = @"SELECT [ReportKey], [SystemAccountKey], [RunDate] 
                                             FROM [OrganizationModule].[RecentReports] 
                                             WHERE SystemAccountKey=@SystemAccountKey 
                                             ORDER BY [RunDate]";
                const int    MaxRows           = 5;
                var          recentReportsDtos = connection.Query <RecentReportsDto> (CompleteQuery, new { message.SystemAccountKey }).ToList();
                if (recentReportsDtos.Count() >= MaxRows)
                {
                    for (var iRow = 0; iRow <= recentReportsDtos.Count() - MaxRows; iRow++)
                    {
                        var reportKey = recentReportsDtos.ElementAt(iRow).ReportKey;
                        connection.Execute("DELETE FROM [OrganizationModule].[RecentReports] WHERE ReportKey='" + reportKey + "'");
                    }
                }
                Guid?patientKey = null;
                if (parametersAssessmentScoreOverTime != null)
                {
                    patientKey = parametersAssessmentScoreOverTime.PatientKey;
                }
                connection.Execute(
                    "INSERT INTO OrganizationModule.RecentReports " +
                    "VALUES(@ReportKey, @SystemAccountKey, @Name, @Assessment, @RunDate, @PatientKey, @OrganizationKey)",
                    new
                {
                    ReportKey = message.Key,
                    message.SystemAccountKey,
                    message.Name,
                    message.Assessment,
                    message.RunDate,
                    patientKey,
                    message.OrganizationKey,
                });
            }
        }