private ResponseReader.ResponseQuestion ResponseCreateResponseQuestion(QuestionDataQuestionNumber value) { //if (_responseQuestion != null) //{ // SaveResponseQuestion(_responseQuestion); //} ResponseReader.ResponseQuestion responseQuestion = new ResponseReader.ResponseQuestion(value.QuestionNumber, value.ColumnIndex, value.Length) { SourceFile = GetSubPath(value.File), SourceFilename = value.Filename, SourceLineNumber = value.LineNumber }; responseQuestion.Year = GetYear(responseQuestion.Position); if (responseQuestion.Year == 0) { throw new PBFileException($"year not found, line {value.LineNumber} column {value.ColumnIndex + 1} file \"{value.Filename}\"", value.File, value.LineNumber); } return(responseQuestion); }
private QuestionResponse_v2 ReadResponse(QuestionData value) { Response_v2 response = null; if (_responseQuestion != null && value.Type != QuestionDataType.Response) { if (_trace) { //Trace.WriteLine($"save response question (line {value.LineNumber} \"{value.Filename}\")"); Trace.WriteLine($"save response question : {_responseQuestion.Year} - {_responseQuestion.QuestionNumber}"); } SaveResponseQuestion(_responseQuestion); _responseQuestion = null; } switch (value.Type) { case QuestionDataType.EmptyLine: if (_emptyLineCount == _responseMaxEmptyLine && _responseYears.Count > 0) { _responseEnd = true; } break; case QuestionDataType.ResponseCategory: _responseCategory = ((QuestionDataResponseCategory)value).Category; if (_trace) { Trace.WriteLine($"response category : {_responseCategory} (line {value.LineNumber} \"{value.Filename}\")"); } ControlRemindResponseQuestions(); _responseYears = new List <ResponseReader.ResponseYear>(); _responseQuestionBlock = false; break; case QuestionDataType.ResponseYear: QuestionDataResponseYear responseYear = (QuestionDataResponseYear)value; if (_responseQuestionBlock) { throw new PBException($"wrong response year position, line {responseYear.LineNumber} column {responseYear.ColumnIndex + 1} file \"{responseYear.Filename}\""); } if (_trace) { Trace.WriteLine($"response year : {responseYear.Year} (line {value.LineNumber} \"{value.Filename}\")"); } ResponseAddYear(responseYear); break; case QuestionDataType.QuestionNumber: //responseQuestion = NewQuestion(namedValue.Value.Value, namedValue.Value.Index, namedValue.Value.Length, responseQuestion); QuestionDataQuestionNumber questionNumber = (QuestionDataQuestionNumber)value; if (_trace) { Trace.WriteLine($"response question : {questionNumber.QuestionNumber} (line {value.LineNumber} \"{value.Filename}\")"); } _responseQuestion = ResponseCreateResponseQuestion(questionNumber); _responseQuestionBlock = true; break; case QuestionDataType.Response: QuestionDataResponse responseValue = (QuestionDataResponse)value; if (_responseQuestion != null && _responseQuestion.SourceLineNumber != responseValue.LineNumber) { SaveResponseQuestion(_responseQuestion); _responseQuestion = null; } response = SetResponse(responseValue, _responseQuestion); if (_trace) { Trace.WriteLine($"response : {response.Responses} question {response.Year} - {response.QuestionNumber} (line {value.LineNumber} \"{value.Filename}\")"); } _responseQuestion = null; break; } ControlResponseQuestions(); return(response); }