コード例 #1
0
        private static EventStatisticsData ConvertToData(EventStatisticsEntry eventStatisticsEntry)
        {
            var statisticsData = new EventStatisticsData();
            var dataType       = typeof(EventStatisticsData);

            foreach (var property in typeof(IEventStatistics).GetProperties())
            {
                var value        = property.GetValue(eventStatisticsEntry, null);
                var dataProperty = dataType.GetProperty(property.Name);
                dataProperty?.SetValue(statisticsData, value, null);
            }

            statisticsData.Count = eventStatisticsEntry.Count;

            return(statisticsData);
        }
コード例 #2
0
        public void InsertOrUpdateStatisticsEntry(EventStatisticsEntry eventStatisticsEntry)
        {
            lock (_lockObjecct)
            {
                var whereClause             = GetStatisticsWhereClause(eventStatisticsEntry, true);
                var query                   = Connection.From <EventStatisticsEntry>().WithSqlFilter(sql => sql + whereClause);
                var existingStatisticsEntry = Connection.Select(query).SingleOrDefault();

                if (existingStatisticsEntry != null)
                {
                    existingStatisticsEntry.Count++;
                    Connection.Update(existingStatisticsEntry);
                }
                else
                {
                    Connection.Insert(eventStatisticsEntry);
                }
            }
        }