Esempio n. 1
0
        private void CheckResult(ExcelLogFile xlLog)
        {
            string[] FileContent;
            string   LogP;
            bool     DidClient  = false;
            bool     DidGateway = false;

            string testName = DG.Rows[testIndex].Cells[1].Value.ToString();

            string[] dirs = Directory.GetDirectories(logFolder, testName + "*");

            DateTime newestDirTime = new DateTime(1900, 1, 1);
            string   newestDirPath = "";

            foreach (string subDir in dirs)
            {
                DateTime created = new DirectoryInfo(subDir).LastWriteTime;
                if (created > newestDirTime)
                {
                    newestDirPath = subDir;
                    newestDirTime = created;
                }
            }
            LogP = newestDirPath + "\\IEX_Summary.xml";

            try
            {
                FileContent = File.ReadAllLines(LogP);

                if (FileContent[1].Contains("Test Status=" + (char)34 + "Failed" + (char)34))
                {
                    DataGridViewCellStyle CellStyle = new DataGridViewCellStyle();
                    CellStyle.BackColor = Color.Red;
                    CellStyle.ForeColor = Color.White;
                    DG.Rows[testIndex].Cells[2].Style = CellStyle;
                    DG.Rows[testIndex].Cells[2].Value = "FAILED";
                }
                else if (FileContent[1].Contains("Test Status=" + (char)34 + "Passed" + (char)34))
                {
                    DataGridViewCellStyle CellStyle = new DataGridViewCellStyle();
                    CellStyle.BackColor = Color.Green;
                    CellStyle.ForeColor = Color.White;
                    DG.Rows[testIndex].Cells[2].Style = CellStyle;
                    DG.Rows[testIndex].Cells[2].Value = "PASSED";
                }

                for (int i = FileContent.Count() - 1; i > -1; i--)
                {
                    if (DidClient && DidGateway)
                    {
                        break;
                    }

                    if (FileContent[i].Contains("Status=" + (char)34 + "Failed" + (char)34))
                    {
                        string Reason = FileContent[i].Remove(0, FileContent[i].IndexOf("Reason"));
                        DataGridViewCellStyle CellStyle = new DataGridViewCellStyle();
                        CellStyle.BackColor = Color.Red;
                        CellStyle.ForeColor = Color.White;
                        if (Reason.Contains("Client") && !DidClient)
                        {
                            DG.Rows[testIndex].Cells[4].Style = CellStyle;
                            DG.Rows[testIndex].Cells[4].Value = "FAILED";
                            DidClient = true;
                        }
                        else if (Reason.Contains("Gateway") && !DidGateway)
                        {
                            DG.Rows[testIndex].Cells[3].Style = CellStyle;
                            DG.Rows[testIndex].Cells[3].Value = "FAILED";
                            DidGateway = true;
                        }
                        Reason = Reason.Substring(Reason.IndexOf("=") + 2, (Reason.IndexOf((char)34 + " ") - 3) - Reason.IndexOf("=") + 1);
                        DG.Rows[testIndex].Cells[5].Value = Reason;
                    }
                    else if (FileContent[i].Contains("Status=" + (char)34 + "Passed" + (char)34))
                    {
                        string Reason = FileContent[i].Remove(0, FileContent[i].IndexOf("Reason"));
                        DataGridViewCellStyle CellStyle = new DataGridViewCellStyle();
                        CellStyle.BackColor = Color.Green;
                        CellStyle.ForeColor = Color.White;
                        if (Reason.Contains("Client") && !DidClient)
                        {
                            DG.Rows[testIndex].Cells[4].Style = CellStyle;
                            DG.Rows[testIndex].Cells[4].Value = "PASSED";
                            DidClient = true;
                        }
                        else if (Reason.Contains("Gateway") && !DidGateway)
                        {
                            DG.Rows[testIndex].Cells[3].Style = CellStyle;
                            DG.Rows[testIndex].Cells[3].Value = "PASSED";
                            DidGateway = true;
                        }
                    }
                }

                xlLog.PrintMsg(testIndex, GetLogFile(ServerType.Gateway, false), GetLogFile(ServerType.Client1, false));
            }
            catch
            {
                DG.Rows[testIndex].Cells[2].Value = "FINISHED";
                DG.Rows[testIndex].Cells[5].Value = "Log isn't available";
            }
        }