예제 #1
0
 private void btnParseSwitch_Click(object sender, EventArgs e)
 {
     profilerLog      = null;
     selectedTestCase = null;
     ddlistTestCases.DropDownItems.Clear();
     lstResultList.Items.Clear();
     updateStatusLabel("Start to parse log date, please wait...... ", Color.Black);
     btnParseSwitch.Text     = "   Stop parse";
     btnParseSwitch.Image    = global::com.usi.shd1_tools.TestGuide.Properties.Resources.stop;
     cmbLogFileList.Enabled  = false;
     ddlistTestCases.Visible = false;
     this.Cursor             = Cursors.WaitCursor;
     Application.DoEvents();
     parseLog_Flag = !parseLog_Flag;
     startLogParse(cmbLogFileList.Text);
     profilerLog.RefreshIsMsgTimeout(FormToolSettings.MaxLogInterval);
     showSummaries();
     currentTCIndex          = -1;
     currentPageIndex        = -1;
     currentLine             = -1;
     btnNext.Visible         = true;
     btnPrevious.Visible     = true;
     this.Cursor             = Cursors.Default;
     ddlistTestCases.Visible = ddlistTestCases.DropDownItems.Count > 0;
     btnParseSwitch.Text     = "   Start parse";
     btnParseSwitch.Image    = global::com.usi.shd1_tools.TestGuide.Properties.Resources.Start;
     cmbLogFileList.Enabled  = true;
     updateStatusLabel("All messages = " + profilerLog.MessageCount + "    ;    Fail = " + profilerLog.ErrorCount, Color.Black);
     #region auto-select the first testcase result to show as default
     if (ddlistTestCases.DropDownItems.Count > 0)
     {
         ddlistTestCases_DropDownItemClicked(ddlistTestCases, new ToolStripItemClickedEventArgs(ddlistTestCases.DropDownItems[0]));
     }
     #endregion auto-select the first testcase result to show as default
 }
예제 #2
0
 private void showLogMsgOfTestCase(ProfilerLog_TestCase tc, int startIndex, int length)
 {
     lstResultList.Items.Clear();
     this.Cursor = Cursors.WaitCursor;
     for (int counter = 0; counter < length; counter++)
     {
         try
         {
             if (tc.LogMessages.Count > startIndex + counter)
             {
                 ProfilerLogMsg msg = tc.LogMessages[startIndex + counter];
                 ListViewItem   li  = new ListViewItem((startIndex + counter + 1).ToString("0000"));
                 ListViewItem.ListViewSubItem lsi = new ListViewItem.ListViewSubItem(li, msg.ToString());
                 li.SubItems.Add(lsi);
                 if ((int)msg.Level == (int)ProfilerLogMsg.LogLevels.Debug)
                 {
                     li.BackColor = Color.Yellow;
                 }
                 else if ((int)msg.Level == (int)ProfilerLogMsg.LogLevels.Error)
                 {
                     li.BackColor = Color.Crimson;
                 }
                 else
                 {
                     li.BackColor = Color.White;
                 }
                 if (msg.Timeout)
                 {
                     li.ForeColor = Color.Gray;
                 }
                 lstResultList.Items.Add(li);
             }
             else
             {
                 break;
             }
         }
         catch
         {
         }
     }
     //heighMsgText();
     this.Cursor = Cursors.Default;
 }
예제 #3
0
        private void ddlistTestCases_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            int selectedIndex = ddlistTestCases.DropDownItems.IndexOf(e.ClickedItem);

            if (profilerLog != null && selectedIndex != currentTCIndex)
            {
                currentPageIndex = -1;
                currentTCIndex   = selectedIndex;
                selectedTestCase = profilerLog.TestCaseList[selectedIndex];
                ddlistSplitedLogPage.DropDownItems.Clear();
                for (int i = 1; i < selectedTestCase.LogMessages.Count; i += logMsgSpliteSize)
                {
                    ddlistSplitedLogPage.DropDownItems.Add(i.ToString() + " ~");
                }
                ddlistSplitedLogPage.Text = "1 ~";
                showLogMsgOfTestCase(selectedTestCase);
                ddlistSplitedLogPage.Visible = selectedTestCase != null;
                lblLines.Visible             = selectedTestCase != null;
                ddlistTestCases.Text         = e.ClickedItem.Text;
            }
        }
예제 #4
0
        public bool Parse()
        {
            bool result = false;

            if (File.Exists(LogFullPath))
            {
                StreamReader sr = null;
                testCaseList.Clear();
                try
                {
                    sr = new StreamReader(LogFullPath);
                    while (!sr.EndOfStream)
                    {
                        ProfilerLogMsg newMsg = parseLog_OneLine(sr.ReadLine());
                        if (newMsg != null)
                        {
                            if (newMsg.Header.ToUpper().Contains("LOG OPTIONS"))
                            {
                                #region The keyword of creating a new test case.
                                ProfilerLog_TestCase newTestCase = new ProfilerLog_TestCase();
                                newTestCase.LOG_OPTIONS = newMsg.Message;
                                testCaseList.Add(newTestCase);
                                currentTestCase = newTestCase;
                                #endregion The keyword of creating a new test case.
                            }
                            else if (newMsg.Header.ToLower().Contains("script version"))
                            {
                                try
                                {
                                    currentTestCase.Version = newMsg.Header.Split(':')[1].Trim();
                                }
                                catch
                                {
                                }
                            }
                            else if (newMsg.Header.ToLower().Contains("script title"))
                            {
                                try
                                {
                                    currentTestCase.Title = newMsg.Header.Split(':')[1].Trim();
                                }
                                catch
                                {
                                }
                            }
                            #region Battery Infomation Related
                            else if (newMsg.Header.ToLower().Trim().Equals("battery module"))
                            {
                                #region AC Power Status, the keyword to create new BatteryInfo object
                                if (newMsg.Message.ToLower().Contains("ac power status"))
                                {
                                    BatteryInfo batInfo = new BatteryInfo();
                                    try
                                    {
                                        batInfo.AC_Status = newMsg.Message.Split('|')[1];
                                        batInfo.Time      = newMsg.MsgTime;
                                    }
                                    catch
                                    {
                                    }
                                    currentBatteryInfo = batInfo;
                                }
                                #endregion  AC Power Status, the keyword to create new BatteryInfo object
                                #region Battery Life Percent
                                else if (newMsg.Message.ToLower().Contains("batterylifepercent"))
                                {
                                    try
                                    {
                                        currentBatteryInfo.Percentage = Convert.ToDouble(newMsg.Message.Split('|')[1]);
                                    }
                                    catch
                                    {
                                    }
                                }
                                #endregion Battery Life Percent
                                #region Voltage
                                else if (newMsg.Message.ToLower().Contains("batteryvoltage"))
                                {
                                    try
                                    {
                                        String strVoltage = newMsg.Message.Split('|')[1];
                                        strVoltage = strVoltage.Replace("mV", "").Trim();
                                        currentBatteryInfo.Voltage = Convert.ToInt32(strVoltage);
                                    }
                                    catch
                                    {
                                    }
                                }
                                #endregion Voltage
                                #region Temperature
                                else if (newMsg.Message.ToLower().Contains("batterytemperature"))
                                {
                                    try
                                    {
                                        String strTemperature = newMsg.Message.Split('|')[1];
                                        strTemperature = strTemperature.Replace("degrees Celsius", "").Trim();
                                        currentBatteryInfo.Temperature = Convert.ToDouble(strTemperature);
                                    }
                                    catch
                                    {
                                    }
                                }
                                #endregion Temperature
                                #region AverageBatteryCurrent,the key word of end section of the BatteryInfo
                                else if (newMsg.Message.ToLower().Contains("averagebatterycurrent"))
                                {
                                    try
                                    {
                                        String strCurrent = newMsg.Message.Split('|')[1];
                                        strCurrent = strCurrent.Replace("mA", "").Trim();
                                        currentBatteryInfo.AvgCurrent = Convert.ToInt32(strCurrent);
                                    }
                                    catch
                                    {
                                    }
                                    if (currentBatteryInfo.Percentage != batteryPercentageTemp)
                                    {
                                        currentTestCase.BatteryInfoList.Add(currentBatteryInfo);
                                        batteryPercentageTemp = currentBatteryInfo.Percentage;
                                    }
                                    else //Discard currentBatteryInfo if the percentage is not changed.
                                    {
                                        currentBatteryInfo = null;
                                    }
                                }
                                #endregion AverageBatteryCurrent,the key word of end section of the BatteryInfo
                            }
                            #endregion  Battery Infomation Related
                            currentTestCase.LogMessages.Add(newMsg);
                            if (newMsg.Level.Equals(ProfilerLogMsg.LogLevels.Error))
                            {
                                currentTestCase.ErrorIndexList.Add(currentTestCase.LogMessages.Count - 1);
                            }
                        }
                    }
                    result = true;
                }
                catch
                {
                }
                finally
                {
                    if (sr != null)
                    {
                        sr.Close();
                    }
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
예제 #5
0
 /*
  * private void readAndParseLog()
  * {
  *  int passCount = 0;
  *  int failCount = 0;
  *  if (File.Exists(currentLogPath))
  *  {
  *
  *     StreamReader sr = null;
  *     Regex rgxPass = new Regex(@"\|(\s*)(?i:info)(\s*)\|");
  *     Regex rgxFail = new Regex(@"\|(\s*)(?i:error)(\s*)\|");
  *     Match m;
  *     try
  *     {
  *         sr = new StreamReader(currentLogPath);
  *         while (!sr.EndOfStream && parseLog_Flag)
  *         {
  *             String line = sr.ReadLine();
  *             m = rgxPass.Match(line);
  *             if (m.Success)
  *             {
  *                 passCount++;
  *                 rtxtLogAppendNewText(line);
  *             }
  *             m = rgxFail.Match(line);
  *             if (m.Success)
  *             {
  *                 failCount++;
  *                 rtxtLogAppendNewText(line, Color.Crimson);
  *             }
  *             updateStatusLabel("Pass = "******"    ;    Fail = " + failCount, Color.Black);
  *         }
  *         updateStatusLabel("Pass = "******"    ;    Fail = " + failCount + (parseLog_Flag ? ", finished!" : ", interuputed!"), (parseLog_Flag?Color.Green:Color.Red));
  *     }
  *     catch
  *     {
  *     }
  *     if (sr != null)
  *     {
  *         sr.Close();
  *     }
  *  }
  *  parseLog_Flag = false;
  *  parseLogStausChanged();
  * }
  */
 private void showLogMsgOfTestCase(ProfilerLog_TestCase tc)
 {
     showLogMsgOfTestCase(tc, 0, logMsgSpliteSize);
     currentPageIndex = 0;
 }