Esempio n. 1
0
 private void ResponseAddYear(QuestionDataResponseYear value)
 {
     _responseYears.Add(new ResponseReader.ResponseYear(value.Year, value.ColumnIndex, value.Length));
 }
Esempio n. 2
0
        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);
        }