コード例 #1
0
 public async Task Save(List <XEventData> eventsData)
 {
     using (var context = new ClickHouseContext(_connectionString))
     {
         await context.SaveRowsData(_xEventsLog, eventsData);
     }
 }
コード例 #2
0
        public async Task Save(IList <XEventData> eventsData)
        {
            using (var context = new ClickHouseContext(_connectionString))
            {
                List <XEventData> newEntities = new List <XEventData>();
                foreach (var itemRow in eventsData)
                {
                    if (itemRow == null)
                    {
                        continue;
                    }

                    if (!_maxPeriodsByFiles.TryGetValue(itemRow.FileName, out var maxPeriod))
                    {
                        maxPeriod = await context.GetRowsDataMaxPeriod(itemRow.FileName);

                        _maxPeriodsByFiles.Add(itemRow.FileName, maxPeriod);
                    }

                    if (maxPeriod != DateTime.MinValue)
                    {
                        if (itemRow.Timestamp.DateTime < maxPeriod)
                        {
                            continue;
                        }

                        if (itemRow.Timestamp.DateTime == maxPeriod)
                        {
                            if (await context.RowDataExistOnDatabase(itemRow.FileName, itemRow))
                            {
                                continue;
                            }
                        }
                    }

                    newEntities.Add(itemRow);
                }
                await context.SaveRowsData(newEntities);
            }
        }