/// <summary> /// For each survey in the report, fill the question list, comments and translations as needed. /// </summary> private void PopulateSurveys() { // populate the survey and extra fields foreach (ReportSurvey rs in SR.Surveys) { if (filterBy == 1) { rs.QRangeHigh = questionFilters.QRangeHigh; rs.QRangeLow = questionFilters.QRangeLow; rs.Prefixes = null; rs.Headings = null; } else if (filterBy == 2) { rs.QRangeHigh = 0; rs.QRangeLow = 0; rs.Prefixes = questionFilters.Prefixes; rs.Headings = null; } else if (filterBy == 3) { rs.QRangeHigh = 0; rs.QRangeLow = 0; rs.Prefixes = null; rs.Headings = questionFilters.Headings; } rs.Varnames = questionFilters.Varnames; rs.Questions.Clear(); rs.SurveyNotes.Clear(); rs.VarChanges.Clear(); // questions if (rs.Backend.Date != DateTime.Today) { rs.AddQuestions(new BindingList <SurveyQuestion>(DBAction.GetBackupQuestions(rs, rs.Backend))); } else { DBAction.FillQuestions(rs); } // correct questions // TODO should we only get corrected for current data? if (rs.Corrected) { DBAction.FillCorrectedQuestions(rs); rs.CorrectWordings(); } // previous names (for Var column) DBAction.FillPreviousNames(rs, SR.ExcludeTempChanges); if (compare.MatchOnRename && rs.Backend.Date != DateTime.Today) { foreach (SurveyQuestion sq in rs.Questions) { sq.VarName = new VariableName(DBAction.GetCurrentName(rs.SurveyCode, sq.VarName.FullVarName, rs.Backend)); } } // survey notes if (SR.SurvNotes) { rs.SurveyNotes = DBAction.GetSurvCommentsBySurvey(rs.SID); } // comments if (rs.CommentFields.Count > 0) { DBAction.FillCommentsBySurvey(rs); } // translations foreach (string language in rs.TransFields) { DBAction.FillTranslationsBySurvey(rs, language); } // filters if (rs.FilterCol) { rs.MakeFilterList(); } // varchanges (for appendix) if (SR.VarChangesApp) { rs.VarChanges = DBAction.GetVarNameChangeBySurvey(rs.SurveyCode, SR.ExcludeTempChanges); } } }