using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using AsbCloudDb.Model; using AsbCloudDb; using Google.Apis.Drive.v3.Data; using Microsoft.EntityFrameworkCore; using System.Net.Mail; using System.Text.RegularExpressions; using AsbCloudInfrastructure.Services.WellOperationService; using AsbCloudInfrastructure.Services.Cache; using AsbCloudInfrastructure.Services; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Primitives; namespace ConsoleApp1 { //var options = new DbContextOptionsBuilder() // .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") // .Options; //var context = new AsbCloudDbContext(options); class ConfigurationService : IConfigurationSection { public string this[string key] { get => "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True"; set{} } public string Key => ""; public string Path => ""; public string Value { get; set; } = "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True"; public IEnumerable GetChildren() { return null; } public IChangeToken GetReloadToken() { return null; } public IConfigurationSection GetSection(string key) => this; } class Program { static void Main(/*string[] args*/) { var options = new DbContextOptionsBuilder() .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") .Options; var db = new AsbCloudDbContext(options); var cacheDb = new CacheDb(); AsbCloudInfrastructure.DependencyInjection.MapsterSetup(); var configService = new ConfigurationService(); var telemetryTracker = new TelemetryTracker(cacheDb, configService); var timeZoneService = new TimezoneService(); var telemetryService = new TelemetryService(db, telemetryTracker, timeZoneService, cacheDb); var wellService = new WellService(db, cacheDb, telemetryService, timeZoneService); var operationService = new OperationsStatService(db, cacheDb, wellService); var scheduleReportService = new ScheduleReportService(operationService, wellService); var stream = scheduleReportService.MakeReportAsync(44).Result; var outStream = System.IO.File.OpenWrite(@"c:\temp\1.xlsx"); stream.CopyTo(outStream); outStream.Flush(); outStream.Close(); return; //SendMail.Main(); //DbDemoDataService.AddDemoData(); //.GetAwaiter().GetResult(); Console.WriteLine("End of Test"); Console.ReadLine(); //var options = new DbContextOptionsBuilder() // .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") // .Options; //var context = new AsbCloudDbContext(options); //var sett = context.Set(); //var r = context.Database.ExecInsertOrUpdateAsync(sett, new List { // new TelemetryDataSaub // { // Date = DateTime.Now, // IdTelemetry = 3, // AxialLoad = 100.1f, // }, // new TelemetryDataSaub // { // Date = DateTime.Now.AddSeconds(2), // IdTelemetry = 3, // AxialLoad = 100.2f, // }, //}, System.Threading.CancellationToken.None).Result; } } }