Beispiel #1
0
        private void SimpleLabelReplacement(TestingProcessResultDto result, WordprocessingDocument document)
        {
            var list = WordKeyBulider <TestingProcessResultDto> .GetRepalcedValues(result);

            list.AddRange(this._GetStatisticsRangeDescription(result));
            list.AddRange(this._GetPointValues(result));

            document.SearchAndReplaces(list);
        }
Beispiel #2
0
        private void SetFinallyNotes(TestingProcessResultDto result, WordprocessingDocument document)
        {
            var name = "{{FinallyNotes}}";


            var text = document.MainDocumentPart.Document.Descendants <Text>().Where(t => t.Text == name).FirstOrDefault();

            if (text != null)
            {
                text.Text           = "";
                result.FinallyNotes = "注" + result.FinallyNotes;
                WordHelper.ComplexReplace((Paragraph)text.Parent.Parent, result.FinallyNotes, new char[] { 'U', 'k' });
            }
        }
Beispiel #3
0
        public TestingProcessResultDto GetResult(SpreadsheetDocument document)
        {
            var result = new TestingProcessResultDto();
            var propertyDescriptions = PropertyInfoBulider <TestingProcessResultDto> .GetPropertyAttributes();

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

            this.SetStatsticsValues(result, document);
            this.SetFinallyNotes(result, document);
            this.SetPointsValues(result, document);
            return(result);
        }
Beispiel #4
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)");
            }

            TableRow firstDataRow;

            if (result.FileType == FileType.Range1)
            {
                firstDataRow = table.Elements <TableRow>().ToList()[2];
            }
            else
            {
                firstDataRow = table.Elements <TableRow>().ToList()[3];
            }
            if (result.TemperatureRanges.Count == 0)
            {
                return;
            }

            var addedRow = firstDataRow;

            for (var i = 0; i < result.TemperatureRanges.Count; i++)
            {
                var      standardTempture = result.TemperatureRanges[i];
                TableRow newRow;
                if (i == 0)
                {
                    newRow = firstDataRow;
                }
                else
                {
                    newRow = (TableRow)firstDataRow.Clone();
                }
                var cells = newRow.Elements <TableCell>().ToList();
                //输入第一个量程的
                this.SetCellValue(cells[0], standardTempture);
                var obj = result.Ranges.Where(t => t.DisplayStandardTemperature == standardTempture &&
                                              t.Type == RangetType.范围1).FirstOrDefault();
                var difference = "—";
                var uValue     = "—";
                if (obj != null)
                {
                    difference = obj.Difference;
                    uValue     = obj.UValue;
                }
                this.SetCellValue(cells[1], difference);
                this.SetCellValue(cells[2], uValue);
                if (cells.Count > 3) //RangetType.范围1
                {
                    obj = result.Ranges.Where(t => t.DisplayStandardTemperature == standardTempture &&
                                              t.Type == RangetType.范围2).FirstOrDefault();
                    difference = "—";
                    uValue     = "—";
                    if (obj != null)
                    {
                        difference = obj.Difference;
                        uValue     = obj.UValue;
                    }
                    this.SetCellValue(cells[3], difference);
                    this.SetCellValue(cells[4], uValue);
                }
                if (cells.Count > 5)
                {
                    obj = result.Ranges.Where(t => t.DisplayStandardTemperature == standardTempture &&
                                              t.Type == RangetType.范围3).FirstOrDefault();
                    difference = "—";
                    uValue     = "—";
                    if (obj != null)
                    {
                        difference = obj.Difference;
                        uValue     = obj.UValue;
                    }
                    this.SetCellValue(cells[5], difference);
                    this.SetCellValue(cells[6], uValue);
                }
                if (cells.Count > 7)
                {
                    obj = result.Ranges.Where(t => t.DisplayStandardTemperature == standardTempture &&
                                              t.Type == RangetType.范围4).FirstOrDefault();
                    difference = "—";
                    uValue     = "—";
                    if (obj != null)
                    {
                        difference = obj.Difference;
                        uValue     = obj.UValue;
                    }
                    this.SetCellValue(cells[7], difference);
                    this.SetCellValue(cells[8], uValue);
                }

                if (i > 0)
                {
                    table.InsertAfter(newRow, addedRow);
                }
                addedRow = newRow;
            }
        }
Beispiel #5
0
        private List <(string replacedString, string replacingString)> _GetStatisticsRangeDescription(TestingProcessResultDto result)
        {
            var range1 = "";
            var range2 = "";
            var range3 = "";
            var range4 = "";

            var obj = this.Result.Ranges.Where(t => t.Type == RangetType.范围1).FirstOrDefault();

            if (obj != null)
            {
                range1 = obj.Description;
            }
            obj = this.Result.Ranges.Where(t => t.Type == RangetType.范围2).FirstOrDefault();
            if (obj != null)
            {
                range2 = obj.Description;
            }
            obj = this.Result.Ranges.Where(t => t.Type == RangetType.范围3).FirstOrDefault();
            if (obj != null)
            {
                range3 = obj.Description;
            }
            obj = this.Result.Ranges.Where(t => t.Type == RangetType.范围4).FirstOrDefault();
            if (obj != null)
            {
                range4 = obj.Description;
            }

            var list = new List <(string, string)>();

            list.Add(("{{range1}}", range1));
            list.Add(("{{range2}}", range2));
            list.Add(("{{range3}}", range3));
            list.Add(("{{range4}}", range4));
            return(list);
        }
Beispiel #6
0
        private List <(string replacedString, string replacingString)> _GetPointValues(TestingProcessResultDto result)
        {
            var list = new List <(string, string)>();

            for (var i = 0; i < result.TestingPointValues.Count(); i++)
            {
                var obj   = result.TestingPointValues[i];
                var key   = "{{pointvalue" + obj.Location + "}}";
                var value = obj.Value;
                list.Add((key, value));
            }

            return(list);
        }