private normPage LoadNorm(Pollution polution, Well well, int row) { normPage normPage = new normPage(); normPage.Set621(polution.ID, well); normPage.Set644(polution.ID, well); if (normPage._621 != null) { table.value.Add(new MyTools.C_ValueCell($"{(polution.HasRange ? $"{normPage._621.FromRound}-" : "")}{normPage._621.ToRound}", row + 2, 3 + MonthCount, style: style[0])); } else { table.value.Add(new MyTools.C_ValueCell("", row + 2, 3 + MonthCount, style: style[0])); } if (normPage._644 != null) { table.value.Add(new MyTools.C_ValueCell($"{(polution.HasRange ? $"{normPage._644.FromRound}-" : "")}{normPage._644.ToRound}", row + 2, 4 + MonthCount, style: style[1])); } else { table.value.Add(new MyTools.C_ValueCell("", row + 2, 4 + MonthCount, style: style[1])); } return(normPage); }
private bool LoadTable() { if (!LoadBase()) { return(false); } loadData(); LoadCap(); int indexRow = 0; var pollutions = new Dictionary <Pollution, int>(); { //делаю список показателей var prePollutions = new HashSet <Pollution>(); foreach (var selectionWell in _selectionWells) { foreach (var selectionValue in selectionWell.ValueSelections) { if (!prePollutions.Contains(selectionValue.Pollution)) { prePollutions.Add(selectionValue.Pollution); } } } int index = 0; pollutions = prePollutions.ToDictionary(x => x, x => index++); } foreach (var selectionWell in _selectionWells) { foreach (var selectionValue in selectionWell.ValueSelections) { } if (ShowNorms) { } if (ShowCalcs) { } } foreach (var one in values.GroupBy(x => x.Pollution).OrderBy(x => x.Key.Number).ToArray()) { table.value.Add(new MyTools.C_ValueCell(indexRow + 1, indexRow + 2, 0)); table.value.Add(new MyTools.C_ValueCell(MyTools.TextToUpper(one.Key.FullName).SymbolConverter(), indexRow + 2, 1)); normPage normPage = null; if (ShowNorms) { normPage = LoadNorm(one.Key, one.First().SelectionWell.Well, indexRow); } foreach (var sw in one.OrderBy(x => x.SelectionWell.Number).ThenBy(x => x.SelectionWell.YMDHM).GroupBy(x => MyTools.YM_From_YMDHM(x.SelectionWell.YMDHM)).ToArray()) { string value = string.Empty; foreach (var val in sw) { value += $"{val.ValueRound}\n"; } ICellStyle style = null; if (normPage != null) { style = normPage.Verify(sw.Sum(x => x.ValueRound) / sw.Count()); } table.value.Add(new MyTools.C_ValueCell(value.Trim('\n'), indexRow + 2, sw.Key - StartYM + 2, style: style)); } table.value.Add(new MyTools.C_ValueCell(Math.Round(one.Sum(x => x.Value) / one.Count(), one.Key.Round, MidpointRounding.AwayFromZero), indexRow + 2, MonthCount + 2)); indexRow++; } LoadVolume(); for (int i = 2; i < 2 + MonthCount; i++) { for (int j = 2; j < indexRow + 2; j++) { if (table.value.Find(x => x.row == j && x.col == i) == null) { table.value.Add(new MyTools.C_ValueCell('-', j, i)); } } } if (ShowCalcs) { indexRow += 2; table.value.Add(new MyTools.C_ValueCell("Расчёт 621-П", 1 + indexRow, 1)); table.value.Add(new MyTools.C_ValueCell("Расчёт 644", 2 + indexRow, 1)); foreach (var one in values.GroupBy(x => MyTools.YM_From_YMDHM(x.SelectionWell.YMDHM)).ToArray()) { Calc_621 calc_621 = new Calc_621(Helpers.LogicHelper.SampleLogic.FirstModel(one.First().SampleID), this._selectionWell.Objecte, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains("621"))); calc_621.Calc(); table.value.Add(new MyTools.C_ValueCell(calc_621.Answer != null ? calc_621.Answer.Sum(x => x.Value.SummNDS).ToMoney() : "", 1 + indexRow, one.Key - StartYM + 2, style: style[0])); Calc_644 calc_644 = new Calc_644(Helpers.LogicHelper.SampleLogic.FirstModel(one.First().SampleID), this._selectionWell.Objecte, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains("644"))); calc_644.Calc(); table.value.Add(new MyTools.C_ValueCell(calc_644.Answer != null ? calc_644.Answer.Sum(x => x.Value.SummNDS).ToMoney() : "", 2 + indexRow, one.Key - StartYM + 2, style: style[1])); } for (int i = 0; i < MonthCount; i++) { if (table.value.Find(x => x.col == i + 2 && x.row == indexRow + 1) == null) { table.value.Add(new MyTools.C_ValueCell("", 1 + indexRow, i + 2, style: style[0])); } if (table.value.Find(x => x.col == i + 2 && x.row == indexRow + 2) == null) { table.value.Add(new MyTools.C_ValueCell("", 2 + indexRow, i + 2, style: style[1])); } } } CreateTable(sheet, table); ResizeWidth(sheet, MonthCount > 6 ? MyTools.ETypeFormatBook.Horizontal : MyTools.ETypeFormatBook.Vertical, table); ResizeHeight(sheet, table); return(true); }