Exemple #1
0
 //执行一次深度复制
 public void CopyFrom(TestedRacks tr)
 {
     this.Key         = tr.Key;
     this.Tester      = tr.Tester;
     this.SN          = tr.SN;
     this.Racks       = tr.Racks;
     this.TestStatus  = tr.TestStatus;
     this.StartTime   = tr.StartTime;
     this.LastKey     = tr.LastKey;
     this.preTestTime = tr.preTestTime;
     this.RunningTime = tr.RunningTime;
 }
Exemple #2
0
 public void DisplayTree(TestedRacks testedRacks)
 {
     rackAdvTree.Nodes.Clear();
     Node baseroot = new Node();
     baseroot.Tag = "TSP";
     baseroot.Text = "TSP";
     baseroot.Expand();
     Node root = null;
     Node teed = null;
     foreach (Rack rack in testedRacks.Racks)
     {
         root = new Node();
         root.Text = rack.Name;
         root.Tag = rack;
         root.CheckBoxVisible = true;
         root.Checked = rack.IsTested;
         baseroot.Nodes.Add(root);
         if (rack.Name.Contains("部件功能测试"))
         {
             root.Expand();
         }
         foreach (Board board in rack.Boards)
         {
             teed = new Node();
             teed.Text = board.Name;
             teed.Tag = board;
             if (!board.Name.Contains("空"))
             {
                 if (board.IsTested)
                 {
                     teed.Checked = true;
                 }
                 teed.Expand();
                 root.Nodes.Add(teed);
             }
         }
     }
     rackAdvTree.Nodes.Add(baseroot);
     rackAdvTree.Refresh();
 }
Exemple #3
0
 //执行一次深度复制
 public void CopyFrom(TestedRacks tr)
 {
     this.Key = tr.Key;
     this.Tester = tr.Tester;
     this.SN = tr.SN;
     this.Racks = tr.Racks;
     this.TestStatus = tr.TestStatus;
     this.StartTime = tr.StartTime;
     this.LastKey = tr.LastKey;
     this.preTestTime = tr.preTestTime;
     this.RunningTime = tr.RunningTime;
 }
Exemple #4
0
 private void SetNodeColor(TestedRacks testedRacks, TestStatus testStatus)
 {
     foreach (Node basenode in rackAdvTree.Nodes)
     {
         foreach (Node rack in basenode.Nodes)
         {
             Rack r = (Rack)rack.Tag;
             if(r.IsTested)
             {
                 foreach (Node board in rack.Nodes)
                 {
                     Board b = (Board)board.Tag;
                     switch (testStatus)
                     {
                         case TestStatus.THRESHOLD:
                             break;
                         case TestStatus.HANDS_OK:
                             break;
                         case TestStatus.RUNNING:
                             if (!b.IsPassed)
                             {
                                 SetAdvTreeNodeColor(Color.Red, board);
                             }
                             break;
                         case TestStatus.UNEXPECTED_FINNISH:
                             break;
                         case TestStatus.EXPECTED_FINNISH:
                             if (b.IsTested)
                             {
                                 if (b.IsPassed)
                                 {
                                     SetAdvTreeNodeColor(Color.Green, board);
                                 }
                                 else
                                 {
                                     SetAdvTreeNodeColor(Color.Red, board);
                                 }
                             }
                             break;
                     }
                 }
             }
         }
     }
 }
Exemple #5
0
 private string findSnByRack(TestedRacks lastTestedRacks,int rack)
 {
     foreach (Rack r in lastTestedRacks.Racks)
     {
         if(r.No == rack)
         {
             return r.SN;
         }
     }
     return "";
 }
Exemple #6
0
        public void GeneratePdf(TestedRacks tr)
        {
            PdfReader rdr;
            PdfStamper stamper;
            BaseFont baseFont;

            string pdfFile = Util.GetBasePath() + "//Report//" + tr.Key + ".pdf";
            string dataFile = Util.GetBasePath() + "//Report//Data//" + tr.Key + ".trs";
            string logFile = Util.GetBasePath() + "//Report//Data//" + tr.Key + ".log";

            LogHelper.GetLogger<Report>().Debug(pdfFile);
            LogHelper.GetLogger<Report>().Debug(dataFile);
            LogHelper.GetLogger<Report>().Debug(logFile);

            try
            {
                baseFont = BaseFont.CreateFont(fontFile, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger<Report>().Error(ee.Message);
                LogHelper.GetLogger<Report>().Error(ee.StackTrace);
                MessageBox.Show("报告系统的资源文件载入失败,请与开发人员联系。");
                return;
            }

            try
            {
                rdr = new PdfReader(Util.GetBasePath() + templetFile);
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger<Report>().Error(ee.Message);
                LogHelper.GetLogger<Report>().Error(ee.StackTrace);
                MessageBox.Show(string.Format("模板文件载入失败,请检查'{0}'是否存在。",
                    Util.GetBasePath() + templetFile));
                return;
            }

            try
            {
                stamper = new PdfStamper(rdr, new System.IO.FileStream(pdfFile, System.IO.FileMode.Create));
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger<Report>().Error(ee.Message);
                LogHelper.GetLogger<Report>().Error(ee.StackTrace);
                MessageBox.Show(string.Format("报告文件'{0}'创建失败,请关闭软件重新生成报告。", pdfFile));
                rdr.Close();
                return;
            }

            try
            {
                stamper.AcroFields.AddSubstitutionFont(baseFont);

                SetFieldValue(stamper, "pageHead", reportTitle);
                SetFieldValue(stamper, "Head", reportTitle);
                stamper.AcroFields.SetFieldProperty("Head", "textsize", 20.0f, null);

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

                SetFieldValue(stamper, "tester", tr.Tester);
                SetFieldValue(stamper, "startTime", Util.FormateDateTime(tr.StartTime));
                SetFieldValue(stamper, "SN", tr.GetSN());
                SetFieldValue(stamper, "runningTime", Util.FormateDurationSecondsMaxHour(tr.RunningTime));
                if (tr.IsPass())
                {
                    SetFieldValue(stamper, "IsPass", "PASS");
                    stamper.AcroFields.SetFieldProperty("IsPass", "textsize", 38.0f, null);
                    stamper.AcroFields.SetFieldProperty("IsPass", "textcolor", BaseColor.BLUE, null);
                }
                else
                {
                    SetFieldValue(stamper, "IsPass", "FAIL");
                    stamper.AcroFields.SetFieldProperty("IsPass", "textsize", 38.0f, null);
                    stamper.AcroFields.SetFieldProperty("IsPass", "textcolor", BaseColor.RED, null);
                }
                string testType = "";
                string boardName = "";
                string isBoardPass = "";
                foreach (Rack r in tr.Racks)
                {
                    if(r.IsTested)
                    {
                        testType += r.Name + "\n";
                        foreach (Board b in r.Boards)
                        {
                            if (!b.IsTested)
                                continue;
                            boardName += b.Name + "\n";
                            isBoardPass += b.IsPassed ? "PASS\n" : "FAIL\n";
                        }
                    }

                }

                testType += endString;
                boardName += endString;
                isBoardPass += endString;
                SetFieldValue(stamper, "testType", testType);
                SetFieldValue(stamper, "boardName", boardName);
                SetFieldValue(stamper, "isBoardPass", isBoardPass);

                if (File.Exists(logFile))
                {
                    stamper.AddFileAttachment("Diagnostics logs", null, logFile, "log.txt");
                }

                stamper.FormFlattening = true;//不允许编辑
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger<Report>().Error(ee.Message);
                LogHelper.GetLogger<Report>().Error(ee.StackTrace);
            }

            try
            {
                stamper.Close();
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger<Report>().Error(ee.Message);
                LogHelper.GetLogger<Report>().Error(ee.StackTrace);
            }

            try
            {
                rdr.Close();
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger<Report>().Error(ee.Message);
                LogHelper.GetLogger<Report>().Error(ee.StackTrace);
            }

            try
            {
                System.Diagnostics.Process.Start(pdfFile);
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger<Report>().Error(ee.Message);
                LogHelper.GetLogger<Report>().Error(ee.StackTrace);
            }
        }
Exemple #7
0
        public void GeneratePdf(TestedRacks tr)
        {
            PdfReader  rdr;
            PdfStamper stamper;
            BaseFont   baseFont;

            string pdfFile  = Util.GetBasePath() + "//Report//" + tr.Key + ".pdf";
            string dataFile = Util.GetBasePath() + "//Report//Data//" + tr.Key + ".trs";
            string logFile  = Util.GetBasePath() + "//Report//Data//" + tr.Key + ".log";

            LogHelper.GetLogger <Report>().Debug(pdfFile);
            LogHelper.GetLogger <Report>().Debug(dataFile);
            LogHelper.GetLogger <Report>().Debug(logFile);

            try
            {
                baseFont = BaseFont.CreateFont(fontFile, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger <Report>().Error(ee.Message);
                LogHelper.GetLogger <Report>().Error(ee.StackTrace);
                MessageBox.Show("报告系统的资源文件载入失败,请与开发人员联系。");
                return;
            }

            try
            {
                rdr = new PdfReader(Util.GetBasePath() + templetFile);
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger <Report>().Error(ee.Message);
                LogHelper.GetLogger <Report>().Error(ee.StackTrace);
                MessageBox.Show(string.Format("模板文件载入失败,请检查'{0}'是否存在。",
                                              Util.GetBasePath() + templetFile));
                return;
            }

            try
            {
                stamper = new PdfStamper(rdr, new System.IO.FileStream(pdfFile, System.IO.FileMode.Create));
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger <Report>().Error(ee.Message);
                LogHelper.GetLogger <Report>().Error(ee.StackTrace);
                MessageBox.Show(string.Format("报告文件'{0}'创建失败,请关闭软件重新生成报告。", pdfFile));
                rdr.Close();
                return;
            }

            try
            {
                stamper.AcroFields.AddSubstitutionFont(baseFont);

                SetFieldValue(stamper, "pageHead", reportTitle);
                SetFieldValue(stamper, "Head", reportTitle);
                stamper.AcroFields.SetFieldProperty("Head", "textsize", 20.0f, null);

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

                SetFieldValue(stamper, "tester", tr.Tester);
                SetFieldValue(stamper, "startTime", Util.FormateDateTime(tr.StartTime));
                SetFieldValue(stamper, "SN", tr.GetSN());
                SetFieldValue(stamper, "runningTime", Util.FormateDurationSecondsMaxHour(tr.RunningTime));
                if (tr.IsPass())
                {
                    SetFieldValue(stamper, "IsPass", "PASS");
                    stamper.AcroFields.SetFieldProperty("IsPass", "textsize", 38.0f, null);
                    stamper.AcroFields.SetFieldProperty("IsPass", "textcolor", BaseColor.BLUE, null);
                }
                else
                {
                    SetFieldValue(stamper, "IsPass", "FAIL");
                    stamper.AcroFields.SetFieldProperty("IsPass", "textsize", 38.0f, null);
                    stamper.AcroFields.SetFieldProperty("IsPass", "textcolor", BaseColor.RED, null);
                }
                string testType    = "";
                string boardName   = "";
                string isBoardPass = "";
                foreach (Rack r in tr.Racks)
                {
                    if (r.IsTested)
                    {
                        testType += r.Name + "\n";
                        foreach (Board b in r.Boards)
                        {
                            if (!b.IsTested)
                            {
                                continue;
                            }
                            boardName   += b.Name + "\n";
                            isBoardPass += b.IsPassed ? "PASS\n" : "FAIL\n";
                        }
                    }
                }

                testType    += endString;
                boardName   += endString;
                isBoardPass += endString;
                SetFieldValue(stamper, "testType", testType);
                SetFieldValue(stamper, "boardName", boardName);
                SetFieldValue(stamper, "isBoardPass", isBoardPass);

                if (File.Exists(logFile))
                {
                    stamper.AddFileAttachment("Diagnostics logs", null, logFile, "log.txt");
                }

                stamper.FormFlattening = true;//不允许编辑
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger <Report>().Error(ee.Message);
                LogHelper.GetLogger <Report>().Error(ee.StackTrace);
            }

            try
            {
                stamper.Close();
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger <Report>().Error(ee.Message);
                LogHelper.GetLogger <Report>().Error(ee.StackTrace);
            }

            try
            {
                rdr.Close();
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger <Report>().Error(ee.Message);
                LogHelper.GetLogger <Report>().Error(ee.StackTrace);
            }

            try
            {
                System.Diagnostics.Process.Start(pdfFile);
            }
            catch (Exception ee)
            {
                LogHelper.GetLogger <Report>().Error(ee.Message);
                LogHelper.GetLogger <Report>().Error(ee.StackTrace);
            }
        }