using AsbCloudApp.Data.DailyReport;
using ClosedXML.Excel;

namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks
{
    class TimeBalanceBlock : BlockAbstract
    {
        private readonly TimeBalanceDto blockDto;
        public CellAddress AddressTitle { get; }        
		public CellAddress AddressDrilling { get; set; }
        public CellAddress AddressFlushing { get; set; }
        public CellAddress AddressBuilding { get; set; }
        public CellAddress AddressElaboration { get; set; }
        public CellAddress AddressExtension { get; set; }
        public CellAddress AddressRepair { get; set; }
        public CellAddress AddressDrillingValue { get; set; }
        public CellAddress AddressFlushingValue { get; set; }
        public CellAddress AddressBuildingValue { get; set; }
        public CellAddress AddressElaborationValue { get; set; }
        public CellAddress AddressExtensionValue { get; set; }
        public CellAddress AddressRepairValue { get; set; }
        public CellAddress AddressKnbk { get; set; }
        public CellAddress AddressSpo { get; set; }
        public CellAddress AddressPzr { get; set; }
        public CellAddress AddressPvo { get; set; }
        public CellAddress AddressPgr { get; set; }
        public CellAddress AddressGis { get; set; }
        public CellAddress AddressKnbkValue { get; set; }
        public CellAddress AddressSpoValue { get; set; }
        public CellAddress AddressPzrValue { get; set; }
        public CellAddress AddressPvoValue { get; set; }
        public CellAddress AddressPgrValue { get; set; }
        public CellAddress AddressGisValue { get; set; }
		public CellAddress AddressOzc { get; set; }
        public CellAddress AddressEngineeringWorks { get; set; }
        public CellAddress AddressTakingMeasure { get; set; }
        public CellAddress AddressCementing { get; set; }
        public CellAddress AddressSimple { get; set; }
        public CellAddress AddressNpv { get; set; }
        public CellAddress AddressOzcValue { get; set; }
        public CellAddress AddressEngineeringWorksValue { get; set; }
        public CellAddress AddressTakingMeasureValue { get; set; }
        public CellAddress AddressCementingValue { get; set; }
        public CellAddress AddressSimpleValue { get; set; }
        public CellAddress AddressNpvValue { get; set; }
        public CellAddress[] AddressPeriodTableDataArray { get; }
        public override CellAddress AddressBlockBegin { get; }
        public override CellAddress AddressBlockEnd { get; }

        public TimeBalanceBlock(CellAddress addressBlockBegin, TimeBalanceDto blockDto)
        {
            AddressBlockBegin = addressBlockBegin.Copy();
            this.blockDto = blockDto;
            AddressTitle = addressBlockBegin + (1, 3);
            AddressDrilling = addressBlockBegin + (2, 1);
            AddressFlushing = addressBlockBegin + (3, 1);
            AddressBuilding = addressBlockBegin + (4, 1);
            AddressElaboration = addressBlockBegin + (5, 1);
            AddressExtension = addressBlockBegin + (6, 1);
            AddressRepair = addressBlockBegin + (7, 1);
            AddressDrillingValue = addressBlockBegin + (2, 2);
            AddressFlushingValue = addressBlockBegin + (3, 2);
            AddressBuildingValue = addressBlockBegin + (4, 2);
            AddressElaborationValue = addressBlockBegin + (5, 2);
            AddressExtensionValue = addressBlockBegin + (6, 2);
            AddressRepairValue = addressBlockBegin + (7, 2);
            AddressKnbk = addressBlockBegin + (2, 3);
            AddressSpo = addressBlockBegin + (3, 3);
            AddressPzr = addressBlockBegin + (4, 3);
            AddressPvo = addressBlockBegin + (5, 3);
            AddressPgr = addressBlockBegin + (6, 3);
            AddressGis = addressBlockBegin + (7, 3);
            AddressKnbkValue = addressBlockBegin + (2, 4);
            AddressSpoValue = addressBlockBegin + (3, 4);
            AddressPzrValue = addressBlockBegin + (4, 4);
            AddressPvoValue = addressBlockBegin + (5, 4);
            AddressPgrValue = addressBlockBegin + (6, 4);
            AddressGisValue = addressBlockBegin + (7, 4);
            AddressOzc = addressBlockBegin + (2, 5);
            AddressEngineeringWorks = addressBlockBegin + (3, 5);
            AddressTakingMeasure = addressBlockBegin + (4, 5);
            AddressCementing = addressBlockBegin + (5, 5);
            AddressSimple = addressBlockBegin + (6, 5);
            AddressNpv = addressBlockBegin + (7, 5);
            AddressOzcValue = addressBlockBegin + (2, 6);
            AddressEngineeringWorksValue = addressBlockBegin + (3, 6);
            AddressTakingMeasureValue = addressBlockBegin + (4, 6);
            AddressCementingValue = addressBlockBegin + (5, 6);
            AddressSimpleValue = addressBlockBegin + (6, 6);
            AddressNpvValue = addressBlockBegin + (7, 6);
            AddressBlockEnd = AddressNpvValue;
        }

        public override void Draw(IXLWorksheet sheet)
        {
             sheet.Range(AddressTitle.RowNumber, AddressTitle.ColumnNumber, AddressTitle.RowNumber, AddressTitle.ColumnNumber + 1)
                .Merge()
               .SetValue("БАЛАНС ВРЕМЕНИ");
            sheet.Cell(AddressDrilling)
               ._SetValue("Бурение", true);
            sheet.Cell(AddressFlushing)
               ._SetValue("Промывка", true);
            sheet.Cell(AddressBuilding)
               ._SetValue("Наращивание", true);
            sheet.Cell(AddressElaboration)
               ._SetValue("Проработка", true);
            sheet.Cell(AddressExtension)
               ._SetValue("Расширка", true);
            sheet.Cell(AddressRepair)
               ._SetValue("Ремонт", true);
            sheet.Cell(AddressDrillingValue)
               ._SetValue($"{blockDto.Drilling}");
            sheet.Cell(AddressFlushingValue)
               ._SetValue($"{blockDto.Flushing}");
            sheet.Cell(AddressBuildingValue)
               ._SetValue($"{blockDto.Building}");
            sheet.Cell(AddressElaborationValue)
               ._SetValue($"{blockDto.Elaboration}");
            sheet.Cell(AddressExtensionValue)
               ._SetValue($"{blockDto.Extension}");
            sheet.Cell(AddressRepairValue)
               ._SetValue($"{blockDto.Repair}");
            sheet.Cell(AddressKnbk)
               ._SetValue("КНБК");
            sheet.Cell(AddressSpo)
               ._SetValue("СПО");
            sheet.Cell(AddressPzr)
               ._SetValue("ПЗР");
            sheet.Cell(AddressPvo)
               ._SetValue("ПВО");
            sheet.Cell(AddressPgr)
               ._SetValue("ПГР");
            sheet.Cell(AddressGis)
               ._SetValue("ГИС");
            sheet.Cell(AddressKnbkValue)
               ._SetValue($"{blockDto.Knbk}");
            sheet.Cell(AddressSpoValue)
               ._SetValue($"{blockDto.Spo}");
            sheet.Cell(AddressPzrValue)
               ._SetValue($"{blockDto.Pzr}");
            sheet.Cell(AddressPvoValue)
               ._SetValue($"{blockDto.Pvo}");
            sheet.Cell(AddressPgrValue)
               ._SetValue($"{blockDto.Pgr}");
            sheet.Cell(AddressGisValue)
               ._SetValue($"{blockDto.Gis}");
            sheet.Cell(AddressOzc)
               ._SetValue("ОЗЦ");
            sheet.Cell(AddressEngineeringWorks)
               ._SetValue("Тех. работы");
            sheet.Cell(AddressTakingMeasure)
               ._SetValue("Снятие замера");
            sheet.Cell(AddressCementing)
               ._SetValue("Цементирование");
            sheet.Cell(AddressSimple)
               ._SetValue("Простой");
            sheet.Cell(AddressNpv)
               ._SetValue("НПВ");
            sheet.Cell(AddressOzcValue)
               ._SetValue($"{blockDto.Ozc}");
            sheet.Cell(AddressEngineeringWorksValue)
               ._SetValue($"{blockDto.EngineeringWorks}");
            sheet.Cell(AddressTakingMeasureValue)
               ._SetValue($"{blockDto.TakingMeasure}");
            sheet.Cell(AddressCementingValue)
               ._SetValue($"{blockDto.Cementing}");
            sheet.Cell(AddressSimpleValue)
               ._SetValue($"{blockDto.Simple}");
            sheet.Cell(AddressNpvValue)
               ._SetValue($"{blockDto.Npv}");
        }
    }

}