private void generateDataEventyForms_Click(object sender, RoutedEventArgs e) { List <AEvent> evs = new List <AEvent>(); //if ( ((App)Application.Current ).CurrentChampionship.Name.Contains ( "TF" ) ) //{ foreach (EventVM Event in ((App)Application.Current).CurrentChampionship.Events) { evs.Add(Event.Event); } try { Exports.GenerateResultEntryForms(evs, true); } catch (Exception ex) { MessageBox.Show("Failed to open results sheet. \n" + ex.Message); } //} //else //{ //// 2015-06-07 printBothResults is part of the cross country application. //new Print ( ).printBothResults ( evs , true ); //} }
private void OpenResultsCard_Click(object sender, RoutedEventArgs e) { if (Event == null) { return; } List <AEvent> evs = new List <AEvent>(); if (Event is IHeatEvent) { evs.Add(((IHeatEvent)Event).Final); } else { evs.Add(Event); } try { if (((App)App.Current).CurrentChampionship.ShortName.Contains("XC")) { Exports.printBothResults(evs, true); } else if (((App)App.Current).CurrentChampionship.ShortName.Contains("TF")) { Exports.GenerateResultEntryForms(evs, true); } else { MessageBox.Show("This feature is only available for championships that are XC or TF."); } } catch (Exception ex) { MessageBox.Show("Failed to open results sheet. \n" + ex.Message); } }
private MemoryStream FileNeededEvent(object sender, DynamicFileRequestedEventArgs e) { if (e.FilePath.StartsWith(@"/exports/")) { string exportPath = ((App)Application.Current).CurrentChampionship.getChampionshipHomeDir(); // @"F:\Championship Solutions\Events\WSAA XC 2015-16\Testing Results\PDFs"; if (File.Exists(exportPath + e.FullPath)) { return(FileToMemoryStream(exportPath + e.FullPath)); } else { return(null); } } else if (e.FilePath.StartsWith(@"/files/")) { //CSDB context = FileIO.FConnFile.getContext(); int fileID = 0; if (int.TryParse(e.FileName.Trim(".jpg".ToCharArray()), out fileID)) { FileStorage file = FileIO.FConnFile.GetFileDetails().IO.GetAll <FileStorage>().Where(f => f.ID == fileID).FirstOrDefault(); if (file == null) { return(null); } return(new MemoryStream(file.FileData)); } } else if (e.FilePath.StartsWith(@"/reports/")) { if (e.FileName.StartsWith("report_")) { string reportName = e.FileName.Remove(0, 7); reportName = reportName.Replace(".pdf", ""); switch (reportName.ToLower()) { case "eventcard": if (e.Arguments.AllKeys.Contains("eventid")) { IScriptEvent Event = Championship.Championship.getEvent(int.Parse(e.Arguments["eventid"])); if (Event == null) { return(null); } List <AEvent> evs = new List <AEvent>(); evs.Add((AEvent)Event); string fileNames = Exports.GenerateResultEntryForms(evs, false, false, true); if (fileNames != null) { return(FileToMemoryStream(fileNames)); } } break; case "announcers": if (e.Arguments.AllKeys.Contains("eventid")) { } break; case "athleteprofile": if (e.Arguments.AllKeys.Contains("athleteid")) { Athlete athlete = Championship.Championship.getAthlete((int.Parse(e.Arguments["athleteid"]))); if (athlete == null) { return(null); } List <Athlete> evs = new List <Athlete>(); evs.Add((Athlete)athlete); string fileNames = Exports.GenerateAthleteProfile(evs, false, PrintOptions.NO_PRINT, true); if (fileNames != null) { return(FileToMemoryStream(fileNames)); } } break; } } } #region Legacy Report Generation from WSAA XC 2016 //else //{ //if (e.FileName.StartsWith("report_")) //{ // string reportName = e.FileName.Remove(0, 7); // reportName = reportName.TrimEnd((".pdf").ToCharArray()); // AReport rep; // switch (reportName) // { // case "vest": // rep = ReportLibrary["XCVestNumber"]; // if (e.Arguments.ContainsKey("vest")) // { // string tempFile = new Print().generateSingleVestNumberPDF( // MainWindow.CurrentChampionship.getCompetitor(e.Arguments["vest"]).FirstOrDefault() // , ""); // if (tempFile == null) return null; // using (FileStream file = new FileStream(tempFile, FileMode.Open, System.IO.FileAccess.Read)) // { // MemoryStream ms = new MemoryStream(); // file.CopyTo(ms); // return new MemoryStream(ms.ToArray()); // } // //File.Delete(tempFile); // } // break; // case "results": // if (e.Arguments.ContainsKey("eventid")) // { // IScriptEvent Event = MainWindow.CurrentChampionship.getEvent(int.Parse(e.Arguments["eventid"])); // if (Event == null) return null; // List<AEvent> evs = new List<AEvent>(); // evs.Add((AEvent)Event); // string[] fileNames = new Print().printResults(evs, false); // if (fileNames.Length == 1) // return FileToMemoryStream(fileNames[0]); // } // break; // case "teamresults": // if (e.Arguments.ContainsKey("eventid")) // { // IScriptEvent Event = MainWindow.CurrentChampionship.getEvent(int.Parse(e.Arguments["eventid"])); // if (Event == null) return null; // List<AEvent> evs = new List<AEvent>(); // evs.Add((AEvent)Event); // string[] fileNames = new Print().printTeamResults(evs, false); // if (fileNames.Length == 1) // return FileToMemoryStream(fileNames[0]); // } // break; // default: // return null; // } // end switch //} // end if report //} #endregion return(null); }