public static IEnumerable <TextData> Test_ReadQuestionFiles(string directory, int limit = 0) { directory = zPath.Combine(XmlConfig.CurrentConfig.GetExplicit("CardDirectory"), directory); //TextDataReader textDataReader = new TextDataReader(QuestionsManager.GetScanFiles(directory, limit)); TextDataReader textDataReader = new TextDataReader(); textDataReader.SetRegexList(CreateQuestionRegexValuesList()); //return textDataReader.Read(QuestionsManager.GetScanFiles(zPath.Combine(directory, @"data\scan"), limit)); int pageNumber = 1; foreach (TextData textData in textDataReader.Read(QuestionsManager.GetScanFiles(zPath.Combine(directory, @"data\scan"), limit))) { yield return(textData); if (textData.Values.ContainsKey("pageNumber")) { pageNumber++; } if (textData.Values.ContainsKey("responses") && pageNumber > 1) { textDataReader.SetRegexList(CreateResponseRegexValuesList()); textDataReader.ContiguousSearch = true; } } }
public static IEnumerable <QuestionData> Test_ReadQuestionFilesAsQuestionData_v2(string directory, int limit = 0) { directory = zPath.Combine(XmlConfig.CurrentConfig.GetExplicit("CardDirectory"), directory); //TextDataReader textDataReader = new TextDataReader(QuestionsManager.GetScanFiles(directory, limit)); TextDataReader textDataReader = new TextDataReader(); textDataReader.SetRegexList(CreateQuestionRegexValuesList()); foreach (QuestionData value in textDataReader.Read(QuestionsManager.GetScanFiles(zPath.Combine(directory, @"data\scan"), limit)).Select(textData => QuestionData.CreateQuestionData(textData))) { if (value.Type == QuestionDataType.Responses) { //Trace.WriteLine("read responses"); textDataReader.SetRegexList(CreateResponseRegexValuesList()); textDataReader.ContiguousSearch = true; } yield return(value); } }
public static void Test_QuestionReader_Comparev1v2(IEnumerable <string> directories, string outputDirectory) { string baseDirectory = XmlConfig.CurrentConfig.GetExplicit("CardDirectory"); QuestionReader_v2 questionReader_v2 = CreateQuestionReader_v2(); foreach (string directory in directories) { Trace.WriteLine($"compare QuestionReader for \"{directory}\""); string directory2 = zPath.Combine(baseDirectory, directory); string file1 = zPath.Combine(outputDirectory, "questions.json"); string file2 = zPath.Combine(outputDirectory, "questions_v2.json"); QuestionRun.CreateQuestionsManager(directory2).ReadQuestions().zSave(file1, jsonIndent: true); questionReader_v2.Read(QuestionsManager.GetScanFiles(zPath.Combine(directory2, @"data\scan")), baseDirectory) .Select(question => (Question_v2)question).zSave(file2, jsonIndent: true); if (!zfile.AreFileEqual(file1, file2)) { Trace.WriteLine(" files are differents"); break; } } }
// string baseDirectory public static IEnumerable <QuestionResponse_v2> Test_QuestionReader_v2(string directory, int limit = 0) { string baseDirectory = XmlConfig.CurrentConfig.GetExplicit("CardDirectory"); return(CreateQuestionReader_v2().Read(QuestionsManager.GetScanFiles(zPath.Combine(baseDirectory, directory, @"data\scan"), limit), baseDirectory)); }