private void btParetoChartRefresh_Click(object sender, RoutedEventArgs e)
        {
            List <string> selectedLines = (from line in availableLineList
                                           where line.IsSelected == true
                                           select line.LineID).ToList();
            List <string> selectedTesters = (from tester in testList.availableTesterList
                                             where tester.IsSelected == true
                                             select tester.TesterID).ToList();

            desiredStartDateTimeForPareto = this.dtpStartDateForPareto.SelectedDate;
            desiredStartDateTimeForPareto = new DateTime(desiredStartDateTimeForPareto.Value.Year, desiredStartDateTimeForPareto.Value.Month, desiredStartDateTimeForPareto.Value.Day, 0, 0, 0);

            desiredEndDateTimeForPareto = this.dtpEndDateForPareto.SelectedDate;
            desiredEndDateTimeForPareto = new DateTime(desiredEndDateTimeForPareto.Value.Year, desiredEndDateTimeForPareto.Value.Month, desiredEndDateTimeForPareto.Value.Day, 23, 59, 59);

            dtTesterPareto.Rows.Clear();

            //Get the data by slot.
            foreach (string line in selectedLines)
            {
                foreach (string tester in selectedTesters)
                {
                    //Only query the data if the tester is in the correct line.
                    if (TesterMap[line].Contains(tester))
                    {
                        if (this.cbByPosition.IsChecked.Value)
                        {
                            for (int position = 1; position <= 4; position++)
                            {
                                //Get the data by position.
                                DefectsBreakDown defectPattern = myDatabase.GetDefectsBreakdownOfPosition(activeTableName, line, tester, position.ToString(), desiredStartDateTimeForPareto.Value, desiredEndDateTimeForPareto.Value);
                                this.AddRowToParetoDataTable(defectPattern);
                            }
                        }
                        else
                        {
                            //Get the data by tester.
                            DefectsBreakDown defectPattern = myDatabase.GetDefectsBreakdownOfTester(activeTableName, line, tester, desiredStartDateTimeForPareto.Value, desiredEndDateTimeForPareto.Value);
                            this.AddRowToParetoDataTable(defectPattern);
                        }
                    }
                }
            }
            foreach (string line in selectedLines)
            {
                DefectsBreakDown defectPattern = myDatabase.GetDefectsBreakdownOfLine(activeTableName, line, desiredStartDateTimeForPareto.Value, desiredEndDateTimeForPareto.Value);
                this.AddRowToParetoDataTable(defectPattern);
            }
        }
        private void AddRowToParetoDataTable(DefectsBreakDown defectsBySlot)
        {
            DataRow row = dtTesterPareto.NewRow();

            row["LineId"]     = defectsBySlot.lineId;
            row["TesterId"]   = defectsBySlot.testerId;
            row["PositionId"] = defectsBySlot.positionId;
            row["InputCount"] = defectsBySlot.inputCount;
            row["FailCount"]  = defectsBySlot.failureCount;
            if (defectsBySlot.inputCount != 0)
            {
                row["FailRate"] = Math.Round(100.0 * defectsBySlot.failureCount / defectsBySlot.inputCount, 3);
            }
            for (int i = 0; i < Math.Min(5, defectsBySlot.FailurePattern.Count); i++)
            {
                string header1 = $"Top{i + 1}EC";
                string header2 = $"Top{i + 1}Count";
                string value1  = defectsBySlot.FailurePattern.ElementAt(i).Key;
                int    value2  = defectsBySlot.FailurePattern.ElementAt(i).Value;
                row[header1] = value1;
                row[header2] = value2;
            }
            dtTesterPareto.Rows.Add(row);
        }