Beispiel #1
0
        private void timer_Main_Tick(object sender, EventArgs e)
        {
            String str_actualTrayIconText = this.TrayIcon.Text;

            this.TrayIcon.Text = "Working. Be patient.";

            foreach (FileInfo actFI in this.SearchDirectory.GetFiles())
            {
                if (actFI.Extension.ToLower() != ".txt")
                {
                    continue;
                }
                StreamReader sr = new StreamReader(actFI.OpenRead());

                SpeaReport[] SpeaFileReports = { };

                while (!sr.EndOfStream)
                {
                    String[] ar_LineElements = sr.ReadLine().Split(';');
                    if (ar_LineElements[0] != "START")
                    {
                        continue;
                    }

                    SpeaReport actSpeaReport = new SpeaReport();

                    if (sr.EndOfStream)
                    {
                        continue;
                    }

                    /*
                     * String[] ar_NextLE = sr.ReadLine().Split(';');
                     * if (ar_NextLE[0] != "SN")
                     * {
                     *
                     * }
                     */

                    actSpeaReport.ReportHeader.ProductID  = ar_LineElements[1];
                    actSpeaReport.ReportHeader.OperatorID = ar_LineElements[5];
                    DateTime startTime;

                    try
                    {
                        startTime = new DateTime(
                            Convert.ToInt32(ar_LineElements[6].Substring(6, 4)),
                            Convert.ToInt32(ar_LineElements[6].Substring(0, 2)),
                            Convert.ToInt32(ar_LineElements[6].Substring(3, 2)),
                            Convert.ToInt32(ar_LineElements[7].Substring(0, 2)),
                            Convert.ToInt32(ar_LineElements[7].Substring(3, 2)),
                            Convert.ToInt32(ar_LineElements[7].Substring(6, 2)));
                    }
                    catch
                    {
                        startTime = new DateTime(
                            Convert.ToInt32(ar_LineElements[6].Substring(6, 4)),
                            Convert.ToInt32(ar_LineElements[6].Substring(3, 2)),
                            Convert.ToInt32(ar_LineElements[6].Substring(0, 2)),
                            Convert.ToInt32(ar_LineElements[7].Substring(0, 2)),
                            Convert.ToInt32(ar_LineElements[7].Substring(3, 2)),
                            Convert.ToInt32(ar_LineElements[7].Substring(6, 2)));
                    }
                    if (startTime < new DateTime(2017, 4, 6, 4, 0, 0))
                    {
                        continue;                                                // only new reports are allowed to process
                    }
                    actSpeaReport.ReportHeader.StartTime = startTime.ToString();

                    ar_LineElements = sr.ReadLine().Split(';');

                    if (ar_LineElements[0] == "SN")
                    {
                        actSpeaReport.ReportHeader.SerialNumber = ar_LineElements[1];
                        ar_LineElements = sr.ReadLine().Split(';');
                    }
                    else
                    {
                        actSpeaReport.ReportHeader.SerialNumber = "0000000000000";
                    }

                    if (actSpeaReport.ReportHeader.SerialNumber.Length != 13)
                    {
                        continue;
                    }

                    if (DoubleResultCheck.IsWritten(actSpeaReport.ReportHeader.SerialNumber, startTime))
                    {
                        actSpeaReport.Dispose();
                        continue;
                    }

                    while (!(ar_LineElements[0] == "BOARDRESULT"))
                    {
                        TestRunSpea actTRS = ParserFunctions.FormatLine(ar_LineElements);

                        Array.Resize(ref actSpeaReport.ReportBody.TestRuns, actSpeaReport.ReportBody.TestRuns.Length + 1);
                        actSpeaReport.ReportBody.TestRuns.SetValue(actTRS, actSpeaReport.ReportBody.TestRuns.Length - 1);

                        ar_LineElements = sr.ReadLine().Split(';');
                    }

                    actSpeaReport.ReportHeader.Grade = ar_LineElements[1];

                    ar_LineElements = sr.ReadLine().Split(';');

                    DateTime endTime = new DateTime(
                        Convert.ToInt32(ar_LineElements[2].Substring(6, 4)),
                        Convert.ToInt32(ar_LineElements[2].Substring(0, 2)),
                        Convert.ToInt32(ar_LineElements[2].Substring(3, 2)),
                        Convert.ToInt32(ar_LineElements[3].Substring(0, 2)),
                        Convert.ToInt32(ar_LineElements[3].Substring(3, 2)),
                        Convert.ToInt32(ar_LineElements[3].Substring(6, 2)));

                    actSpeaReport.ReportHeader.EndTime = endTime.ToString();

                    Array.Resize(ref SpeaFileReports, SpeaFileReports.Length + 1);
                    SpeaFileReports.SetValue(actSpeaReport, SpeaFileReports.Length - 1);
                }

                SpeaReport[] SpeaReportsToProcess = { };

                if (SpeaFileReports.Length == 0)
                {
                    continue;
                }

                for (Int32 i = 0; i < SpeaFileReports.Length; i++)
                {
                    if ((SpeaFileReports[i].ReportHeader.SerialNumber == "0000000000000") && (SpeaReportsToProcess.Length == 0))
                    {
                        continue;
                    }
                    if ((SpeaFileReports[i].ReportHeader.Grade == "PASS") && (SpeaFileReports[i].ReportHeader.SerialNumber != "0000000000000"))
                    {
                        Array.Resize(ref SpeaReportsToProcess, SpeaReportsToProcess.Length + 1);
                        SpeaReportsToProcess.SetValue(SpeaFileReports[i], SpeaReportsToProcess.Length - 1);
                        continue;
                    }
                    if (i < SpeaFileReports.Length - 1)
                    {
                        if (SpeaFileReports[i + 1].ReportHeader.SerialNumber == "0000000000000")
                        {
                            if (SpeaFileReports[i + 1].ReportHeader.Grade == "PASS")
                            {
                                SpeaFileReports[i].ReportHeader.Grade = "PASS";
                            }
                            for (Int32 j = 0; j < SpeaFileReports[i].ReportBody.TestRuns.Length; j++)
                            {
                                if (SpeaFileReports[i].ReportBody.TestRuns[j].TestGrade == "FAIL")
                                {
                                    for (Int32 k = 0; k < SpeaFileReports[i + 1].ReportBody.TestRuns.Length; k++)
                                    {
                                        if (SpeaFileReports[i].ReportBody.TestRuns[j].TestName == SpeaFileReports[i + 1].ReportBody.TestRuns[k].TestName)
                                        {
                                            SpeaFileReports[i].ReportBody.TestRuns[j] = SpeaFileReports[i + 1].ReportBody.TestRuns[k];
                                            k = SpeaFileReports[i + 1].ReportBody.TestRuns.Length;
                                        }
                                    }
                                }
                            }
                        }
                        Array.Resize(ref SpeaReportsToProcess, SpeaReportsToProcess.Length + 1);
                        SpeaReportsToProcess.SetValue(SpeaFileReports[i], SpeaReportsToProcess.Length - 1);
                        continue;
                    }
                }

                foreach (SpeaReport actSRTP in SpeaReportsToProcess)
                {
                    UnitReport UR = new UnitReport();

                    UR.starttime = Convert.ToDateTime(actSRTP.ReportHeader.StartTime);
                    UR.endtime   = Convert.ToDateTime(actSRTP.ReportHeader.EndTime);

                    UR.Operator = new _Operator(ConfigFile.GetOperatorPersonalNumber(actSRTP.ReportHeader.OperatorID));

                    UR.Cathegory.Product.SerialNo = actSRTP.ReportHeader.SerialNumber;
                    UR.Cathegory.Product.PartNo   = actSRTP.ReportHeader.ProductID;

                    UR.AddProperty("Work Order", UR.Cathegory.Product.SerialNo.Substring(0, 8));

                    UR.TestRun.name = "ICT";

                    foreach (TestRunSpea actTRS in actSRTP.ReportBody.TestRuns)
                    {
                        UR.TestRun.AddTestRunChild(actTRS.TestName, Convert.ToDateTime(actSRTP.ReportHeader.StartTime), Convert.ToDateTime(actSRTP.ReportHeader.EndTime), actTRS.TestGrade, actTRS.MeasUnit, actTRS.MeasValue, actTRS.LowLimit, actTRS.HighLimit);
                    }

                    UR.Cathegory.name = "Default";

                    UR.mode = "P";

                    UR.TestNumberPrefix = false;

                    Array  actReport     = UR.GetXMLReport();
                    String str_actReport = "";
                    foreach (String actLine in actReport)
                    {
                        str_actReport = String.Concat(str_actReport, actLine);
                    }

                    DoubleResultCheck.WriteResult(UR.Cathegory.Product.SerialNo, UR.starttime);

                    if (!this.BelMesObj.EmployeeVerification(UR.Operator.ToString()))
                    {
                        ErrorHandling.Create("Neznamy operator.", false, false);
                    }
                    else
                    {
                        if (this.BelMesObj.BelMESAuthorization(UR.Cathegory.Product.SerialNo, "ICT", UR.Cathegory.Product.PartNo, ""))
                        {
                            Thread.Sleep(500);

                            if (this.BelMesObj.SetActualResult(UR.Cathegory.Product.SerialNo, "ICT", UR.TestRun.grade, str_actReport))
                            {
                                //DoubleResultCheck.WriteResult(UR.Cathegory.Product.SerialNo, UR.starttime);
                            }
                        }
                    }
                }

                this.TrayIcon.Text = str_actualTrayIconText;
            }
        }
Beispiel #2
0
 public void AddTestRun(String[] LineElements)
 {
     Array.Resize(ref this.ReportBody.TestRuns, this.ReportBody.TestRuns.Length + 1);
     this.ReportBody.TestRuns.SetValue(ParserFunctions.FormatLine(LineElements), this.ReportBody.TestRuns.Length - 1);
 }