}// End of button1_Click function /// <summary> /// Don't know if this is working hehe /// </summary> /// <param name="report_list"></param> public void order_global_reports(IList <ReportVO> report_list, IList <Category> categories) { IList <ReportVO> results = new List <ReportVO>(); for (int i = 0; i < report_array.Length; i++) { for (int j = i; j < report_array.Length; j++) { int date_compare = DateTime.Compare(DateTime.Parse(report_array[i].total_time), DateTime.Parse(report_array[j].total_time)); if (report_array[j].total_time != "00:00:00") { if (date_compare > 0 || report_array[i].total_time == "00:00:00") { ReportVO temp = report_array[i]; report_array[i] = report_array[j]; report_array[j] = temp; report_array[i].global_score = i + 1; report_array[j].global_score = j + 1; }// End of compare validation else { report_array[i].global_score = i + 1; report_array[j].global_score = j + 1; } } else { report_array[i].global_score = i + 1; report_array[j].global_score = j + 1; } } // End of second loop pbGenerating.Value = (100 * (i + 1)) / report_array.Length; } // End of first loop foreach (Category cat in categories) { int h = 1; for (int k = 0; k < report_array.Length; k++) { if (report_array[k].category == cat.name) { report_array[k].category_score = h; h++; } } // End of reports loop } // End of categories loop } // End of order_global_reports function
}// End of Report Control constructor public IList <ReportVO> createReportsCategories(Competition competition, Category cat) { // init the reports array IList <ReportVO> reports = new List <ReportVO>(); // 5.- get the time registers for the respective register // Get the competitors pbDataProgress.Value = 0; IList <Competitor> competitors = event_control.competitor_service.getAll(null); pbDataProgress.Value = 33; IList <Category> categories = event_control.category_service.getAll(null); pbDataProgress.Value = 66; // Init temporal shit IList <Register> registers = getRegisters(competition); pbDataProgress.Value = 100; IList <TimeReg> time_regs = new List <TimeReg>(); // 4.- get the registes for the repective comeptition foreach (Register r in registers) { ReportVO report = new ReportVO(); // 6.- get the competitor for the respective regiser Competitor comp = competitors.Where(competitor => competitor.id == r.competitor).ToList().First(); // 7.- create the report object with all the data you have- // the competition, register, competitor, time registers time_regs = event_control.time_reg_service.getByRegister(r, null); TimeReg time_reg_temp = new TimeReg(); time_reg_temp.register = r.id; time_reg_temp.time = txtStartTime.Text; time_regs.Insert(0, time_reg_temp); // 8.- fill the list of times on the report with the time registers report.competitors_name = string.Format("{0} {1}", comp.name, comp.second_name); report.competitor_num = r.competitor_num; report.category = categories.Where(category => category.id == r.category).ToList().First().name; // loop time registers foreach (TimeReg tr in time_regs) { if (tr != time_regs.First()) { TimeSpan dif = DateTime.Parse(tr.time).Subtract(DateTime.Parse(time_regs.First().time)); report.times.Add(dif.ToString()); } } // Validate it the time_registers has none, it means something went wrong with the competitor if (time_regs.Count > 0) { report.disqualified = false; report.total_time = DateTime.Parse(time_regs.Last().time).Subtract(DateTime.Parse(time_regs.First().time)).ToString(); } // Else just put a 0; us tin case else { report.disqualified = true; report.total_time = "00:00:00"; } // Add the report to the reports array reports.Add(report); } // Fill the array that will contain the number fill_array(reports); // order the reports globally order_global_reports_by_category(reports, categories, cat); // Return the reports just in case duh! return(reports); }// End of createReportsCategories function