using AsbCloudApp.Data;
using AsbCloudApp.Data.DailyReport;
using AsbCloudInfrastructure.Services.DailyReport;
using ClosedXML.Excel;
using System;
using System.IO;


namespace ConsoleApp1
{

    class Program
    {
        // use ServiceFactory to make services
        static void Main(/*string[] args*/)
        {
            

            var block = new HeadDto()
            {
                AzimuthAngle = 12,
                WellName = "WellName",
                ClusterName = "clusterName",
                Customer = "customer",
                Contractor = "Contractor",
                ReportDate = DateTime.Now,
                WellDepthIntervalFinishDate = 27.5,
                WellDepthIntervalStartDate = 26.5,
                BottomholeDepth = 66.6
            };
            var block2 = new BhaDto()
            {
                BHADescription = "sadasdasdasdasdasdjlaskjdaksjdlasdlalskdklj"
            };
            var block3 = new SaubDto();
            var bloks = new DailyReportDto()
            {
                Head = block,
                Saub = block3
            };



            var service = new DailyReportMakerExcel();
            var stream = service.MakeReportFromBlocks(bloks);
            var filename = "____.xlsx";
            if (File.Exists(filename))
                File.Delete(filename);
            using var fileStream = File.OpenWrite(filename);
            stream.CopyTo(fileStream);

            return;
           





            //var ms = MakeReportFromBlocks(block,block3);
            ////File.Create("", MakeReportFromBlocks(block));
            //using var file = new FileStream("file.xlsx", FileMode.Create, System.IO.FileAccess.Write);
            //byte[] bytes = new byte[ms.Length];
            //ms.Read(bytes, 0, (int)ms.Length);
            //file.Write(bytes, 0, bytes.Length);
            //ms.Close();
        }




    }
}