using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services;
using AsbCloudInfrastructure.Services.Cache;
using AsbCloudInfrastructure.Services.WellOperationService;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    public static class DebugWellOperationImportService
    {
        private static DbContextOptions<AsbCloudDbContext> options = new DbContextOptionsBuilder<AsbCloudDbContext>()
            .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
            .Options;

        public static void Main(/*string[] args*/)
        {
            using var db = new AsbCloudDbContext(options);

            var wellOperationImportService = new WellOperationImportService(db);

            //var inStream = System.IO.File.OpenRead(@"C:\temp\Миграция.xlsx");
            //wellOperationImportService.Import(1, inStream);
            var stream = wellOperationImportService.Export(1);
            var fs = System.IO.File.Create(@"C:\temp\2.xlsx");
            stream.CopyTo(fs);
            fs.Flush();
            fs.Close();
            fs.Dispose();
            Console.WriteLine("_");
        }
    }
}