Exemple #1
0
        private void SetStatistcisTable(TestingProcessResultDto result, WordprocessingDocument document)
        {
            var tables = document.MainDocumentPart.Document.Body.Elements <Table>().ToList();

            Table table = null;
            //statstics-data

            IEnumerable <TableProperties> tableProperties = document.MainDocumentPart.Document.Body.Descendants <TableProperties>().Where(tp => tp.TableCaption != null);

            foreach (TableProperties tProp in tableProperties)
            {
                if (tProp.TableCaption.Val.InnerText.Equals("statstics-data"))
                {
                    // do something for table with myCaption
                    table = (Table)tProp.Parent;
                }
            }

            if (table == null)
            {
                throw new Exception("未找到填充数据的表格。(caption:statstics-data)");
            }


            var firstDataRow = table.Elements <TableRow>().ToList()[2];

            if (result.TestingStatstics.Count == 0)
            {
                return;
            }

            var addedRow = firstDataRow;

            for (var i = 0; i < result.TestingStatstics.Count; i++)
            {
                var      obj = result.TestingStatstics[i];
                TableRow newRow;
                if (i == 0)
                {
                    newRow = firstDataRow;
                }
                else
                {
                    newRow = (TableRow)firstDataRow.Clone();
                }
                var cells = newRow.Elements <TableCell>().ToList();
                this.SetCellValue(cells[0], obj.温控设置.ToString());

                this.SetCellValue(cells[1], obj.控温显示);
                this.SetCellValue(cells[2], obj.亮度温度);
                this.SetCellValue(cells[3], obj.U值);
                if (i > 0)
                {
                    table.InsertAfter(newRow, addedRow);
                }
                addedRow = newRow;
            }
        }
Exemple #2
0
        private void SetTestingTools(TestingProcessResultDto result, WordprocessingDocument document)
        {
            for (var i = 0; i < result.TestingTools.Count; i++)
            {
                var flag = "";
                if (i > 0)
                {
                    flag = (i + 1).ToString();
                }
                var name = "{{TToolName" + flag + "}}";

                var text = document.MainDocumentPart.Document.Descendants <Text>().Where(t => t.Text == name).FirstOrDefault();
                if (text != null)
                {
                    text.Text = result.TestingTools[i].Name;
                }

                name = "{{TToolTempRange" + flag + "}}";

                text = document.MainDocumentPart.Document.Descendants <Text>().Where(t => t.Text == name).FirstOrDefault();
                if (text != null)
                {
                    text.Text = result.TestingTools[i].TempRange;
                }
                //{TToolNotSure}}
                name = "{{TToolNotSure" + flag + "}}";
                text = document.MainDocumentPart.Document.Descendants <Text>().Where(t => t.Text == name).FirstOrDefault();
                if (text != null)
                {
                    text.Text = "";
                    WordHelper.SetKeyWordItalicStyle((Paragraph)text.Parent.Parent, result.TestingTools[i].NotSure, new char[] { 'U', 'k' });
                }

                name = "{{TToolCode" + flag + "}}";

                text = document.MainDocumentPart.Document.Descendants <Text>().Where(t => t.Text == name).FirstOrDefault();
                if (text != null)
                {
                    text.Text = result.TestingTools[i].Code;
                }


                name = "{{TToolExpiredDesc" + flag + "}}";

                text = document.MainDocumentPart.Document.Descendants <Text>().Where(t => t.Text == name).FirstOrDefault();
                if (text != null)
                {
                    text.Text = result.TestingTools[i].ExpiredDesc;
                }
            }
        }
        public TestingProcessResultDto GetResult(SpreadsheetDocument document)
        {
            var result = new TestingProcessResultDto();
            var propertyDescriptions = PropertyInfoBulider <TestingProcessResultDto> .GetPropertyAttributes();

            propertyDescriptions.ForEach(propertyDescription =>
            {
                this.SetPropertyValue(result, document, propertyDescription);
            });

            this.SetStandardToolValues(result, document);
            this.SetStatsticsValues(result, document);
            this.SetFinallyNotes(result, document);
            return(result);
        }
Exemple #4
0
        //private void SetAccordingByCondtions(TestingProcessResultDto result, WordprocessingDocument document)
        //{
        //    var text = document.MainDocumentPart.Document.Body.Descendants<Text>().Where(t => t.Text == "{{AccordingByConditions}}").FirstOrDefault();
        //    if (text != null)
        //    {
        //        var run = (Run)text.Parent;
        //        var paragraph = (Paragraph)run.Parent;

        //        var paragraphParent = paragraph.Parent;

        //        var addedparagraph = paragraph;


        //        for (var i = 0; i < this.Result.AccordingByConditions.Count; i++)
        //        {
        //            if (i > 0)
        //            {
        //                paragraph = (Paragraph)paragraph.Clone();
        //            }
        //            paragraph.Elements<Run>().ToList()[0].Elements<Text>().ToList()[0].Text = this.Result.AccordingByConditions[i];
        //            if (i > 0)
        //            {
        //                paragraphParent.InsertAfter(paragraph, addedparagraph);
        //            }
        //            addedparagraph = paragraph;
        //        }
        //    }


        //    this.Result.AccordingByConditions.ForEach(fullString =>
        //    {
        //        document.SetNumberStyle(fullString);

        //    });

        //}
        private void SetFinallyNotes(TestingProcessResultDto result, WordprocessingDocument document)
        {
            var text = document.MainDocumentPart.Document.Body.Descendants <Text>().Where(t => t.Text == "{{finnallynotes}}").FirstOrDefault();

            if (text != null)
            {
                text.Text = "";
                var run       = (Run)text.Parent;
                var paragraph = (Paragraph)run.Parent;

                var paragraphParent = paragraph.Parent;

                var clonedParagrapth = (Paragraph)paragraph.Clone();
                var addedparagraph   = paragraph;

                for (var i = 0; i < this.Result.FinallyNotes.Count; i++)
                {
                    this.Result.FinallyNotes[i] = (i + 1).ToString() + "." + this.Result.FinallyNotes[i];
                }
                for (var i = 0; i < this.Result.FinallyNotes.Count; i++)
                {
                    Paragraph thisParagraph;
                    if (i == 0)
                    {
                        thisParagraph = paragraph;
                    }
                    else
                    {
                        thisParagraph = (Paragraph)clonedParagrapth.Clone();
                    }
                    WordHelper.SetKeyWordItalicStyle(thisParagraph, this.Result.FinallyNotes[i], new char[] { 'U', 'k' });
                    if (i > 0)
                    {
                        paragraphParent.InsertAfter(thisParagraph, addedparagraph);
                    }

                    addedparagraph = thisParagraph;
                }
            }
        }
Exemple #5
0
        private void SimpleLabelReplacement(TestingProcessResultDto result, WordprocessingDocument document)
        {
            var list = WordKeyBulider <TestingProcessResultDto> .GetRepalcedValues(result);

            document.SearchAndReplaces(list);
        }