Пример #1
0
        private void WriteComments(TextBox commentsSection, ObservableCollection <ReportArea> AreasLocations)
        {
            commentsSection.Text = "";
            ObservableCollection <ReportArea> problemAreas = new ObservableCollection <ReportArea>();

            ReportArea usedForSorting = new ReportArea();

            foreach (ReportArea a in AreasLocations)
            {
                usedForSorting.RelatedReports.Add(a);
            }
            usedForSorting.sortRelatedReportsByRating();
            foreach (ReportArea a in usedForSorting.RelatedReports)
            {
                //TODO: sort by rating
                string betterString = "";
                if (a.RatingInt == "0" || a.RatingInt == "1" || a.RatingInt == "2")
                {
                    int index;

                    if ((index = a.Comment.IndexOf("(3)")) != -1)
                    {
                        betterString = a.Comment.Substring(0, index);
                    }
                    else
                    {
                        betterString = a.Comment;
                    }
                    commentsSection.Text += String.Format("{0}: {1}\n", a.Name, betterString);
                }
            }
        }
Пример #2
0
        //Summaries dont summarize atm
        private List <ReportArea> GetSummaries(string[] filePaths)
        {
            List <ReportArea> reportAreasSummary = new List <ReportArea>();

            //for each txt file
            foreach (string path in filePaths)
            {
                //Get the report
                ReportArea newReport = GetReportArea(path);
                //Learn Linq
                //check to see if it is existing
                bool IsExisting = false;
                foreach (ReportArea existingReport in reportAreasSummary)
                {
                    if (newReport.Name == existingReport.Name)
                    {
                        existingReport.RelatedReports.Add(newReport);
                        IsExisting = true;
                        break;
                    }
                }
                if (!IsExisting)
                {
                    reportAreasSummary.Add(newReport);
                }
            }
            foreach (ReportArea ra in reportAreasSummary)
            {
                //ra.Summarize();
            }
            return(reportAreasSummary);
        }
Пример #3
0
        private void WriteComments(TextBox commentsSection, ObservableCollection<ReportArea> AreasLocations)
        {
            commentsSection.Text = "";
            ObservableCollection<ReportArea> problemAreas = new ObservableCollection<ReportArea>();

            ReportArea usedForSorting = new ReportArea();
            foreach (ReportArea a in AreasLocations)
            {
                usedForSorting.RelatedReports.Add(a);
            }
            usedForSorting.sortRelatedReportsByRating();
            foreach (ReportArea a in usedForSorting.RelatedReports)
            {
                //TODO: sort by rating
                string betterString = "";
                if (a.RatingInt == "0" || a.RatingInt == "1" || a.RatingInt == "2")
                {
                    int index;

                    if((index = a.Comment.IndexOf("(3)")) != -1){
                        betterString = a.Comment.Substring(0, index);
                    }
                    else
                    {
                        betterString = a.Comment;
                    }
                    commentsSection.Text += String.Format("{0}: {1}\n", a.Name, betterString);
                }

            }
        }
Пример #4
0
        private ReportArea GetReportArea(string filePath)
        {
            //This could be a function of the ReportArea class (constructor even)
            string[] lines = File.ReadAllLines(filePath);
            ReportArea a = new ReportArea();
            string issue = "";
            foreach (string line in lines)
            {
                if (line.StartsWith("Area: "))
                {
                    a.Name = line.Substring(6);
                }
                else if (line.StartsWith("Rating: "))
                {
                    a.RatingInt = line.Substring(8);
                }
                else if (line.StartsWith("Issue: "))
                {
                    //issue should always come before comments
                    if (issue.StartsWith("None") || issue.StartsWith(@"N/A"))
                    {
                        issue = "";
                    }
                    issue = line.Substring(7) + ": ";
                }
                else if (line.StartsWith("Comment/s:"))
                {
                    int curIndex = Array.IndexOf(lines,line);
                    //parsing for comment
                    string newComment = issue;
                    //if the string is long enough
                    if (lines[curIndex].Length > 10 ||
                        !string.IsNullOrEmpty(lines[curIndex+1].Trim()))
                    {
                        //Get first line of comments
                        newComment += lines[curIndex].Substring(10).Trim();
                        //if there's more than one line
                        if (lines.Length > curIndex + 1)
                        {
                            //add the rest of the lines
                            for (int i = curIndex + 1; i < lines.Length; i++)
                            {
                                newComment += lines[i].Trim() + " ";
                            }
                            newComment = newComment.Trim() + ". ";
                        }
                    }
                    if(newComment.StartsWith("No Defect Visible:") ||
                        newComment.StartsWith("None:"))
                    {
                        a.Comment = "";
                    }
                    else
                    {
                        a.Comment = newComment;
                    }

                }
            }
            if (string.IsNullOrEmpty(a.RatingInt)) { a.RatingInt = "NA"; }
            //set the rating
            switch (a.RatingInt)
            {
                case "0":
                case "1":
                    {
                        a.RatingFlag = "A";
                        break;
                    }
                case "2":
                case "3":
                    {
                        a.RatingFlag = "F";
                        break;
                    }
                case "4":
                    {
                        a.RatingFlag = "D";
                        break;
                    }
                default:
                    {
                        //TODO check this is the right NA for ASAM upload
                        a.RatingFlag = "NA";
                        break;
                    }
            }
            return a;
        }
Пример #5
0
        private ReportArea GetReportArea(string filePath)
        {
            //This could be a function of the ReportArea class (constructor even)
            string[]   lines = File.ReadAllLines(filePath);
            ReportArea a     = new ReportArea();
            string     issue = "";

            foreach (string line in lines)
            {
                if (line.StartsWith("Area: "))
                {
                    a.Name = line.Substring(6);
                }
                else if (line.StartsWith("Rating: "))
                {
                    a.RatingInt = line.Substring(8);
                }
                else if (line.StartsWith("Issue: "))
                {
                    //issue should always come before comments
                    if (issue.StartsWith("None") || issue.StartsWith(@"N/A"))
                    {
                        issue = "";
                    }
                    issue = line.Substring(7) + ": ";
                }
                else if (line.StartsWith("Comment/s:"))
                {
                    int curIndex = Array.IndexOf(lines, line);
                    //parsing for comment
                    string newComment = issue;
                    //if the string is long enough
                    if (lines[curIndex].Length > 10 ||
                        !string.IsNullOrEmpty(lines[curIndex + 1].Trim()))
                    {
                        //Get first line of comments
                        newComment += lines[curIndex].Substring(10).Trim();
                        //if there's more than one line
                        if (lines.Length > curIndex + 1)
                        {
                            //add the rest of the lines
                            for (int i = curIndex + 1; i < lines.Length; i++)
                            {
                                newComment += lines[i].Trim() + " ";
                            }
                            newComment = newComment.Trim() + ". ";
                        }
                    }
                    if (newComment.StartsWith("No Defect Visible:") ||
                        newComment.StartsWith("None:"))
                    {
                        a.Comment = "";
                    }
                    else
                    {
                        a.Comment = newComment;
                    }
                }
            }
            if (string.IsNullOrEmpty(a.RatingInt))
            {
                a.RatingInt = "NA";
            }
            //set the rating
            switch (a.RatingInt)
            {
            case "0":
            case "1":
            {
                a.RatingFlag = "A";
                break;
            }

            case "2":
            case "3":
            {
                a.RatingFlag = "F";
                break;
            }

            case "4":
            {
                a.RatingFlag = "D";
                break;
            }

            default:
            {
                //TODO check this is the right NA for ASAM upload
                a.RatingFlag = "NA";
                break;
            }
            }
            return(a);
        }