Ejemplo n.º 1
0
 public LocalRepository()
 {
     this.Pump  = new Pump();
     this.Tanks = new WaterTank[NUMBER_OF_TANKS];
     for (int i = 0; i < NUMBER_OF_TANKS; i++)
     {
         this.Tanks[i] = new WaterTank();
     }
     this.ProcessChart = new ProcessChart();
 }
Ejemplo n.º 2
0
        public void Process(string templateName, string fileName, string measured, float operatorValue, float inspectorValue, float sigma)
        {
            // first read document in as stream
            byte[]   original = File.ReadAllBytes(templateName);
            string[] switches = new string[] {};
            var      template = GetReport(1);

            Populate(template);

            using (var stream = new MemoryStream())
            {
                stream.Write(original, 0, original.Length);

                using (var docx = WordprocessingDocument.Open(stream, true))
                {
                    ConvertFieldCodes(docx.MainDocumentPart.Document);
                    foreach (var detail in template.Charts)
                    {
                        var fieldName = (detail.DetailName.ToUpper().StartsWith("CRT") ? detail.DetailName: "CRT_" + detail.DetailName);
                        var dcInfo    = BaseProcess.GetColumnInfo(fieldName);
                        if (!GetTableName(template, dcInfo))
                        {
                            continue;
                        }
                        if (dcInfo.FieldType == FieldType.Chart)
                        {
                            ProcessChart.Process(docx, dcInfo, detail, detail.DetailName);
                        }
                    }
                    foreach (var field in docx.MainDocumentPart.Document.Descendants <SimpleField>())
                    {
                        var fieldname = BaseProcess.GetFieldName(field, out switches);
                        if (string.IsNullOrEmpty(fieldname))
                        {
                            continue;
                        }
                        var dcInfo = BaseProcess.GetColumnInfo(fieldname);
                        if (dcInfo.FieldType == FieldType.Chart)
                        {
                            continue;
                        }
                        if (dcInfo.FieldType == FieldType.Table)
                        {
                            if (!GetTableName(template, dcInfo))
                            {
                                continue;
                            }
                            var table = template.DataSet.Tables[dcInfo.TableNameInDb];
                            if (dcInfo.FieldType == FieldType.Table)
                            {
                                ProcessTable.Process(docx, dcInfo, table, field, fieldname);
                            }
                        }
                        else if (dcInfo.FieldType == FieldType.Image)
                        {
                            ProcessImage.ShowIndicator(docx, field, measured, operatorValue, inspectorValue, sigma);
                        }
                    }
                    ProcessTable.RemoveEmptyTables(docx);


                    docx.MainDocumentPart.Document.Save();
                }

                stream.Seek(0, SeekOrigin.Begin);
                byte[] data = stream.ToArray();

                File.WriteAllBytes(fileName, data);
            }
        }
Ejemplo n.º 3
0
 public void InsertProcessChart(ProcessChart processChart)
 {
     _ProcessChartRepository.Insert(processChart, 5);
 }