예제 #1
0
        public void ResultsToCsv()
        {
            var fileName = Path.Combine(Event.Instance.DraftsFolder, "Task " + UltraShortDescription + " results.csv");
            var sb       = new StringBuilder();

            sb.AppendLine("Task " + Description + " results");
            //sb.AppendLine(string.Format("{0:d} {1}", Date, Date.Hour < 12 ? "AM" : "PM"));

            //table
            sb.AppendLine(
                String.Join("\t",
                            "Pilot number",
                            "Pilot name",
                            "Performance",
                            "Performance penalty",
                            "Task penalty",
                            "Comp. penalty",
                            "Notes/Rules"
                            )
                .Trim('\t')
                );

            foreach (var pilotResult in PilotResults.OrderBy(pr => pr.Pilot.Number))
            {
                var mr = pilotResult.ManualResultInfo;
                var ar = pilotResult.AutoResultInfo;

                sb.AppendLine(
                    String.Join("\t",
                                pilotResult.Pilot.Number.ToString(),
                                pilotResult.Pilot.Name,
                                ResultInfo.ToString(ResultInfo.MergeMeasure(mr.Measure, ar.Measure, 0)),
                                ResultInfo.ToString(ResultInfo.MergeMeasure(mr.MeasurePenalty, ar.MeasurePenalty, 0)),
                                ResultInfo.ToString(ResultInfo.MergePenalty(mr.TaskScorePenalty, ar.TaskScorePenalty, 1)),
                                ResultInfo.ToString(ResultInfo.MergePenalty(mr.CompetitionScorePenalty, ar.CompetitionScorePenalty, 1)),
                                String.Join(";", mr.InfringedRules, ar.InfringedRules).Trim(';')
                                )
                    .Trim('\t')
                    );
            }
            File.WriteAllText(fileName, sb.ToString());
        }
예제 #2
0
        public void ResultsToPdf(bool openAfterCreation)
        {
            var fileName = Path.Combine(Event.Instance.DraftsFolder, "Task " + UltraShortDescription + " results.pdf");
            var config   = Event.Instance.GetDefaultPdfConfig();

            var helper   = new PdfHelper(fileName, config);
            var document = helper.Document;

            //title
            document.Add(new Paragraph(Event.Instance.Name, config.TitleFont)
            {
                SpacingAfter = 10
            });
            //subtitle
            var title = "Task " + Description + " results";

            document.Add(new Paragraph(title, config.SubtitleFont));
            var date = string.Format("{0:d} {1}", Date, Date.Hour < 12 ? "AM" : "PM");

            document.Add(new Paragraph(date, config.BoldFont)
            {
                SpacingAfter = 10
            });

            //table
            var headers = new string[] {
                "Pilot",
                "Performance (M)", "Performance (A)",
                "Performance penalty (M)", "Performance penalty (A)",
                "Task penalty (M)", "Task penalty (A)",
                "Comp. penalty (M)", "Comp. penalty (A)",
                "Notes/Rules (M)", "Notes/Rules (A)"
            };
            var relWidths = new float[] { 8, 3, 3, 3, 3, 3, 3, 3, 3, 6, 6 };
            var table     = helper.NewTable(headers, relWidths, title);

            foreach (var pilotResult in PilotResults.OrderBy(pr => pr.Pilot.Number))
            {
                var mr = pilotResult.ManualResultInfo;
                var ar = pilotResult.AutoResultInfo;

                table.AddCell(helper.NewLCell(pilotResult.Pilot.Info));
                table.AddCell(helper.NewRCell(ResultInfo.ToString(mr.Measure)));
                table.AddCell(helper.NewRCell(ResultInfo.ToString(ar.Measure)));
                table.AddCell(helper.NewRCell(ResultInfo.ToString(mr.MeasurePenalty)));
                table.AddCell(helper.NewRCell(ResultInfo.ToString(ar.MeasurePenalty)));
                table.AddCell(helper.NewRCell(mr.TaskScorePenalty.ToString("0")));
                table.AddCell(helper.NewRCell(ar.TaskScorePenalty.ToString("0")));
                table.AddCell(helper.NewRCell(mr.CompetitionScorePenalty.ToString("0")));
                table.AddCell(helper.NewRCell(ar.CompetitionScorePenalty.ToString("0")));
                table.AddCell(helper.NewLCell(mr.InfringedRules));
                table.AddCell(helper.NewLCell(ar.InfringedRules));
            }
            document.Add(table);

            document.Close();

            if (openAfterCreation)
            {
                helper.OpenPdf();
            }
        }