public async Task SaveRowsData(XEventsExportSettings settings, Dictionary<LogBufferItemKey, LogBufferItem> dataFromBuffer)
 {
     using (ClickHouseContext context = new ClickHouseContext(settings.ConnectionString))
     {
         await context.SaveRowsData(dataFromBuffer);
     }
 }
 public IDictionary<string, ExtendedEventsPosition> GetCurrentLogPositions(XEventsExportSettings settings, ExtendedEventsLogBase xEventsLog)
 {
     using (ClickHouseContext context = new ClickHouseContext(settings.ConnectionString))
     {
         return context.GetCurrentLogPositions(xEventsLog);
     }
 }
Exemple #3
0
        private string GetConfigFile()
        {
            // TODO
            // Перенести формирование конфигурационного файла в скрипты CI

            string configFilePath = "appsettings.json";

            if (!File.Exists(configFilePath))
            {
                configFilePath = "travisci-appsettings.json";
                IConfiguration Configuration = new ConfigurationBuilder()
                                               .AddJsonFile(configFilePath, optional: true, reloadOnChange: true)
                                               .Build();
                string connectionString = Configuration.GetConnectionString("EventLogDatabase");
                try
                {
                    using (var context = new ClickHouseContext(connectionString))
                    {
                        var someValue = context.GetHashCode();
                    }
                }
                catch
                {
                    configFilePath = "appveyor-appsettings.json";
                }
            }

            if (!File.Exists(configFilePath))
            {
                throw new Exception("Файл конфигурации не обнаружен.");
            }

            return(configFilePath);
        }
        public void EndsWith()
        {
            // Arrange
            var c = new ClickHouseContext();

            // Act

            // Assert
            c.SimpleEntities.Any(e => e.Text.EndsWith("ipsum")).Should().BeTrue();
        }
        public void ToInt32()
        {
            // Arrange
            var c = new ClickHouseContext();

            // Act
            var v = c.SimpleEntities.Select(e => Convert.ToInt32(e.Text)).Single();

            // Assert
            v.Should().Be(Value);
        }
        public async Task Initialize()
        {
            var context = new ClickHouseContext();
            await context.Database.EnsureCreatedAsync();

            await context.SimpleEntities.AddRangeAsync(
                new SimpleEntity { Id = 1, Text = 1.ToString(), DateTime = DateTime.Now.ToString("yyyy-MM-dd") }
                );

            await context.SaveChangesAsync();
        }
        public void DateTimeParse()
        {
            // Arrange
            var c = new ClickHouseContext();

            // Act
            var v = c.SimpleEntities.Select(e => DateTime.Parse(e.DateTime)).Single();

            // Assert
            v.Should().Be(DateTime.Today);
        }
        public void DoubleParse()
        {
            // Arrange
            var c = new ClickHouseContext();

            // Act
            var v = c.SimpleEntities.Select(e => double.Parse(e.Text)).Single();

            // Assert
            v.Should().Be(Value);
        }
        public async Task Initialize()
        {
            var context = new ClickHouseContext();
            await context.Database.EnsureCreatedAsync();

            await context.SimpleEntities.AddRangeAsync(
                new SimpleEntity { Id = 1, Text = "Lorem ipsum" }
                );

            await context.SaveChangesAsync();
        }
Exemple #10
0
        public void Log10()
        {
            // Arrange
            const double v = 3;
            var          c = new ClickHouseContext();

            // Act
            var log10 = c.SimpleEntities.Select(e => Math.Log10(v)).First();

            // Assert
            log10.Should().BeApproximately(Math.Log10(v), 0.0001);
        }
Exemple #11
0
        public void Exp()
        {
            // Arrange
            const double v = 1;
            var          c = new ClickHouseContext();

            // Act
            var exp = c.SimpleEntities.Select(e => Math.Exp(v)).First();

            // Assert
            exp.Should().BeApproximately(Math.Exp(v), 0.0001);
        }
Exemple #12
0
        public void Pow()
        {
            // Arrange
            const double v = 12;
            var          c = new ClickHouseContext();

            // Act
            var pow = c.SimpleEntities.Select(e => Math.Pow(v, 3)).First();

            // Assert
            pow.Should().BeApproximately(Math.Pow(v, 3), 0.0001);
        }
Exemple #13
0
        public void Atan()
        {
            // Arrange
            const double v = 11;
            var          c = new ClickHouseContext();

            // Act
            var atan = c.SimpleEntities.Select(e => Math.Atan(v)).First();

            // Assert
            atan.Should().BeApproximately(Math.Atan(v), 0.0001);
        }
Exemple #14
0
        public void Cos()
        {
            // Arrange
            const double v = 7;
            var          c = new ClickHouseContext();

            // Act
            var cos = c.SimpleEntities.Select(e => Math.Cos(v)).First();

            // Assert
            cos.Should().BeApproximately(Math.Cos(v), 0.0001);
        }
Exemple #15
0
        public void Sqrt()
        {
            // Arrange
            const double v = 4;
            var          c = new ClickHouseContext();

            // Act
            var sqrt = c.SimpleEntities.Select(e => Math.Sqrt(v)).First();

            // Assert
            sqrt.Should().BeApproximately(Math.Sqrt(v), 0.0001);
        }
        public void AppendDeleteCommandHeader_DeleteEntity_ShouldOverrideDefaultBehavior()
        {
            // Arrange
            var c = new ClickHouseContext();

            // Act
            var s = c.SimpleEntities.First();

            // Assert
            c.SimpleEntities.Remove(s);
            c.SaveChanges();
        }