Exemplo n.º 1
0
        public void PopulateDocument(int markId, MemoryStream memory)
        {
            var mark = _markRepo.GetById(markId);

            if (mark == null)
            {
                throw new ArgumentNullException(nameof(mark));
            }
            var subnode = mark.Subnode;
            var node    = subnode.Node;
            var project = node.Project;

            var constructionBolts = _constructionBoltRepo.GetAllByMarkId(markId);
            var boltLengths       = new List <BoltLength> {
            };

            foreach (var bolt in constructionBolts)
            {
                var arr = _boltLengthRepo.GetAllByDiameterId(bolt.Diameter.Id);
                var bl  = arr.Where(
                    v => v.Length >= bolt.Packet + v.ScrewLength).Aggregate(
                    (i1, i2) => i1.Length < i2.Length ? i1 : i2);
                boltLengths.Add(bl);
            }
            using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(memory, true))
            {
                var markName = MarkHelper.MakeMarkName(
                    project.BaseSeries, node.Code, subnode.Code, mark.Code);
                AppendToTable(wordDoc, constructionBolts.ToList(), boltLengths);
                Word.AppendToSmallFooterTable(wordDoc, markName);
                Word.AppendToMainSmallFooterTable(wordDoc, markName);
            }
        }
Exemplo n.º 2
0
        public void PopulateDocument(int markId, MemoryStream memory)
        {
            var mark = _markRepo.GetById(markId);

            if (mark == null)
            {
                throw new ArgumentNullException(nameof(mark));
            }
            var subnode = mark.Subnode;
            var node    = subnode.Node;
            var project = node.Project;

            var sheets                = _docService.GetAllSheetsByMarkId(markId).ToList();
            var docs                  = _docService.GetAllAttachedByMarkId(markId).ToList();
            var attachedDocs          = _attachedDocRepo.GetAllByMarkId(markId).ToList();
            var additionalWork        = _additionalWorkService.GetAllByMarkId(markId).ToList();
            var constructions         = _constructionRepo.GetAllByMarkId(markId).ToList();
            var standardConstructions = _standardConstructionRepo.GetAllByMarkId(markId).ToList();

            using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(memory, true))
            {
                var markName = MarkHelper.MakeMarkName(
                    project.BaseSeries, node.Code, subnode.Code, mark.Code);
                (var complexName, var objectName) = MarkHelper.MakeComplexAndObjectName(
                    project.Name, node.Name, subnode.Name, mark.Name);

                Word.ReplaceText(wordDoc, "A", markName);
                Word.ReplaceText(wordDoc, "B", complexName);
                Word.ReplaceText(wordDoc, "C", objectName);
                Word.ReplaceText(wordDoc, "D", mark.Subnode.Node.ChiefEngineer.Name);
                Word.ReplaceText(wordDoc, "E", mark.GroupLeader.Name);
                Word.ReplaceText(
                    wordDoc, "F", mark.IssueDate.GetValueOrDefault().ToString("dd.MM.yyyy"));
                Word.ReplaceText(wordDoc, "G", FindWeight(constructions, standardConstructions).ToStringWithComma());
                AppendToSheetsTable(wordDoc, sheets);
                AppendToDocsTable(wordDoc, docs);
                AppendToAttachedDocsTable(wordDoc, attachedDocs);
                AppendToAdditionalWorkTable(wordDoc, additionalWork);

                Word.AppendToMainSmallFooterTable(wordDoc, markName);
                Word.AppendToSmallFooterTable(wordDoc, markName);
            }
        }