示例#1
0
        private void AppendConstruction(
            List <GroupedElement> groupedConstructionElements,
            ref int num,
            int i,
            List <TableCell> trCells,
            TableRow secondTr,
            OpenXmlElement newTr,
            OpenXmlElement clonedSecondTr,
            Table t)
        {
            var steelMap   = new Dictionary <string, double> {
            };
            var elementSum = 0.0;
            var areaSum    = 0.0;

            for (int j = 0; j < groupedConstructionElements.Count(); j++)
            {
                var steelArr = groupedConstructionElements[j].Steel;
                var steelSum = 0.0;
                for (int k = 0; k < steelArr.Count(); k++)
                {
                    var profileArr = steelArr[k].Profiles;
                    var profileSum = 0.0;
                    for (int z = 0; z < profileArr.Count(); z++)
                    {
                        if (i == 0 && j == 0 && k == 0 && z == 0)
                        {
                            trCells = secondTr.Descendants <TableCell>().ToList();
                        }
                        else
                        {
                            newTr   = clonedSecondTr.CloneNode(true);
                            trCells = newTr.Descendants <TableCell>().ToList();
                        }
                        if (k == 0 && z == 0)
                        {
                            trCells[0].GetFirstChild <Paragraph>().Append(
                                Word.GetTextElement(groupedConstructionElements[j].Name, 24));
                            trCells[0].GetFirstChild <TableCellProperties>().Append(new VerticalMerge
                            {
                                Val = MergedCellValues.Restart,
                            });
                        }
                        else
                        {
                            trCells[0].GetFirstChild <TableCellProperties>().Append(new VerticalMerge {
                            });
                        }

                        if (z == 0)
                        {
                            trCells[1].GetFirstChild <Paragraph>().Append(
                                Word.GetTextElement(steelArr[k].Name, 24));
                            var run = Word.GetTextElement(" по", 24);
                            run.AppendChild(new Break());
                            trCells[1].GetFirstChild <Paragraph>().Append(run);
                            var split = steelArr[k].Standard.Split("по ");
                            trCells[1].GetFirstChild <Paragraph>().Append(
                                Word.GetTextElement(split[1], 24));

                            if (profileArr.Count > 1)
                            {
                                trCells[1].GetFirstChild <TableCellProperties>().Append(new VerticalMerge
                                {
                                    Val = MergedCellValues.Restart,
                                });
                            }
                        }
                        else
                        {
                            trCells[1].GetFirstChild <TableCellProperties>().Append(new VerticalMerge {
                            });
                        }

                        trCells[2].GetFirstChild <Paragraph>().Append(
                            Word.GetTextElement(
                                profileArr[z].Symbol, 24, false, false, false, profileArr[z].Symbol == "s="));
                        trCells[2].GetFirstChild <Paragraph>().Append(
                            Word.GetTextElement(profileArr[z].Name, 24));
                        trCells[3].GetFirstChild <Paragraph>().Append(
                            Word.GetTextElement(num.ToString(), 24));
                        trCells[4].GetFirstChild <Paragraph>().Append(
                            Word.GetTextElement(profileArr[z].Length.ToStringWithComma(), 24));
                        trCells[5].GetFirstChild <Paragraph>().Append(
                            Word.GetTextElement(profileArr[z].Weight.ToStringWithComma(), 24));
                        num++;
                        Word.MakeBordersThin(trCells);
                        profileSum += profileArr[z].Weight;
                        areaSum    += profileArr[z].Area;
                        if (i != 0 || j != 0 || k != 0 || z != 0)
                        {
                            t.Append(newTr);
                        }
                    }

                    if (steelMap.ContainsKey(steelArr[k].Name))
                    {
                        steelMap[steelArr[k].Name] += profileSum;
                    }
                    else
                    {
                        steelMap.Add(steelArr[k].Name, profileSum);
                    }

                    newTr   = clonedSecondTr.CloneNode(true);
                    trCells = newTr.Descendants <TableCell>().ToList();
                    Word.MakeBordersThin(trCells);
                    trCells[0].GetFirstChild <TableCellProperties>().Append(new VerticalMerge {
                    });
                    trCells[1].GetFirstChild <Paragraph>().Append(
                        Word.GetTextElement("Итого:", 24));
                    trCells[3].GetFirstChild <Paragraph>().Append(
                        Word.GetTextElement(num.ToString(), 24));
                    trCells[5].GetFirstChild <Paragraph>().Append(
                        Word.GetTextElement(Math.Round(profileSum, 3).ToStringWithComma(), 24));
                    num++;
                    t.Append(newTr);

                    steelSum += profileSum;
                }

                newTr   = clonedSecondTr.CloneNode(true);
                trCells = newTr.Descendants <TableCell>().ToList();
                trCells[0].GetFirstChild <Paragraph>().Append(
                    Word.GetTextElement("Всего профиля:", 24));
                trCells[3].GetFirstChild <Paragraph>().Append(
                    Word.GetTextElement(num.ToString(), 24));
                trCells[5].GetFirstChild <Paragraph>().Append(
                    Word.GetTextElement(Math.Round(steelSum, 3).ToStringWithComma(), 24));
                num++;
                Word.MakeBordersThin(trCells);
                t.Append(newTr);

                elementSum += steelSum;
            }

            newTr   = clonedSecondTr.CloneNode(true);
            trCells = newTr.Descendants <TableCell>().ToList();
            trCells[0].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement("Итого масса металла:", 24));
            trCells[3].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(num.ToString(), 24));
            trCells[5].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(Math.Round(elementSum, 3).ToStringWithComma(), 24));
            num++;
            Word.MakeBordersThin(trCells);
            t.Append(newTr);

            newTr   = clonedSecondTr.CloneNode(true);
            trCells = newTr.Descendants <TableCell>().ToList();
            var p = trCells[0].GetFirstChild <Paragraph>();

            p.Append(Word.GetTextElement(
                         "Итого развернутая площадь поверхности конструкций, 100 м", 24));
            p.Append(Word.GetTextElement("2", 24, false, true));
            p.Append(Word.GetTextElement(":", 24));
            trCells[3].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(num.ToString(), 24));
            trCells[5].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(Math.Round(areaSum, 3).ToStringWithComma(), 24));
            num++;
            Word.MakeBordersThin(trCells);
            t.Append(newTr);

            var n = 0;

            foreach (var steel in steelMap)
            {
                newTr   = clonedSecondTr.CloneNode(true);
                trCells = newTr.Descendants <TableCell>().ToList();
                if (n == 0)
                {
                    trCells[0].GetFirstChild <Paragraph>().Append(
                        Word.GetTextElement("В том числе по маркам:", 24));
                }
                trCells[1].GetFirstChild <Paragraph>().Append(
                    Word.GetTextElement(steel.Key, 24));
                trCells[3].GetFirstChild <Paragraph>().Append(
                    Word.GetTextElement(num.ToString(), 24));
                trCells[5].GetFirstChild <Paragraph>().Append(
                    Word.GetTextElement(Math.Round(steel.Value, 3).ToStringWithComma(), 24));
                num++;
                if (n == steelMap.Count() - 1)
                {
                    Word.MakeBordersThin(trCells, false);
                }
                else
                {
                    Word.MakeBordersThin(trCells);
                }
                t.Append(newTr);
                n++;
            }
        }
示例#2
0
        private void InsertThreeRows(
            List <TableCell> trCells,
            OpenXmlElement clonedFirstTr,
            Table t,
            int num,
            ConstructionBolt bolt,
            BoltLength boltLength)
        {
            // Болт
            OpenXmlElement newTr = null;

            if (num != 1)
            {
                newTr   = clonedFirstTr.CloneNode(true);
                trCells = newTr.Descendants <TableCell>().ToList();
            }
            trCells[0].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(num.ToString(), 24));
            trCells[1].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement($"Высокопрочные болты по {bolt.Diameter.BoltTechSpec}", 24));
            trCells[2].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(bolt.Diameter.Diameter.ToString(), 24));
            trCells[3].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(bolt.Diameter.StrengthClass.ToStringWithComma(), 24));
            trCells[4].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(bolt.Packet.ToString(), 24));
            trCells[5].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(boltLength.Length.ToString(), 24));
            trCells[6].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(bolt.Num.ToString(), 24));
            trCells[7].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(
                    (Math.Ceiling(bolt.Num * boltLength.Weight * 10) / 10).ToStringWithComma(), 24));
            Word.MakeBordersThin(trCells, true, false);
            if (num != 1)
            {
                t.Append(newTr);
            }

            // Гайка
            newTr   = clonedFirstTr.CloneNode(true);
            trCells = newTr.Descendants <TableCell>().ToList();
            trCells[1].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement($"Гайки по {bolt.Diameter.NutTechSpec}", 24));
            trCells[3].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement("?", 24));
            trCells[6].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(bolt.NutNum.ToString(), 24));
            trCells[8].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(
                    (Math.Ceiling(bolt.NutNum * bolt.Diameter.NutWeight * 10) / 10).ToStringWithComma(), 24));
            Word.MakeBordersThin(trCells);
            t.Append(newTr);

            // Шайба
            newTr   = clonedFirstTr.CloneNode(true);
            trCells = newTr.Descendants <TableCell>().ToList();
            trCells[1].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement($"Шайбы по {bolt.Diameter.WasherTechSpec}", 24));
            trCells[3].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(bolt.Diameter.WasherSteel, 24));
            trCells[6].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(bolt.WasherNum.ToString(), 24));
            trCells[9].GetFirstChild <Paragraph>().Append(
                Word.GetTextElement(
                    (Math.Ceiling(bolt.WasherNum * bolt.Diameter.WasherWeight * 10) / 10).ToStringWithComma(), 24));
            Word.MakeBordersThin(trCells, false);
            t.Append(newTr);
        }