// Converts a string to a TestReplay object public void parseTestReplayFile(string testReplayString) { bool inActionSection = true; List<string> testStrings = testReplayString.Split('\n').Cast<string>().ToList<string>(); List<string> firstLineWords = testStrings[0].Split(' ').Cast<string>().ToList<string>(); parsePatientInfo(firstLineWords); string startTimeString = testStrings[1]; startTime = Convert.ToDateTime(startTimeString); int foundEndTestLine = 0; List<string> LEGACY_endTestCheckLine = testStrings[2].Split(' ').Cast<string>().ToList<string>(); if (LEGACY_endTestCheckLine[0].Contains('/')) { string endTimeString = testStrings[2]; endTime = Convert.ToDateTime(endTimeString); foundEndTestLine = 1; } for(int i = 2 + foundEndTestLine; i < testStrings.Count; i++) { if (inActionSection) { List<string> lineWords = testStrings[i].Split(' ') .Cast<string>().ToList<string>(); if (lineWords[0] == "line") ((Stroke)testActions[testActions.Count - 1]) .addLineData(parseLineLineData(lineWords)); else if (lineWords[0] == "Stroke") testActions.Add(parseLineStroke(lineWords)); else if (lineWords[0] == "DeleteStroke") testActions.Add(parseLineDelPrevStroke(lineWords)); else if (lineWords[0] == "=====TIMES=====") { inActionSection = false; } else if (lineWords[0] == "=====ERRORS====") { inActionSection = false; } else if (lineWords[0] == "=====NOTES=====") { inActionSection = false; } } else { // Parse all the error objects. Each one should be three nodes plus a Date List<string> lineWords = testStrings[i] .Split('\t').Cast<string>().ToList<string>(); // This is a node completion object. // Should be read as: //begin node '\t' point //end node '\t' point //DateTime if (lineWords.Count == 7) { NodeCompletion completion = new NodeCompletion(); // Get each of the node strings and points from the line for (int j = 0; j < 6; j += 3) { string beginText = lineWords[j]; Point point; point.X = Convert.ToDouble(lineWords[j + 1]); point.Y = Convert.ToDouble(lineWords[j + 2]); bool flip = true; if (testType.ToString().Contains("_H")) flip = false; TrailNode node = new TrailNode(beginText, point, flip); if (j == 0) completion.setBegin(node); if (j == 3) completion.setEnd(node); } DateTime date = new DateTime(); date = Convert.ToDateTime(lineWords[6]); completion.setTime(date); testCompletions.Add(completion); } // This is an error object. // Should be read as: //begin node '\t' point //exp end node '\t' point //act end node '\t' point //DateTime else if(lineWords.Count == 10) { TestError error = new TestError(); // Get each of the node strings and points from the line for(int j = 0; j < 9; j += 3) { string beginText = lineWords[j]; Point point; point.X = Convert.ToDouble(lineWords[j + 1]); point.Y = Convert.ToDouble(lineWords[j + 2]); bool flip = true; if(testType.ToString().Contains("_H")) flip = false; TrailNode node = new TrailNode(beginText, point, flip); if(j == 0) error.setBegin(node); if (j == 3) error.setExpected(node); if (j == 6) error.setActual(node); } DateTime date = new DateTime(); date = Convert.ToDateTime(lineWords[9]); error.setTime(date); testErrors.Add(error); } else if (lineWords.Count >= 5) { DateTime date = new DateTime(); date = DateTime.Parse(lineWords[0] + " " + lineWords[1] + " " + lineWords[2]); lineWords[3] = lineWords[3].Replace("[SPC]", ""); lineWords[4] = lineWords[4].Replace("[SPC]", ""); testNotes.Add( new PatientNote(lineWords[3], lineWords[4], date)); } } } }
// Add a TestError to the list of errors in the TestReplay class public void addError(TestError e) { testErrors.Add(e); }