using AsbCloudApp.Data.DailyReport; using ClosedXML.Excel; namespace AsbCloudInfrastructure.Services.DailyReport.DailyReportBlocks { class BhaBlock : BlockAbstract { private readonly BhaDto blockDto; public CellAddress AddressBhaDescription { get; } public CellAddress AddressOperationTitle { get; } public CellAddress AddressDurationTitle { get; } public CellAddress AddressTotalTitle { get; } public CellAddress[] AddressOperationData { get; } public CellAddress[] AddressDurationDataStart { get; } public CellAddress[] AddressDurationDataFinish { get; } public CellAddress[] AddressTotaData { get; } public override CellAddress AddressBlockBegin { get; } public override CellAddress AddressBlockEnd { get; } public BhaBlock(CellAddress addressBlockBegin, BhaDto blockDto) { this.blockDto = blockDto; AddressBlockBegin = addressBlockBegin.Copy(); AddressBhaDescription = addressBlockBegin + (1,0); AddressOperationTitle = addressBlockBegin + (3, 0); AddressDurationTitle = addressBlockBegin + (3, 5); AddressTotalTitle = addressBlockBegin + (3, 7); AddressOperationData = new CellAddress[5]; AddressOperationData[0] = addressBlockBegin + (4, 0); AddressOperationData[1] = addressBlockBegin + (5, 0); AddressOperationData[2] = addressBlockBegin + (6, 0); AddressOperationData[3] = addressBlockBegin + (7, 0); AddressOperationData[4] = addressBlockBegin + (8, 0); AddressDurationDataStart = new CellAddress[5]; AddressDurationDataStart[0] = addressBlockBegin + (4, 5); AddressDurationDataStart[1] = addressBlockBegin + (5, 5); AddressDurationDataStart[2] = addressBlockBegin + (6, 5); AddressDurationDataStart[3] = addressBlockBegin + (7, 5); AddressDurationDataStart[4] = addressBlockBegin + (8, 5); AddressDurationDataFinish = new CellAddress[5]; AddressDurationDataFinish[0] = addressBlockBegin + (4, 6); AddressDurationDataFinish[1] = addressBlockBegin + (5, 6); AddressDurationDataFinish[2] = addressBlockBegin + (6, 6); AddressDurationDataFinish[3] = addressBlockBegin + (7, 6); AddressDurationDataFinish[4] = addressBlockBegin + (8, 6); AddressTotaData = new CellAddress[5]; AddressTotaData[0] = addressBlockBegin + (4, 7); AddressTotaData[1] = addressBlockBegin + (5, 7); AddressTotaData[2] = addressBlockBegin + (6, 7); AddressTotaData[3] = addressBlockBegin + (7, 7); AddressTotaData[4] = addressBlockBegin + (8, 7); AddressBlockEnd = AddressTotaData[4]; } private string FormulaBhaBlock(CellAddress beginTime, CellAddress endTime) { return string.Format("IF({0}>0,({0}-{1})*24, \"\")", endTime.ToString(), beginTime.ToString()); } public override void Draw(IXLWorksheet sheet) { sheet._Range(AddressBhaDescription, AddressBhaDescription + (0, 7)) ._SetValue($"{blockDto.BHADescription}"); sheet._Range(AddressOperationTitle, AddressOperationTitle + (0, 4)) ._SetValue("Выполняемые операции в отчетный период, комментарии:"); sheet._Range(AddressDurationTitle, AddressDurationTitle + (0, 1)) ._SetValue("Продолжительность, ч. "); sheet.Cell(AddressTotalTitle) ._SetValue("Итого"); sheet._Range(AddressOperationData[0], AddressOperationData[0] + (0, 4)) ._SetValue("Бурение с наращиваниями в инт. 2195-2763м."); sheet.Cell(AddressDurationDataStart[0]) ._SetValue($"{blockDto.ExtensionDrillingOneBegin}"); sheet.Cell(AddressDurationDataFinish[0]) ._SetValue($"{blockDto.ExtensionDrillingOneFinish}"); sheet.Cell(AddressTotaData[0]) .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[0], AddressDurationDataFinish[0])}").Style.SetAllBorders(); sheet._Range(AddressOperationData[1], AddressOperationData[1] + (0, 4)) ._SetValue("Промывка."); sheet.Cell(AddressDurationDataStart[1]) ._SetValue($"{blockDto.SluiceBegin}"); sheet.Cell(AddressDurationDataFinish[1]) ._SetValue($"{blockDto.SluiceFinish}"); sheet.Cell(AddressTotaData[1]) .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[1], AddressDurationDataFinish[1])}").Style.SetAllBorders(); sheet._Range(AddressOperationData[2], AddressOperationData[2] + (0, 4)) ._SetValue("Подъем КНБК в инт. 2763-2442м."); sheet.Cell(AddressDurationDataStart[2]) ._SetValue($"{blockDto.ClimbBegin}"); sheet.Cell(AddressDurationDataFinish[2]) ._SetValue($"{blockDto.ClimbFinish}"); sheet.Cell(AddressTotaData[2]) .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[2], AddressDurationDataFinish[2])}").Style.SetAllBorders(); sheet._Range(AddressOperationData[3], AddressOperationData[3] + (0, 4)) ._SetValue("Спуск КНБК в инт. 2442-2763м."); sheet.Cell(AddressDurationDataStart[3]) ._SetValue($"{blockDto.DescentBegin}"); sheet.Cell(AddressDurationDataFinish[3]) ._SetValue($"{blockDto.DescentFinish}"); sheet.Cell(AddressTotaData[3]) .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[3], AddressDurationDataFinish[3])}").Style.SetAllBorders(); sheet._Range(AddressOperationData[4], AddressOperationData[4] + (0, 4)) ._SetValue("Бурение с наращиваниями в инт. 2763-2850м."); sheet.Cell(AddressDurationDataStart[4]) ._SetValue($"{blockDto.ExtensionDrillingTwoBegin}"); sheet.Cell(AddressDurationDataFinish[4]) ._SetValue($"{blockDto.ExtensionDrillingTwoFinish}"); sheet.Cell(AddressTotaData[4]) .SetFormulaA1($"{FormulaBhaBlock(AddressDurationDataStart[4], AddressDurationDataFinish[4])}").Style.SetAllBorders(); } } }