Example #1
0
        public void Save2DB(FctTest fctTest)
        {
            TMain main = new TMain();
            main.Key = fctTest.Key;
            main.Start = fctTest.StartTime;
            main.RunningTime = fctTest.RunningTime;
            main.Tester = fctTest.Tester;
            main.TestType = TEST_TYPE_FCT;
            main.IsPass = fctTest.IsPass() ? TEST_RESULT_PASS : TEST_RESULT_FAIL;
            main.Note = fctTest.FinishReason;
            mainADO.Insert(main);

            Dictionary<Board, List<ComponentType>> dicts = fctTest.Cabinet.GetFctTestedComponentTypesDicts();
            foreach (var b in dicts.Keys)
            {
                TBoard board = new TBoard();
                board.Id = Summer.System.Util.DbHelper.GenerateKey();
                board.Key = fctTest.Key;
                board.Name = b.EqName;
                board.Type = b.BoardType;
                board.Component = "";
                List<ComponentType> list = dicts[b];
                foreach (var ct in list)
                {
                    board.Component += ct.EqName + " ";
                }
                board.Sn = b.FctTestSN;
                board.IsPass = b.IsFctTestPassed() ? TEST_RESULT_PASS : TEST_RESULT_FAIL;
                boardADO.Insert(board);
            }
        }
Example #2
0
        private void GenerateFctPdf(FctTest fctTest, List<Board> boards, List<ComponentType> componentTypes, bool isUserReport)
        {
            BaseFont baseFont;
            try
            {
                baseFont = BaseFont.CreateFont(fontFile, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                PdfReader rdr = new PdfReader(Util.GetBasePath() + fctTempletFile);
                PdfStamper stamper;
                string pdfFile;
                if (isUserReport)
                    pdfFile = GetUsrFctPdfName(fctTest.FinishReason,fctTest.Key, boards[0].FctTestSN, componentTypes[0].IsFctTestPassed());
                else
                    pdfFile = GetDiagnoseFctPdfName(fctTest.Key);

                stamper = new PdfStamper(rdr, new System.IO.FileStream(pdfFile, System.IO.FileMode.Create));
                stamper.AcroFields.AddSubstitutionFont(baseFont);

                if (isUserReport)
                {
                    SetHeadFieldValue(stamper, "pageHead", fctUserReportTitle);
                    SetFieldValue(stamper, "Head", fctUserReportTitle);
                }
                else
                {
                    if (fctMessageLogFile.GetFileName(fctTest.Key) != null)
                        SetFieldValue(stamper, "pageHead", Util.GetMD5(fctMessageLogFile.GetFileName(fctTest.Key)));
                    else
                        SetFieldValue(stamper, "pageHead", fctDiagReportTitle);
                    SetHeadFieldValue(stamper, "Head", fctDiagReportTitle);

                }
                stamper.AcroFields.SetFieldProperty("Head", "textsize", 20.0f, null);
                stamper.AcroFields.SetFieldProperty("Head", "textsize", 20.0f, null);

                SetHeadFieldValue(stamper, "ver", string.Format("{0} Build:{1}", version.Ver, version.Build));
                SetHeadFieldValue(stamper, "data", fctTest.Key);
                SetHeadFieldValue(stamper, "gDate", Util.FormateDateTime2(DateTime.Now));

                SetFieldValue(stamper, "tester", fctTest.Tester);
                SetFieldValue(stamper, "startTime", Util.FormateDateTime(fctTest.StartTime));
                SetFieldValue(stamper, "planRunningTime",
                        string.Format("{0}/{1}", Util.FormateDurationSecondsMaxHour(fctTest.PlanRunningTime),
                        Util.FormateDurationSecondsMaxHour(fctTest.RunningTime)));
                SetFieldValue(stamper, "finishReason", fctTest.FinishReason);

                string names = "";
                string sns = "";
                string passes = "";
                bool isPass = true;

                string componentName = "";
                string allTestTimes = "";
                string errorPackageTimes = "";
                string lostPackageTimes = "";
                string interruptTimes = "";
                for (int i = 0; i < boards.Count; i++)
                {
                    names += boards[i].EqName + "\n";
                    if (boards[i].FctTestSN != "")
                        sns += boards[i].FctTestSN + "\n";
                    else
                        sns += "非待测" + "\n";
                    passes += boards[i].IsFctTestPassed() ? "PASS\n" : "FAIL\n";
                    isPass &= componentTypes[i].IsFctTestPassed();
                }
                names += endString;
                sns += endString;
                passes += endString;

                foreach (ComponentType ct in componentTypes)
                {
                    if (ct.IsFctTestTested)
                    {
                        foreach (Component cp in ct.Components)
                        {
                            if (isUserReport)
                            {
                                componentName += cp.EqName + "\n";
                            }
                            else
                            {
                                componentName += cp.ParentComponentType.ParentBoard.EqName + "-" + cp.EqName + "\n";
                            }
                            allTestTimes += cp.AllTestTimes.ToString() + "\n";
                            errorPackageTimes += cp.ErrorPackageTimes.ToString() + "\n";
                            lostPackageTimes += cp.LostPackageTimes.ToString() + "\n";
                            interruptTimes += cp.InterruptTimes.ToString() + "\n";
                        }
                    }
                }
                componentName += endString;
                allTestTimes += endString;
                errorPackageTimes += endString;
                lostPackageTimes += endString;
                interruptTimes += endString;

                SetFieldValue(stamper, "boardName", names);
                SetFieldValue(stamper, "boardSn", sns);
                SetFieldValue(stamper, "isItemPass", passes);

                SetFieldValue(stamper, "componentName", componentName);
                SetFieldValue(stamper, "allTestTimes", allTestTimes);
                SetFieldValue(stamper, "errorPackageTimes", errorPackageTimes);
                SetFieldValue(stamper, "lostPackageTimes", lostPackageTimes);
                SetFieldValue(stamper, "interruptTimes", interruptTimes);

                if (isPass)
                {
                    SetFieldValue(stamper, "IsPass", "PASS");
                    stamper.AcroFields.SetFieldProperty("IsPass", "textsize", 38.0f, null);
                    BaseColor bc = new BaseColor(00, 64, 00);//DarkGreen
                    stamper.AcroFields.SetFieldProperty("IsPass", "textcolor", bc, null);
                }
                else
                {
                    SetFieldValue(stamper, "IsPass", "FAIL");
                    stamper.AcroFields.SetFieldProperty("IsPass", "textsize", 38.0f, null);
                    stamper.AcroFields.SetFieldProperty("IsPass", "textcolor", BaseColor.RED, null);
                }
                stamper.FormFlattening = true;//不允许编辑
                stamper.Close();
                rdr.Close();
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger<Report>().Error(ee.Message);
                LogHelper.GetLogger<Report>().Error(ee.StackTrace);
                //MessageBox.Show(ee.Message);
            }
        }
Example #3
0
 /// <summary>
 /// FctTest报告生成共包含三种文件:
 /// 1、Pdf报告文件,每个被测试组件生成一份,通过的放在Report//Fct//Passboard,未通过的放在Report//Fct//FailBoard下面,
 /// 命名格式为SN_key.pdf;
 /// 2、Pdf诊断文件,每次测试生成一份,通过的放在Data//Fct,命名格式为key.pdf;
 /// 3、fct二进制文件,保存在Data//Fct目录下,命名格式为 SN_key.fct;
 /// 4、中间的日志文件保存在Data//Fct目录下,命名格式为 SN_key.log;
 /// 本函数用于第一种文件和第二种文件的生成
 /// </summary>
 /// <param name="tr"></param>
 public void GenerateUserPdf(FctTest fctTest)
 {
     //生成用户报告
     Dictionary<Board, List<ComponentType>> dicts = fctTest.Cabinet.GetFctTestedComponentTypesDicts();
     List<Board> boards = new List<Board>();
     List<ComponentType> componentTypes = new List<ComponentType>();
     foreach (var b in dicts.Keys)
     {
         List<Board> tmpBoardList = new List<Board>();
         tmpBoardList.Add(b);
         boards.Add(b);
         componentTypes.AddRange(dicts[b]);
         GenerateFctPdf(fctTest, tmpBoardList, dicts[b], true);
     }
     //生成诊断报告(诊断报告不包含log文件,因为log文件比较大,包含后压缩时间太长)
     //GenerateFctPdf(fctTest, boards, componentTypes, fctMessageLogFile.GetFileName(fctTest.Key), false);
     GenerateFctPdf(fctTest, boards, componentTypes, false);
 }