Exemple #1
0
        /// <summary>
        /// Retrieves publish history.
        /// </summary>
        /// <param name="processId">The process id.</param>
        /// <param name="numberOfRecords">The number of records.</param>
        /// <returns>The list of DTO objects.</returns>
        public IEnumerable<PublishHistoryDto> FetchPublishHistory(int processId, int numberOfRecords = 10)
        {
            const string Query = @"
SELECT TOP (@count)  Date ,
        Id ,
        IsSuccess ,
        ProcessId ,
        TimeToBuildClientLib ,
        TimeToBuildServerLib ,
        TimeToPublish ,
        TimeToRegisterPublishedCopy ,
        TimeToRetrieve ,
        TimeToUpdateRuntime ,
        TriggeredBy ,
        TriggeredByProcess FROM dbo.PublishHistory
WHERE ProcessId = @processId
ORDER BY Date DESC
";
            var result = new List<PublishHistoryDto>();
            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var connection = ctx.Connection;

                using (var cmd = new SqlCommand(Query, connection))
                {
                    cmd.Parameters.AddWithValue("@count", numberOfRecords);
                    cmd.Parameters.AddWithValue("@processId", processId);

                    using (var reader = new SafeDataReader(cmd.ExecuteReader()))
                    {
                        {
                            while (reader.Read())
                            {
                                var item = new PublishHistoryDto
                                               {
                                                   Date = reader.ReadDateTime(0),
                                                   IsSuccess = reader.GetBool(2),
                                                   ProcessId = reader.GetInt32(3),
                                                   TimeToPublish = reader.GetInt64(6)
                                               };

                                result.Add(item);
                            }
                        }
                    }
                }
            }

            return result;
        }