Example #1
0
 private void MarkFlags(TVALUES_DB watts, ExtendedXlsFile xls, int col)
 {
     //есть ОВ
     if ((watts.F_FLAG & (VALUES_FLAG_DB.None | VALUES_FLAG_DB.IsOVReplaced)) ==
         (VALUES_FLAG_DB.None | VALUES_FLAG_DB.IsOVReplaced))
     {
         xls.SetCellFontColor(UsedRows, col, IsOVReplacedColor);
         xls.SetCellFontColor(UsedRows, col, IsOVReplacedColor);
         InternalData.FlagOVremark = true;
     }
     // нет данных
     if ((watts.F_FLAG & VALUES_FLAG_DB.DataNotFull) == VALUES_FLAG_DB.DataNotFull)
     {
         xls.SetCellBkColor(UsedRows, col, NoDataColor);
         InternalData.FlNoData = true;
     }
     // статус менялся вручную
     if (((watts.F_FLAG & VALUES_FLAG_DB.NotCorrect) == VALUES_FLAG_DB.NotCorrect) &&
         ((watts.F_FLAG & VALUES_FLAG_DB.isManualStatusChanged) ==
          VALUES_FLAG_DB.isManualStatusChanged))
     {
         xls.SetCellBkColor(UsedRows, col, IsManualStatusChangeColor);
         InternalData.FlagManualStatusChange = true;
     }
 }
        protected override void RenderFooter(ExtendedXlsFile xls)
        {
            UsedRows++;
            xls.SetCellValueStyled(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName], "Всего по " + Data.Name, TFlxFontStyles.Bold);
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);

            RenderSummaryBehavior behav = new RenderSummaryBehavior(this, TFlxFontStyles.Bold);

            behav.RenderSummary(xls, GetInnerFirstEntryFormulas);
            if (Data.IsGroupUseInGeneralBalance)
            {
                behav.AddSummaryFormulas(xls, GetInnerFirstEntryFormulas);
            }

            if (Data.IsGroupUseInRelative)
            {
                UsedCols = InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1;
                for (int i = 0; i < InternalData.NumbersValues; i++)
                {
                    UsedCols++;
                    AddCellToFormula(InternalData.IntervalFormulUids[i].SummBalPartSaldoForLossesDivider,
                                     UsedCols + 2, GetUsedRows(), GetInnerFirstEntryFormulas(InternalData.IntervalFormulUids[i].SummSaldoForPs).DoubleRepresentation(), Model.Formula.EnumExcelFormulaOperators.Minus);
                    UsedCols++;
                    UsedCols++;
                }
            }

            SetBorderAllCellsInBlock(xls, Color.Gray, TFlxBorderStyle.Dotted);
        }
Example #3
0
        public void RenderSummary(ExtendedXlsFile xls, Func <Guid, ExcelFormula> getInnerFirstEntryFormulas)
        {
            int currentCol = block.InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1;

            for (int i = 0; i < block.InternalData.NumbersValues; i++)
            {
                currentCol++;
                xls.SetFormulaStyled(block.GetUsedRows(),
                                     currentCol,
                                     getInnerFirstEntryFormulas(block.InternalData.IntervalFormulUids[i].SummInForPs),
                                     style);
                block.AddCellToFormula(block.InternalData.IntervalFormulUids[i].SummInForPs, currentCol, block.GetUsedRows(),
                                       getInnerFirstEntryFormulas(block.InternalData.IntervalFormulUids[i].SummInForPs).DoubleRepresentation(),
                                       Model.Formula.EnumExcelFormulaOperators.Plus);
                xls.SetFormulaStyled(block.GetUsedRows(),
                                     currentCol + 1,
                                     getInnerFirstEntryFormulas(block.InternalData.IntervalFormulUids[i].SummOutForPs),
                                     style);
                block.AddCellToFormula(block.InternalData.IntervalFormulUids[i].SummOutForPs, currentCol + 1, block.GetUsedRows(),
                                       getInnerFirstEntryFormulas(block.InternalData.IntervalFormulUids[i].SummOutForPs).DoubleRepresentation(),
                                       Model.Formula.EnumExcelFormulaOperators.Plus);
                xls.SetFormulaStyled(block.GetUsedRows(),
                                     currentCol + 2,
                                     getInnerFirstEntryFormulas(block.InternalData.IntervalFormulUids[i].SummSaldoForPs),
                                     style);
                block.AddCellToFormula(block.InternalData.IntervalFormulUids[i].SummSaldoForPs, currentCol + 2, block.GetUsedRows(),
                                       getInnerFirstEntryFormulas(block.InternalData.IntervalFormulUids[i].SummSaldoForPs).DoubleRepresentation(),
                                       Model.Formula.EnumExcelFormulaOperators.Plus);

                currentCol++;
                currentCol++;
            }
        }
        protected override void RenderBody(ExtendedXlsFile xls)
        {
            UsedRows = Parent.GetUsedRows() + 1;
            StartRow = UsedRows;
            StartCol = NestingLevel;

            xls.SetCellValue(UsedRows, NestingLevel, Data);
            xls.MergeCells(UsedRows, NestingLevel, UsedRows, InternalData.TotalColumnsCount);
        }
Example #5
0
        protected override void RenderBody(ExtendedXlsFile xls)
        {
            StartRow = Parent.GetUsedRows() + 1;
            UsedRows = StartRow;
            StartCol = NestingLevel;
            UsedCols = Parent.GetUsedCols();

            xls.SetCellValue(UsedRows, NestingLevel, Data);
            xls.MergeCells(UsedRows, NestingLevel, UsedRows, UsedCols);
        }
Example #6
0
 protected override void RenderFooter(ExtendedXlsFile xls)
 {
     if (InternalData.ExportType == TExportExcelAdapterType.toHTML)
     {
         xls.AutofitCols(0.99f);
     }
     else
     {
         xls.AutofitCols(1.28f);
     }
 }
        protected override void RenderBody(ExtendedXlsFile xls)
        {
            StartRow = Parent.GetUsedRows() + 1;
            UsedRows = StartRow;
            StartCol = InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName];
            UsedCols = Parent.GetUsedCols();

            xls.SetCellValue(UsedRows,
                             InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                             Data.Name, InternalData.GetSectionNameFormat(xls));
            xls.MergeCells(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows, UsedCols);
        }
        protected override void RenderFooter(ExtendedXlsFile xls)
        {
            xls.SetRowOutlineLevel(StartRow + 1, UsedRows, 1);

            UsedRows++;
            xls.SetCellValueStyled(UsedRows, NestingLevel, "Итого по " + Data, TFlxFontStyles.Bold);
            xls.MergeCells(UsedRows, NestingLevel, UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);

            RenderSummaryBehavior behav = new RenderSummaryBehavior(this, TFlxFontStyles.Bold);

            behav.RenderSummary(xls, GetInnerFirstEntryFormulas);
            behav.AddSummaryFormulas(xls, GetInnerFirstEntryFormulas);
        }
Example #9
0
        public void RenderSummary(ExtendedXlsFile xls, Func <Guid, ExcelFormula> getInnerFirstEntryFormulas)
        {
            if (getInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330InputSummary.GetFormulaUid()).Elements.Count > 0)
            {
                xls.SetFormulaStyled(block.GetUsedRows(),
                                     block.InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm],
                                     getInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330InputSummary.GetFormulaUid()),
                                     style);
            }

            if (getInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330OutputSummary.GetFormulaUid()).Elements.Count > 0)
            {
                xls.SetFormulaStyled(block.GetUsedRows(),
                                     block.InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm],
                                     getInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330OutputSummary.GetFormulaUid()),
                                     style);
            }

            if (getInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330SaldoSummary.GetFormulaUid()).Elements.Count > 0)
            {
                xls.SetFormulaStyled(block.GetUsedRows(),
                                     block.InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm],
                                     getInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330SaldoSummary.GetFormulaUid()),
                                     style);
            }

            //TODO: дублирование
            foreach (var voltage in block.InternalData.HeaderInputColumnNumbers)
            {
                if (getInnerFirstEntryFormulas(voltage.Value.FormulaUid).Elements.Count > 0)
                {
                    xls.SetFormulaStyled(block.GetUsedRows(),
                                         voltage.Value.ColumnNumber,
                                         getInnerFirstEntryFormulas(voltage.Value.FormulaUid),
                                         style);
                }
            }
            //TODO: дублирование
            foreach (var voltage in block.InternalData.HeaderOutputColumnNumbers)
            {
                if (getInnerFirstEntryFormulas(voltage.Value.FormulaUid).Elements.Count > 0)
                {
                    xls.SetFormulaStyled(block.GetUsedRows(),
                                         voltage.Value.ColumnNumber,
                                         getInnerFirstEntryFormulas(voltage.Value.FormulaUid),
                                         style);
                }
            }
        }
Example #10
0
        protected override void RenderBody(ExtendedXlsFile xls)
        {
            StartRow = Parent.GetUsedRows() + 1;
            UsedRows = StartRow;
            StartCol = NestingLevel;

            xls.SetCellValue(UsedRows, StartCol, Data.Name);

            if (StartCol < InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1)
            {
                xls.MergeCells(UsedRows, StartCol, UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);
            }

            UsedCols = InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1;

            for (int i = 0; i < InternalData.NumbersValues; i++)
            {
                UsedCols++;
                if (i < Data.InputInterval.Count)
                {
                    xls.SetCellFloatValue(UsedRows, UsedCols, Data.InputInterval[i].F_VALUE);
                    AddCellToFormula(InternalData.IntervalFormulUids[i].SummInForPs, UsedCols, UsedRows, Data.InputInterval[i].F_VALUE, EnumExcelFormulaOperators.Plus);
                    AddCellToFormula(InternalData.IntervalFormulUids[i].SaldoByTi, UsedCols, UsedRows, Data.InputInterval[i].F_VALUE, EnumExcelFormulaOperators.Plus);

                    MarkFlags(Data.InputInterval[i], xls, UsedCols);
                    MarkFlags(Data.InputInterval[i], xls, UsedCols + 2);
                }

                if (i < Data.OutputInterval.Count)
                {
                    xls.SetCellFloatValue(UsedRows, UsedCols + 1, Data.OutputInterval[i].F_VALUE);
                    AddCellToFormula(InternalData.IntervalFormulUids[i].SummOutForPs, UsedCols + 1, UsedRows, Data.OutputInterval[i].F_VALUE, EnumExcelFormulaOperators.Plus);
                    AddCellToFormula(InternalData.IntervalFormulUids[i].SaldoByTi, UsedCols + 1, UsedRows, Data.OutputInterval[i].F_VALUE, EnumExcelFormulaOperators.Minus);
                    MarkFlags(Data.OutputInterval[i], xls, UsedCols + 1);
                    MarkFlags(Data.OutputInterval[i], xls, UsedCols + 2);
                }

                if (i < Data.InputInterval.Count || i < Data.OutputInterval.Count)
                {
                    xls.SetFormula(UsedRows, UsedCols + 2, GetFormula(InternalData.IntervalFormulUids[i].SaldoByTi));
                    AddCellToFormula(InternalData.IntervalFormulUids[i].SummSaldoForPs, UsedCols + 2, UsedRows,
                                     GetFormula(InternalData.IntervalFormulUids[i].SaldoByTi).DoubleRepresentation(), EnumExcelFormulaOperators.Plus);
                }

                UsedCols++;
                UsedCols++;
            }
        }
Example #11
0
        public void AddSummaryFormulas(ExtendedXlsFile xls, Func <Guid, ExcelFormula> getInnerFirstEntryFormulas)
        {
            block.AddCellToFormula(FormulaNamesEnum.Balance220330InputSummary.GetFormulaUid(),
                                   block.InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm],
                                   block.GetUsedRows(),
                                   getInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330InputSummary.GetFormulaUid()).DoubleRepresentation(),
                                   EnumExcelFormulaOperators.Plus);

            block.AddCellToFormula(FormulaNamesEnum.Balance220330OutputSummary.GetFormulaUid(),
                                   block.InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm],
                                   block.GetUsedRows(),
                                   getInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330OutputSummary.GetFormulaUid()).DoubleRepresentation(),
                                   EnumExcelFormulaOperators.Plus);

            block.AddCellToFormula(FormulaNamesEnum.Balance220330SaldoSummary.GetFormulaUid(),
                                   block.InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm],
                                   block.GetUsedRows(),
                                   getInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330SaldoSummary.GetFormulaUid()).DoubleRepresentation(),
                                   EnumExcelFormulaOperators.Plus);

            foreach (var voltage in block.InternalData.HeaderInputColumnNumbers)
            {
                if (getInnerFirstEntryFormulas(voltage.Value.FormulaUid).Elements.Count > 0)
                {
                    block.AddCellToFormula(voltage.Value.FormulaUid,
                                           voltage.Value.ColumnNumber,
                                           block.GetUsedRows(),
                                           getInnerFirstEntryFormulas(voltage.Value.FormulaUid).DoubleRepresentation(),
                                           EnumExcelFormulaOperators.Plus);
                }
            }

            foreach (var voltage in block.InternalData.HeaderOutputColumnNumbers)
            {
                if (getInnerFirstEntryFormulas(voltage.Value.FormulaUid).Elements.Count > 0)
                {
                    block.AddCellToFormula(voltage.Value.FormulaUid,
                                           voltage.Value.ColumnNumber,
                                           block.GetUsedRows(),
                                           getInnerFirstEntryFormulas(voltage.Value.FormulaUid).DoubleRepresentation(),
                                           EnumExcelFormulaOperators.Plus);
                }
            }
        }
Example #12
0
        protected override void RenderBody(ExtendedXlsFile xls)
        {
            InternalData.Initialize(GetMaxParentMaxNestingLevel(), Data.VoltageClassPoints);

            TFlxFormat getDefaultFormat = xls.GetDefaultFormat;
            int        formatIndex      = xls.DefaultFormatId;

            xls.ActiveSheet = 1;
            if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
            {
                //getDefaultFormat.Font.Name = "Times New Roman";
                getDefaultFormat.Font.Size20 = 188;
            }
            else
            {
                getDefaultFormat.Font.Size20 = 212;
            }
            xls.SetFormat(formatIndex, getDefaultFormat);
        }
        protected override void RenderBody(ExtendedXlsFile xls)
        {
            StartCol = InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName];
            StartRow = 1;
            UsedRows = 1;

            UsedCols = InternalData.TotalColumnsCount;

            xls.SetCellValueStyled(UsedRows, 1,
                                   Data.Name
                                   + " \n " +
                                   Data.DateRepresentation,
                                   TFlxFontStyles.Bold);
            if (xls.CurrentExportType != TExportExcelAdapterType.toXLS)
            {
                xls.SetCellAlignH(UsedRows, 1, THFlxAlignment.center);
            }
            xls.MergeCells(UsedRows, 1, UsedRows + 1, UsedCols);
            UsedRows++;
        }
        protected override void RenderFooter(ExtendedXlsFile xls)
        {
            UsedRows++;
            xls.SetCellValueStyled(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName], "Всего по " + Data.Name, TFlxFontStyles.Bold);
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);

            RenderSummaryBehavior behav = new RenderSummaryBehavior(this, TFlxFontStyles.Bold);

            behav.RenderSummary(xls, GetInnerFirstEntryFormulas);
            if (Data.IsGroupUseInGeneralBalance)
            {
                behav.AddSummaryFormulas(xls, GetInnerFirstEntryFormulas);
            }

            if (Data.IsGroupUseInRelative)
            {
                AddCellToFormula(FormulaNamesEnum.Balance220330RelativeLosses.GetFormulaUid(),
                                 InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm],
                                 UsedRows,
                                 GetInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330SaldoSummary.GetFormulaUid()).DoubleRepresentation(), EnumExcelFormulaOperators.Minus);
            }

            AddCellToFormula(FormulaNamesEnum.Balance220330AllOutputSummary.GetFormulaUid(),
                             InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm],
                             GetUsedRows(),
                             GetInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330OutputSummary.GetFormulaUid()).DoubleRepresentation(),
                             EnumExcelFormulaOperators.Plus);

            AddCellToFormula(FormulaNamesEnum.Balance220330AllSaldoSummary.GetFormulaUid(),
                             InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm],
                             GetUsedRows(),
                             GetInnerFirstEntryFormulas(FormulaNamesEnum.Balance220330SaldoSummary.GetFormulaUid()).DoubleRepresentation(),
                             EnumExcelFormulaOperators.Plus);

            SetBorderAllCellsInBlock(xls, Color.Gray, TFlxBorderStyle.Dotted);
        }
        protected override void RenderBody(ExtendedXlsFile xls)
        {
            StartRow = Parent.GetUsedRows() + 1;
            UsedRows = StartRow;
            StartCol = InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName];
            UsedCols = InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1;

            xls.SetCellValue(UsedRows + 1,
                             InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                             "Субъект/Подстанция/Присоединение",
                             InternalData.GetHeaderFormat(xls));
            xls.MergeCells(UsedRows + 1,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows + 1,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1); //Нужно объединить ячейку до "Прием кВт.ч."

            foreach (var dateTimePeriod in Data.PeriodsList)
            {
                UsedCols++;
                xls.SetCellValue(UsedRows, UsedCols,
                                 dateTimePeriod.DateStart.ToString("dd.MM.yyyy") + " " + dateTimePeriod.DateStart.ToString("HH:mm") + " - " + dateTimePeriod.DateEnd.ToString("HH:mm"),
                                 InternalData.GetHeaderFormat(xls));
                xls.MergeCells(UsedRows, UsedCols, UsedRows, UsedCols + 2);

                xls.SetCellValue(UsedRows + 1, UsedCols, "Прием кВт.ч.", InternalData.GetHeaderFormat(xls));
                xls.SetCellValue(UsedRows + 1, UsedCols + 1, "Отдача кВт.ч.", InternalData.GetHeaderFormat(xls));
                xls.SetCellValue(UsedRows + 1, UsedCols + 2, "Сальдо кВт.ч.", InternalData.GetHeaderFormat(xls));

                UsedCols++;
                UsedCols++;
            }

            xls.SetBorderRangeCells(UsedRows, StartCol, UsedRows, UsedCols, System.Drawing.Color.Black, FlexCel.Core.TFlxBorderStyle.Dashed);
            xls.SetBorderRangeCells(UsedRows + 1, StartCol, UsedRows + 1, UsedCols, System.Drawing.Color.Black, FlexCel.Core.TFlxBorderStyle.Thin);

            UsedRows++;
        }
Example #16
0
 private void MarkFlags(KeyValuePair <enumVoltageClassPoint, Server.DBAccess.Internal.TClasses.TVALUES_DB> wattsByVolt,
                        ExtendedXlsFile xls,
                        int groupColNum,
                        Dictionary <enumVoltageClassPoint, ColNumFormulaUid> colDict)
 {
     //есть ОВ
     if ((wattsByVolt.Value.F_FLAG & (VALUES_FLAG_DB.None | VALUES_FLAG_DB.IsOVReplaced)) ==
         (VALUES_FLAG_DB.None | VALUES_FLAG_DB.IsOVReplaced))
     {
         xls.SetCellFontColor(UsedRows, colDict[wattsByVolt.Key].ColumnNumber, IsOVReplacedColor);
         xls.SetCellFontColor(UsedRows, groupColNum, IsOVReplacedColor);
         xls.SetCellFontColor(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm], IsOVReplacedColor);
         //Data.FlagOVremark = true;
         InternalData.FlagOVremark = true;
     }
     // нет данных
     if ((wattsByVolt.Value.F_FLAG & VALUES_FLAG_DB.DataNotFull) == VALUES_FLAG_DB.DataNotFull)
     {
         xls.SetCellBkColor(UsedRows, colDict[wattsByVolt.Key].ColumnNumber, NoDataColor);
         xls.SetCellBkColor(UsedRows, groupColNum, NoDataColor);
         xls.SetCellBkColor(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm], NoDataColor);
         //Data.IsNoDataStatus = true;
         InternalData.FlNoData = true;
     }
     // статус менялся вручную
     if (((wattsByVolt.Value.F_FLAG & VALUES_FLAG_DB.NotCorrect) == VALUES_FLAG_DB.NotCorrect)
         &&
         ((wattsByVolt.Value.F_FLAG & VALUES_FLAG_DB.isManualStatusChanged) ==
          VALUES_FLAG_DB.isManualStatusChanged))
     {
         xls.SetCellBkColor(UsedRows, colDict[wattsByVolt.Key].ColumnNumber, IsManualStatusChangeColor);
         xls.SetCellBkColor(UsedRows, groupColNum, IsManualStatusChangeColor);
         xls.SetCellBkColor(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm], IsManualStatusChangeColor);
         //Data.FlagManualStatusChange = true;
         InternalData.FlagManualStatusChange = true;
     }
 }
Example #17
0
        public ExtendedXlsFile TestExecuteBalansHierLev0_Valtage_220_330_Full(BalansHierLev0Result HierLev0,
                                                                              TExportExcelAdapterType ExportType, IVisualDataRequestObjectsNames getNameInterface)
        {
            Dictionary <ID_TypeHierarchy, string> dictionaryOfNames = HierLev0.DictionaryOfNames;
            InitData     data         = new InitData(HierLev0.VoltageClassPoints);
            InternalData internalData = new InternalData(ExportType);
            InitBlock    initBlock    = new InitBlock(data, internalData);

            Classes.TitleInfo titleData =
                new Classes.TitleInfo(getNameInterface.GetBalanceNameForHierLev0(HierLev0.BalanceId), HierLev0.DTStart, HierLev0.DTEnd);
            TitleBlock titleBlock = new TitleBlock(titleData);

            initBlock.AddBlock(titleBlock);
            HeaderFooterData  headFootData = new HeaderFooterData(HierLev0.VoltageClass, HierLev0.HighLimit);
            HeaderFooterBlock headerFooter = new HeaderFooterBlock(headFootData, internalData);

            initBlock.AddBlock(headerFooter);

            foreach (TIntegral_HierLev0_Values balanceSection in HierLev0.Result_Values)
            {
                BalancePartData balData = new BalancePartData(getNameInterface.GetBalanceSectionName(balanceSection.HierLev0Group_Name),
                                                              HierLev0.BalPartList.Where(x => x.IsUseInGeneralBalance).Select(x => x.Name).Contains(balanceSection.HierLev0Group_Name),
                                                              HierLev0.BalPartList.Where(x => x.IsRsk).Select(x => x.Name).Contains(balanceSection.HierLev0Group_Name));

                BalancePartBlock balPartBlock = new BalancePartBlock(balData, internalData);
                foreach (KeyValuePair <ID_IsOurSide, TIntegral_PS_ValuesForHierLev0> psBalSect in balanceSection.HierLev0DetailGroupResult)
                {
                    string psName;
                    TIntegral_PS_ValuesForHierLev0 psBalSectData = psBalSect.Value;
                    ID_IsOurSide     side = psBalSect.Key;
                    ID_TypeHierarchy key  = new ID_TypeHierarchy(enumTypeHierarchy.Dict_PS, -1);
                    key.TypeHierarchy = side.IsOurSide ? enumTypeHierarchy.Dict_PS : enumTypeHierarchy.Dict_Contr_PS;
                    key.ID            = side.ID;

                    if (!dictionaryOfNames.TryGetValue(key, out psName))
                    {
                        psName = getNameInterface.GetPSName(side.ID, !side.IsOurSide);
                    }
                    PsBlock psBlock = new PsBlock(psName, internalData);
                    foreach (TI_Integral_ValuesForHierLev0 tiPsBalSect in psBalSectData.TI_List)
                    {
                        string tIName = string.Empty;
                        key.TypeHierarchy = tiPsBalSect.TypeHierarchy;
                        key.ID            = tiPsBalSect.ID;
                        if (!dictionaryOfNames.TryGetValue(key, out tIName))
                        {
                            switch (tiPsBalSect.TypeHierarchy)
                            {
                            case enumTypeHierarchy.Dict_PS:
                                tIName = getNameInterface.GetPSName(tiPsBalSect.ID, !side.IsOurSide);
                                break;

                            case enumTypeHierarchy.Info_TI:
                                tIName = getNameInterface.GetTIName(tiPsBalSect.ID, false);
                                break;

                            case enumTypeHierarchy.Info_ContrTI:
                                tIName = getNameInterface.GetTIName(tiPsBalSect.ID, true);
                                break;

                            case enumTypeHierarchy.Info_TP:
                                tIName = getNameInterface.GetTPName(tiPsBalSect.ID);
                                break;
                            }
                        }

                        List <TVALUES_DB> inputValues;
                        List <TVALUES_DB> outputValues;
                        Data.Full.TiData  tiData = new Data.Full.TiData(tIName);
                        if (tiPsBalSect.Val_List.TryGetValue(1, out inputValues))
                        {
                            tiData.InputByVoltages.Add(tiPsBalSect.VoltageClassPoint, inputValues[0]);
                        }
                        if (tiPsBalSect.Val_List.TryGetValue(2, out outputValues))
                        {
                            tiData.OutputByVoltages.Add(tiPsBalSect.VoltageClassPoint, outputValues[0]);
                        }

                        TiBlock tiBlock = new TiBlock(tiData, internalData);
                        psBlock.AddBlock(tiBlock);
                    }
                    balPartBlock.AddBlock(psBlock);
                }
                headerFooter.AddBlock(balPartBlock);
            }

            ExtendedXlsFile xls = new ExtendedXlsFile(ExportType);

            initBlock.Render(xls);

            return(xls);
        }
Example #18
0
        protected override void RenderFooter(ExtendedXlsFile xls)
        {
            UsedRows++;
            xls.SetCellValue(UsedRows,
                             InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                             "Итого по ЕНЕС, кВт*ч",
                             InternalData.GetSectionNameFormat(xls));
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows,
                           InternalData.TotalColumnsCount);
            UsedRows++;

            xls.SetCellValueStyled(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                                   "Всего по объектам ЕНЭС " + ((Data.VoltageClass == enumVoltageClassGlobal.V220AndLower) ? "220" : "330") + " кВ и выше", TFlxFontStyles.Bold);
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);

            RenderSummaryBehavior behav = new RenderSummaryBehavior(this, TFlxFontStyles.None);

            behav.RenderSummary(xls, GetFirstLevelFormulas);
            UsedRows++;

            xls.SetCellValueStyled(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                                   "Потери в " + ((Data.VoltageClass == enumVoltageClassGlobal.V220AndLower) ? "сети 220 кВ и ниже" : "сети 330 кВ и выше"),
                                   TFlxFontStyles.Bold);
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);

            var saldoFormula       = GetFirstLevelFormulas(FormulaNamesEnum.Balance220330SaldoSummary.GetFormulaUid());
            var balPartInRelLosses = GetFirstLevelFormulas(FormulaNamesEnum.Balance220330RelativeLosses.GetFormulaUid());

            xls.SetFormula(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm],
                           saldoFormula);
            UsedRows++;

            xls.SetCellValueStyled(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                                   ("Относительные потери в " +
                                    ((Data.VoltageClass == enumVoltageClassGlobal.V220AndLower) ? "сети 220 кВ и ниже" : "сети 330 кВ и выше") +
                                    " к отпуску в РСК и потребителям"), TFlxFontStyles.Bold);
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);

            string relativeLossesFormula;

            if (balPartInRelLosses.Elements.Count > 0)
            {
                if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
                {
                    relativeLossesFormula = "=(" + saldoFormula.StringRepresentation() + ")/("
                                            + balPartInRelLosses.StringRepresentation() + ")*100";
                    xls.SetCellFloatValue(UsedRows,
                                          InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm],
                                          new TFormula(relativeLossesFormula));
                }
                else
                {
                    double relativeLosses = saldoFormula.DoubleRepresentation()
                                            / balPartInRelLosses.DoubleRepresentation() * 100;
                    xls.SetCellFloatValue(UsedRows,
                                          InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm],
                                          relativeLosses);
                }
            }
            else
            {
                xls.SetCellFloatValue(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], 0.000);
            }

            UsedRows++;

            xls.SetCellValueStyled(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                                   "Относительные нормативные потери в сети " +
                                   ((Data.VoltageClass == enumVoltageClassGlobal.V220AndLower) ? "220" : "330") + "кВ, %",
                                   TFlxFontStyles.Bold);
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);
            xls.SetCellFloatValue(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], Data.HighLimit);
            UsedRows++;
            UsedRows++;

            if (InternalData.FlNoData || InternalData.FlagOVremark || InternalData.FlagManualStatusChange)
            {
                UsedRows++;
                UsedRows++;
                xls.SetCellValue(UsedRows,
                                 InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1,
                                 "Примечание : ", InternalData.GetFootnoteFormat(xls));
            }
            if (InternalData.FlNoData)
            {
                UsedRows++;
                xls.SetCellBkColor(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], Color.LightPink);
                xls.SetCellValue(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, " - нет данных по одной или нескольким точкам измерения");
                xls.MergeCells(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, UsedRows, InternalData.TotalColumnsCount);
            }
            if (InternalData.FlagOVremark)
            {
                UsedRows++;
                xls.SetCellFloatValue(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], 0.0);
                xls.SetCellFontColor(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], Color.Red);
                xls.SetCellValue(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, " - обходной выключатель");
                xls.MergeCells(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, UsedRows, InternalData.TotalColumnsCount);
            }
            if (InternalData.FlagManualStatusChange)
            {
                UsedRows++;
                xls.SetCellBkColor(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], Color.Yellow);
                xls.SetCellValue(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, " - вручную установлен некоммерческий статус");
                xls.MergeCells(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, UsedRows, InternalData.TotalColumnsCount);
            }
        }
        protected override void RenderFooter(ExtendedXlsFile xls)
        {
            UsedRows++;

            xls.SetCellValueStyled(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                                   "Потери в " + ((Data.VoltageClass == enumVoltageClassGlobal.V220AndLower) ? "сети 220 кВ и ниже" : "сети 330 кВ и выше"),
                                   TFlxFontStyles.Bold);
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);

            xls.SetCellValueStyled(UsedRows + 1, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                                   ("Относительные потери в " +
                                    ((Data.VoltageClass == enumVoltageClassGlobal.V220AndLower) ? "сети 220 кВ и ниже" : "сети 330 кВ и выше") +
                                    " к отпуску в РСК и потребителям"), TFlxFontStyles.Bold);
            xls.MergeCells(UsedRows + 1,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows + 1,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);

            UsedCols = InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1;
            for (int i = 0; i < InternalData.NumbersValues; i++)
            {
                UsedCols++;
                var lossesFormula = GetFirstLevelFormulas(InternalData.IntervalFormulUids[i].SummBalPartSaldoForLosses);
                xls.SetFormula(UsedRows, UsedCols, lossesFormula);

                string relativeLossesFormula;

                var dividerFormula = GetFirstLevelFormulas(InternalData.IntervalFormulUids[i].SummBalPartSaldoForLossesDivider);

                if (dividerFormula.Elements.Count > 0)
                {
                    if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
                    {
                        relativeLossesFormula = "=(" + lossesFormula.StringRepresentation() + ")/("
                                                + dividerFormula.StringRepresentation() + ")*100";
                        xls.SetCellFloatValue(UsedRows + 1,
                                              UsedCols,
                                              new TFormula(relativeLossesFormula));
                    }
                    else
                    {
                        double relativeLosses = lossesFormula.DoubleRepresentation()
                                                / dividerFormula.DoubleRepresentation() * 100;
                        xls.SetCellFloatValue(UsedRows + 1, UsedCols, relativeLosses);
                    }
                }
                else
                {
                    xls.SetCellFloatValue(UsedRows + 1, UsedCols, 0.000);
                }

                xls.MergeCells(UsedRows, UsedCols, UsedRows, UsedCols + 2);
                xls.MergeCells(UsedRows + 1, UsedCols, UsedRows + 1, UsedCols + 2);

                UsedCols++;
                UsedCols++;
            }

            UsedRows++;

            if (InternalData.FlNoData || InternalData.FlagOVremark || InternalData.FlagManualStatusChange)
            {
                UsedRows++;
                UsedRows++;
                xls.SetCellValue(UsedRows,
                                 InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1,
                                 "Примечание : ", InternalData.GetFootnoteFormat(xls));
            }
            if (InternalData.FlNoData)
            {
                UsedRows++;
                xls.SetCellBkColor(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], Color.LightPink);
                xls.SetCellValue(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, " - нет данных по одной или нескольким точкам измерения");
                xls.MergeCells(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, UsedRows, UsedCols);
            }
            if (InternalData.FlagOVremark)
            {
                UsedRows++;
                xls.SetCellFloatValue(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], 0.0);
                xls.SetCellFontColor(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], Color.Red);
                xls.SetCellValue(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, " - обходной выключатель");
                xls.MergeCells(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, UsedRows, UsedCols);
            }
            if (InternalData.FlagManualStatusChange)
            {
                UsedRows++;
                xls.SetCellBkColor(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], Color.Yellow);
                xls.SetCellValue(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, " - вручную установлен некоммерческий статус");
                xls.MergeCells(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] + 1, UsedRows, UsedCols);
            }
        }
Example #20
0
        protected override void RenderBody(ExtendedXlsFile xls)
        {
            UsedRows = Parent.GetUsedRows() + 1;
            StartRow = UsedRows;
            StartCol = InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName];

            xls.SetCellValue(UsedRows,
                             InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                             "Субъект/Подстанция/Присоединение",
                             InternalData.GetHeaderFormat(xls));
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName],
                           UsedRows + 1,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1); //Нужно объединить ячейку до "Прием кВт.ч."

            xls.SetCellValue(UsedRows,
                             InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm],
                             "Прием кВт.ч.",
                             InternalData.GetHeaderFormat(xls));
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm],
                           UsedRows + 1,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm]);
            if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
            {
                xls.SetColWidth(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm],
                                xls.GetColWidth(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm]) +
                                Convert.ToInt32(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] * ExcelMetrics.ColMult(xls)));
            }

            xls.SetCellValue(UsedRows,
                             InternalData.HeaderInputColumnNumbers.Values.Select(x => x.ColumnNumber).Min(),
                             "В том числе по уровням напряжения",
                             InternalData.GetHeaderFormat(xls));
            if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
            {
                xls.SetColOutlineLevel(InternalData.HeaderInputColumnNumbers.Values.Select(x => x.ColumnNumber).Min(),
                                       InternalData.HeaderInputColumnNumbers.Values.Select(x => x.ColumnNumber).Max(),
                                       1);
            }
            xls.MergeCells(UsedRows,
                           InternalData.HeaderInputColumnNumbers.Values.Select(x => x.ColumnNumber).Min(),
                           UsedRows,
                           InternalData.HeaderInputColumnNumbers.Values.Select(x => x.ColumnNumber).Max());

            foreach (var voltage in InternalData.HeaderInputColumnNumbers)
            {
                xls.SetCellValue(UsedRows + 1,
                                 voltage.Value.ColumnNumber,
                                 ((((double)voltage.Key) / 100.0)).ToString() + "кВ",
                                 InternalData.GetHeaderFormat(xls));

                if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
                {
                    xls.SetColWidth(voltage.Value.ColumnNumber,
                                    xls.GetColWidth(voltage.Value.ColumnNumber) +
                                    Convert.ToInt32(voltage.Value.ColumnNumber * ExcelMetrics.ColMult(xls)));
                }
            }

            xls.SetCellValue(UsedRows,
                             InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm],
                             "Отдача кВт.ч.",
                             InternalData.GetHeaderFormat(xls));
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm],
                           UsedRows + 1,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm]);
            if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
            {
                xls.SetColWidth(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm],
                                xls.GetColWidth(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm]) +
                                Convert.ToInt32(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm] * ExcelMetrics.ColMult(xls)));
            }


            xls.SetCellValue(UsedRows,
                             InternalData.HeaderOutputColumnNumbers.Values.Select(x => x.ColumnNumber).Min(),
                             "В том числе по уровням напряжения",
                             InternalData.GetHeaderFormat(xls));
            if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
            {
                xls.SetColOutlineLevel(InternalData.HeaderOutputColumnNumbers.Values.Select(x => x.ColumnNumber).Min(),
                                       InternalData.HeaderOutputColumnNumbers.Values.Select(x => x.ColumnNumber).Max(),
                                       1);
            }
            xls.MergeCells(UsedRows,
                           InternalData.HeaderOutputColumnNumbers.Values.Select(x => x.ColumnNumber).Min(),
                           UsedRows,
                           InternalData.HeaderOutputColumnNumbers.Values.Select(x => x.ColumnNumber).Max());

            foreach (var voltage in InternalData.HeaderOutputColumnNumbers)
            {
                xls.SetCellValue(UsedRows + 1,
                                 voltage.Value.ColumnNumber,
                                 ((((double)voltage.Key) / 100.0)).ToString() + "кВ",
                                 InternalData.GetHeaderFormat(xls));

                if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
                {
                    xls.SetColWidth(voltage.Value.ColumnNumber,
                                    xls.GetColWidth(voltage.Value.ColumnNumber) +
                                    Convert.ToInt32(voltage.Value.ColumnNumber * ExcelMetrics.ColMult(xls)));
                }
            }

            xls.SetCellValue(UsedRows,
                             InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm],
                             "Сальдо кВт.ч.",
                             InternalData.GetHeaderFormat(xls));
            xls.MergeCells(UsedRows,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm],
                           UsedRows + 1,
                           InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm]);
            if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
            {
                xls.SetColWidth(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm],
                                xls.GetColWidth(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm]) +
                                Convert.ToInt32(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm] * ExcelMetrics.ColMult(xls)));
            }

            UsedRows++;
            UsedCols = InternalData.TotalColumnsCount;

            SetBorderAllCellsInBlock(xls, System.Drawing.Color.Black, FlexCel.Core.TFlxBorderStyle.Thin);

            xls.SetColWidth(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.BalPartName], Convert.ToInt32(30f * ExcelMetrics.ColMult(xls)));
            xls.SetColWidth(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.ItemInLev1], Convert.ToInt32(30f * ExcelMetrics.ColMult(xls)));

            if (InternalData.HeaderColumnNumbers.ContainsKey(HeaderBal0LogicalParts.ItemInLev3))
            {
                xls.SetColWidth(InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.ItemInLev2], Convert.ToInt32(30f * ExcelMetrics.ColMult(xls)));
            }

            if (InternalData.ExportType == TExportExcelAdapterType.toXLS)
            {
                xls.CollapseOutlineCols(1, TCollapseChildrenMode.Collapsed);
            }
        }
Example #21
0
        protected override void RenderBody(ExtendedXlsFile xls)
        {
            UsedRows = Parent.GetUsedRows() + 1;
            StartRow = UsedRows;
            StartCol = NestingLevel;

            xls.SetCellValue(UsedRows, StartCol, Data.Name);

            if (StartCol < InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1)
            {
                xls.MergeCells(UsedRows, StartCol, UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm] - 1);
            }

            #region Input
            foreach (var inputByVolt in Data.InputByVoltages)
            {
                double inputValue = inputByVolt.Value.ConvertDataUnitDigitFromWatt(EnumUnitDigit.Kilo).F_VALUE;
                xls.SetCellFloatValue(UsedRows,
                                      InternalData.HeaderInputColumnNumbers[inputByVolt.Key].ColumnNumber,
                                      inputValue);

                //надо добавить в 2 формулы
                //в input
                AddCellToFormula(HeaderBal0LogicalParts.InputSumm.GetFormulaUid(),
                                 InternalData.HeaderInputColumnNumbers[inputByVolt.Key].ColumnNumber, UsedRows, inputValue, EnumExcelFormulaOperators.Plus);
                //по подстанции
                AddCellToFormula(InternalData.HeaderInputColumnNumbers[inputByVolt.Key].FormulaUid,
                                 InternalData.HeaderInputColumnNumbers[inputByVolt.Key].ColumnNumber, UsedRows, inputValue, EnumExcelFormulaOperators.Plus);

                MarkFlags(inputByVolt, xls, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], InternalData.HeaderInputColumnNumbers);
            }

            var inputFormula = GetFormula(HeaderBal0LogicalParts.InputSumm.GetFormulaUid());
            if (inputFormula.Elements.Count > 0)
            {
                xls.SetFormula(UsedRows, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm],
                               inputFormula);
                AddCellToFormula(FormulaNamesEnum.Balance220330InputSummary.GetFormulaUid(),
                                 InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], UsedRows,
                                 inputFormula.DoubleRepresentation(), EnumExcelFormulaOperators.Plus);
                AddCellToFormula(HeaderBal0LogicalParts.SaldoSumm.GetFormulaUid(),
                                 InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.InputSumm], UsedRows,
                                 inputFormula.DoubleRepresentation(), EnumExcelFormulaOperators.Plus);
            }
            #endregion Input

            #region Output
            foreach (var outputByVolt in Data.OutputByVoltages)
            {
                double outputValue = outputByVolt.Value.ConvertDataUnitDigitFromWatt(EnumUnitDigit.Kilo).F_VALUE;
                xls.SetCellFloatValue(UsedRows,
                                      InternalData.HeaderOutputColumnNumbers[outputByVolt.Key].ColumnNumber,
                                      outputValue);

                //надо добавить в 2 формулы
                //в output
                AddCellToFormula(HeaderBal0LogicalParts.OutputSumm.GetFormulaUid(),
                                 InternalData.HeaderOutputColumnNumbers[outputByVolt.Key].ColumnNumber,
                                 UsedRows,
                                 outputValue, EnumExcelFormulaOperators.Plus);
                //по подстанции
                AddCellToFormula(InternalData.HeaderOutputColumnNumbers[outputByVolt.Key].FormulaUid,
                                 InternalData.HeaderOutputColumnNumbers[outputByVolt.Key].ColumnNumber,
                                 UsedRows, outputValue, EnumExcelFormulaOperators.Plus);

                MarkFlags(outputByVolt, xls, InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm], InternalData.HeaderOutputColumnNumbers);
            }

            var outputFormula = GetFormula(HeaderBal0LogicalParts.OutputSumm.GetFormulaUid());
            if (outputFormula.Elements.Count > 0)
            {
                xls.SetFormula(UsedRows,
                               InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm],
                               outputFormula);
                AddCellToFormula(FormulaNamesEnum.Balance220330OutputSummary.GetFormulaUid(),
                                 InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm],
                                 UsedRows, outputFormula.DoubleRepresentation(), EnumExcelFormulaOperators.Plus);
                AddCellToFormula(HeaderBal0LogicalParts.SaldoSumm.GetFormulaUid(),
                                 InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.OutputSumm], UsedRows,
                                 outputFormula.DoubleRepresentation(), EnumExcelFormulaOperators.Minus);
            }
            #endregion Output

            #region Saldo
            var saldoFormula = GetFormula(HeaderBal0LogicalParts.SaldoSumm.GetFormulaUid());

            if (saldoFormula.Elements.Count > 0)
            {
                xls.SetFormula(UsedRows,
                               InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm],
                               saldoFormula);
                AddCellToFormula(FormulaNamesEnum.Balance220330SaldoSummary.GetFormulaUid(),
                                 InternalData.HeaderColumnNumbers[HeaderBal0LogicalParts.SaldoSumm], UsedRows,
                                 saldoFormula.DoubleRepresentation(), EnumExcelFormulaOperators.Plus);
            }
            #endregion Saldo
        }
        public ExtendedXlsFile TestExecuteBalansHierLev0_Valtage_220_330_Interval(BalansHierLev0Result HierLev0,
                                                                                  TExportExcelAdapterType ExportType, IVisualDataRequestObjectsNames getNameInterface)
        {
            Dictionary <ID_TypeHierarchy, string> dictionaryOfNames = HierLev0.DictionaryOfNames;
            InternalData internalData = new InternalData(ExportType, HierLev0.NumbersValues);
            InitBlock    initBlock    = new InitBlock(internalData);

            Classes.TitleInfo titleData =
                new Classes.TitleInfo(getNameInterface.GetBalanceNameForHierLev0(HierLev0.BalanceId), HierLev0.DTStart, HierLev0.DTEnd);
            TitleBlock titleBlock = new TitleBlock(titleData);

            initBlock.AddBlock(titleBlock);

            List <DateTime> dateTimeListForPeriod = getNameInterface.GetDateTimeListForPeriod(HierLev0.DTStart, HierLev0.DTEnd,
                                                                                              HierLev0.DiscreteType, HierLev0.IsSummerOrWinter);
            List <DateTimePeriod> dateTimePeriods = new List <DateTimePeriod>();

            for (int i = 0; i < dateTimeListForPeriod.Count; i += 1)
            {
                var dateList = dateTimeListForPeriod.GetRange(i, Math.Min(2, dateTimeListForPeriod.Count - i));
                if (dateList.Count > 1)
                {
                    dateTimePeriods.Add(new DateTimePeriod(dateList[0], dateList[1]));
                }
            }
            dateTimePeriods.Add(new DateTimePeriod(dateTimeListForPeriod.Max(), HierLev0.DTEnd.AddMinutes(30)));

            HeaderFooterBlock headerFooter = new HeaderFooterBlock(new Data.HeaderFooterData(HierLev0.VoltageClass, dateTimePeriods));

            initBlock.AddBlock(headerFooter);

            foreach (TIntegral_HierLev0_Values balanceSection in HierLev0.Result_Values)
            {
                BalansHierLev0.Data.Full.BalancePartData balData = new BalansHierLev0.Data.Full.BalancePartData(getNameInterface.GetBalanceSectionName(balanceSection.HierLev0Group_Name),
                                                                                                                HierLev0.BalPartList.Where(x => x.IsUseInGeneralBalance).Select(x => x.Name).Contains(balanceSection.HierLev0Group_Name),
                                                                                                                HierLev0.BalPartList.Where(x => x.IsRsk).Select(x => x.Name).Contains(balanceSection.HierLev0Group_Name));

                BalancePartBlock balPartBlock = new BalancePartBlock(balData);
                foreach (KeyValuePair <ID_IsOurSide, TIntegral_PS_ValuesForHierLev0> psBalSect in balanceSection.HierLev0DetailGroupResult)
                {
                    string psName;
                    TIntegral_PS_ValuesForHierLev0 psBalSectData = psBalSect.Value;
                    ID_IsOurSide     side = psBalSect.Key;
                    ID_TypeHierarchy key  = new ID_TypeHierarchy(enumTypeHierarchy.Dict_PS, -1);
                    key.TypeHierarchy = side.IsOurSide ? enumTypeHierarchy.Dict_PS : enumTypeHierarchy.Dict_Contr_PS;
                    key.ID            = side.ID;

                    if (!dictionaryOfNames.TryGetValue(key, out psName))
                    {
                        psName = getNameInterface.GetPSName(side.ID, !side.IsOurSide);
                    }
                    PsBlock psBlock = new PsBlock(psName);
                    foreach (TI_Integral_ValuesForHierLev0 tiPsBalSect in psBalSectData.TI_List)
                    {
                        string tIName = string.Empty;
                        key.TypeHierarchy = tiPsBalSect.TypeHierarchy;
                        key.ID            = tiPsBalSect.ID;
                        if (!dictionaryOfNames.TryGetValue(key, out tIName))
                        {
                            switch (tiPsBalSect.TypeHierarchy)
                            {
                            case enumTypeHierarchy.Dict_PS:
                                tIName = getNameInterface.GetPSName(tiPsBalSect.ID, !side.IsOurSide);
                                break;

                            case enumTypeHierarchy.Info_TI:
                                tIName = getNameInterface.GetTIName(tiPsBalSect.ID, false);
                                break;

                            case enumTypeHierarchy.Info_ContrTI:
                                tIName = getNameInterface.GetTIName(tiPsBalSect.ID, true);
                                break;

                            case enumTypeHierarchy.Info_TP:
                                tIName = getNameInterface.GetTPName(tiPsBalSect.ID);
                                break;
                            }
                        }

                        List <TVALUES_DB> inputValues;
                        List <TVALUES_DB> outputValues;
                        Data.TiData       tiData = new Data.TiData(tIName);
                        if (tiPsBalSect.Val_List.TryGetValue(1, out inputValues))
                        {
                            tiData.InputInterval = inputValues.Select(x => new TVALUES_DB(x.F_FLAG, x.F_VALUE / 1000)).ToList();
                        }
                        if (tiPsBalSect.Val_List.TryGetValue(2, out outputValues))
                        {
                            tiData.OutputInterval = outputValues.Select(x => new TVALUES_DB(x.F_FLAG, x.F_VALUE / 1000)).ToList();
                        }

                        TiBlock tiBlock = new TiBlock(tiData);
                        psBlock.AddBlock(tiBlock);
                    }
                    balPartBlock.AddBlock(psBlock);
                }
                headerFooter.AddBlock(balPartBlock);
            }

            ExtendedXlsFile xls = new ExtendedXlsFile(ExportType);

            initBlock.Render(xls);

            return(xls);
        }