private void WriteIndividualReports() { app = new Word.Application(); numberOfQuantitativeQuestions = surveyEntries.First().Questions.Where(q => q.IsQuantitative == true).Count(); foreach (var individualReport in individualReports) { currentIndividualReport = individualReport; doc = app.Documents.Add(ref reportTemplateLocation); individualReport.SurveyEntries = surveyEntries.Where(se => se.SurveyId == currentIndividualReport.ReportId); WriteBasicReportInformation(); WriteSurveySpecificReportInformation(); object filename = Path.Combine(reportsDestination, $"{currentIndividualReport.UnitCode} - {currentIndividualReport.Lecturer}.pdf"); doc.SaveAs2(filename, Word.WdSaveFormat.wdFormatPDF); doc.Close(Word.WdSaveOptions.wdDoNotSaveChanges); ProgressCompleted?.Invoke(this, $" Individual report for {currentIndividualReport.UnitCode} - {currentIndividualReport.Lecturer} has been completed"); } app.Quit(); }
static void Main(string[] args) { foreach (string arg in args) { LoadFile(arg); } // // Download the "Scout" backup report from Scoutbook and rename // the file "scouts.csv" // LoadPatrolLookup("./scouts.csv"); { var report = new TroopReport(scouts); report.Run(@"./TroopAdvancementChart.xlsx"); } { var report = new IndividualReport(scouts); report.Run(@"./IndividualReport.xlsx"); } { var report = new EagleReport(scouts); report.Run(@"./EagleReport.xlsx"); } }
private void WriteSummaryReport() { var stringBuilder = new StringBuilder(); IList <string> header = new List <string>(); if (surveyName == SurveyNames.StudentSurveyOnLecturer) { header.Add("Unit Code"); header.Add("Unit Name"); header.Add("Lecturer"); header.Add("Overall Performance Indicator (%)"); header.Add("Status"); header.Add("Number of Flag"); header.Add("Response Rate (%)"); header.Add("Response"); header.Add("Population"); header.Add("Question 1"); header.Add("Question 2"); header.Add("Question 3"); header.Add("Question 4"); header.Add("Question 5"); header.Add("Question 6"); header.Add("Question 7"); header.Add("Question 8"); header.Add("Question 9"); header.Add("Question 10"); } else if (surveyName == SurveyNames.UnitAndLecturerSurvey) { header.Add("Unit Code"); header.Add("Unit Name"); header.Add("Lecturer"); header.Add("Overall Performance Indicator (%)"); header.Add("Status"); header.Add("Number of Flag"); header.Add("Response Rate (%)"); header.Add("Response"); header.Add("Population"); header.Add("Question 1"); header.Add("Question 2"); header.Add("Question 3"); header.Add("Question 4"); header.Add("Question 5"); header.Add("Question 6"); header.Add("Question 9"); header.Add("Question 10"); header.Add("Question 11"); header.Add("Question 12"); } stringBuilder.AppendLine(string.Join(",", header.ToArray())); IList <string> body = new List <string>(); foreach (var individualReport in individualReports) { currentIndividualReport = individualReport; var totalPerformance = Math.Round(100 * currentIndividualReport.TotalPerformance, 0); string status; if (totalPerformance < 80) { if (totalPerformance < 70) { status = "poor"; } else { status = "alert"; } } else { status = "good"; } body.Clear(); body.Add(individualReport.UnitCode); body.Add(individualReport.UnitName); body.Add(individualReport.Lecturer); body.Add(totalPerformance.ToString()); body.Add(status); body.Add(individualReport.Flags.Count.ToString()); body.Add(GetPercentage((double)currentIndividualReport.Response / currentIndividualReport.ClassSize)); body.Add(currentIndividualReport.Response.ToString()); body.Add(currentIndividualReport.ClassSize.ToString()); if (surveyName == SurveyNames.StudentSurveyOnLecturer) { for (int questionNumber = 1; questionNumber <= 10; questionNumber++) { var performance = currentIndividualReport.AllQuestions.Where(q => q.QuestionNumber == questionNumber && (q.Answer == QuantitativeChoices.StronglyAgree || q.Answer == QuantitativeChoices.Agree)).Count(); body.Add(performance.ToString()); } } else { for (int questionNumber = 1; questionNumber <= 6; questionNumber++) { var performance = currentIndividualReport.AllQuestions.Where(q => q.QuestionNumber == questionNumber && (q.Answer == QuantitativeChoices.StronglyAgree || q.Answer == QuantitativeChoices.Agree)).Count(); body.Add(performance.ToString()); } for (int questionNumber = 9; questionNumber <= 12; questionNumber++) { var performance = currentIndividualReport.AllQuestions.Where(q => q.QuestionNumber == questionNumber && (q.Answer == QuantitativeChoices.StronglyAgree || q.Answer == QuantitativeChoices.Agree)).Count(); body.Add(performance.ToString()); } } stringBuilder.AppendLine(string.Join(",", body.ToArray())); } File.WriteAllText(Path.Combine(reportsDestination, "SummaryReport.csv"), stringBuilder.ToString()); ProgressCompleted?.Invoke(this, "Summary report has been completed"); }