internal ResultsReturn[] GetResults( Structs.ResultWeaponsClass wclass, Structs.ShootersClass uclass, Structs.Competition competition, bool finalResults) { lock (resultHolders) { foreach (CResultHolder holder in resultHolders) { if (holder.WClass == wclass && holder.UClass == uclass && holder.NorwegianCount == competition.NorwegianCount && holder.FinalResults == finalResults) { return(holder.Results); } } ResultsReturn[] results = result.GetResults(wclass, uclass, competition, finalResults); CResultHolder newHolder = new CResultHolder( wclass, uclass, competition.NorwegianCount, finalResults, results); resultHolders.Add(newHolder); return(results); } }
internal void UpdatedCompetition() { Trace.WriteLine("FResultsView.UpdatedCompetition: Started."); Structs.Competition[] comps = CommonCode.GetCompetitions(); if (comps.Length == 0) { return; } Structs.Competition comp = comps[0]; switch (comp.Type) { case Structs.CompetitionTypeEnum.Precision: { dataGridPoints.Width = 0; dataGridPoints.HeaderText = ""; break; } case Structs.CompetitionTypeEnum.Field: { break; } case Structs.CompetitionTypeEnum.MagnumField: { break; } default: throw new ApplicationException("Cannot find CompetitionType " + comp.Type.ToString()); } Trace.WriteLine("FResultsView.UpdatedCompetition: Ended."); }
private double writeResultsPageHeader(pdfPage page, double yPos) { Structs.Competition comp = myInterface.GetCompetitions()[0]; addText(page, "Tävling:", leftMargin, yPos, fontCompetitionHeader, fontCompetitionHeaderSize); yPos = addText(page, comp.Name + ", " + comp.StartTime.ToShortDateString(), leftMargin + 30, yPos, fontCompetitionHeader, fontCompetitionHeaderSize); yPos = yPos + 4; return(yPos); }
internal ResultsReturn[] GetResults( Structs.ResultWeaponsClass wclass, Structs.ShootersClass uclass, Structs.Competition competition) { return(GetResults( wclass, uclass, competition, false)); }
internal CPrintResultlistByPatrol(ref Common.Interface newCommon, Structs.Patrol patrolToPrint) : base() { CommonCode = newCommon; patrol = patrolToPrint; Structs.Competition competition = CommonCode.GetCompetitions()[0]; CompetitionType = competition.Type; this.NorwegianCount = competition.NorwegianCount; }
internal ResultsReturnTeam[] GetTeamResults(Structs.ResultWeaponsClass wclass, Structs.Competition competition) { Trace.WriteLine("CResults.GetResults(" + wclass.ToString() + ") started on thread \"" + System.Threading.Thread.CurrentThread.Name + "\" ( " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )"); while (resultsAlreadyRunning) { System.Threading.Thread.Sleep(50); } Trace.WriteLine("CResults: GetResults() " + " locking \"GetResultsLock\" on thread \"" + Thread.CurrentThread.Name + "\" ( " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )"); lock (GetResultsLock) { Trace.WriteLine("CResults: GetResults() " + " locked \"GetResultsLock\" on thread \"" + Thread.CurrentThread.Name + "\" ( " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )"); try { resultsAlreadyRunning = true; CompetitionType = myInterface.CompetitionCurrent.Type; database = myInterface.databaseClass.Database; useNorwegianCount = competition.NorwegianCount; // Ok, now lets count the real ones DSResults results = getAllTeams(wclass); results = sortTeams(results); ResultsReturnTeam[] toReturn = convertIntoArray(results); return(toReturn); } finally { Trace.WriteLine("CResultsTeam: GetResults() " + " unlocking \"GetResultsLock\" on thread \"" + Thread.CurrentThread.Name + "\" ( " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )"); Trace.WriteLine("CResults.GetResults ended."); resultsAlreadyRunning = false; } } }
private void getCurrentResults() { Structs.ShootersClass temp = (Structs.ShootersClass) this.currentUClass; Structs.Competition comp = CommonCode.GetCompetitions()[0]; results = CommonCode.ResultsGet(wclass, temp, comp, !printPrelResults); }
private void calculateStandardMedals(Structs.ResultWeaponsClass wclass, Structs.ShootersClass uclass) { List <ResultsReturn> results; Structs.Competition competition = myInterface.CompetitionCurrent; results = getAllCompetitors( wclass, uclass, true); results.Sort(); calculateMedals(results); }
internal CPrintResultlist(ref Common.Interface newCommon, Structs.ResultWeaponsClass wclasswanted, Structs.ShootersClass uclasswanted, bool prelResults, string clubIdwanted) : base() { CommonCode = newCommon; wclass = wclasswanted; uclass = uclasswanted; printPrelResults = prelResults; clubId = clubIdwanted; competition = CommonCode.GetCompetitions()[0]; CompetitionType = competition.Type; }
private void populateWeaponsClassDropDown() { Trace.WriteLine("FCompetitors: populateWeaponsClassDropDown() " + "started on thread \"" + Thread.CurrentThread.Name + "\" ( " + Thread.CurrentThread.ManagedThreadId.ToString() + " )"); Structs.Competition[] comps = CommonCode.GetCompetitions(); if (comps.Length == 0) { return; } Structs.Competition comp = comps[0]; DatasetTeams ds = new DatasetTeams(); for (int i = 1; i <= Structs.ResultWeaponsClassMax; i++) { Structs.ResultWeaponsClass wc = (Structs.ResultWeaponsClass)i; try { int test = int.Parse(wc.ToString()); } catch (System.FormatException) { DatasetTeams.WeaponClassRow row = ds.WeaponClass.NewWeaponClassRow(); row.ClassId = i; row.ClassName = wc.ToString() + "-vapen"; if ((comp.Type != Structs.CompetitionTypeEnum.MagnumField & row.ClassName.IndexOf("M") == -1) | (comp.Type == Structs.CompetitionTypeEnum.MagnumField & row.ClassName.IndexOf("M") > -1 & row.ClassName != "M-vapen")) { ds.WeaponClass.AddWeaponClassRow(row); } } this.ddWeaponClass.DataSource = ds.WeaponClass; this.ddWeaponClass.DisplayMember = "ClassName"; this.ddWeaponClass.ValueMember = "ClassId"; } Trace.WriteLine("FCompetitors: populateWeaponsClassDropDown() ended."); }
public void TestStandardFieldTwoShooters() { Structs.Competition competition = new Structs.Competition(); competition.Championship = Structs.CompetitionChampionshipEnum.Club; competition.DoFinalShooting = false; competition.FirstPrice = 400; competition.Name = "Unittest Field Two Shooters"; competition.NorwegianCount = false; competition.PatrolConnectionType = Structs.PatrolConnectionTypeEnum.AR_B_C_M; competition.Type = Structs.CompetitionTypeEnum.Field; intf.NewCompetition(competition); createShooter(1); createShooter(2); createShooter(3); createShooter(4); }
private List <ResultsReturn> markPriceMoney(List <ResultsReturn> results) { Structs.Competition comp = myInterface.CompetitionCurrent; int nrOfShooterWithPrice = (int)(((double)comp.PriceMoneyShooterPercent) / 100 * results.Count); int totalAmount = getTotalAmountOfMoney(); CPriceMoney prices = new CPriceMoney(nrOfShooterWithPrice, comp.ShooterFee1, comp.FirstPrice, totalAmount, comp.ShooterFee1); int[] priceArray = prices.Calculate(((double)comp.PriceMoneyPercentToReturn) / 100); for (int i = 0; i < priceArray.Length & i < results.Count; i++) { results[i].PriceMoney = priceArray[i]; } return(results); }
private double writeResultsPageTeamHeader(pdfPage page, double yPos, Structs.ResultWeaponsClass wclass) { Structs.Competition comp = myInterface.GetCompetitions()[0]; addText(page, "Tävling:", leftMargin, yPos, fontCompetitionHeader, fontCompetitionHeaderSize); yPos = addText(page, comp.Name + ", " + comp.StartTime.ToShortDateString(), leftMargin + 30, yPos, fontCompetitionHeader, fontCompetitionHeaderSize); addText(page, "Vapen:", leftMargin, yPos, fontCompetitionHeader, fontCompetitionHeaderSize); yPos = addText(page, wclass.ToString(), leftMargin + 30, yPos, fontCompetitionHeader, fontCompetitionHeaderSize); /*addText(page, "Klass:", leftMargin, yPos, fontCompetitionHeader, fontCompetitionHeaderSize); * yPos = addText(page, uclass.ToString(), * leftMargin + 30, yPos , fontCompetitionHeader, fontCompetitionHeaderSize);*/ yPos = yPos + 4; return(yPos); }
internal ResultsReturn ResultsGetCompetitor( Structs.Competitor competitor) { Structs.Competition competition = myInterface.CompetitionCurrent; ResultsReturn toReturn = new ResultsReturn( competition.Type, competition.NorwegianCount, competition.Championship); Structs.Shooter shooter = myInterface.GetShooter(competitor.ShooterId); Structs.CompetitorResult[] results = myInterface.GetCompetitorResults(competitor.CompetitorId); int figureHits = 0; int hits = 0; int points = 0; foreach (Structs.CompetitorResult result in results) { figureHits += result.FigureHits; hits += result.Hits; points += result.Points; toReturn.AddHitsPerStn(result.Hits); toReturn.AddFigureHitsPerStn(result.FigureHits); toReturn.AddPointsPerStn(result.Points); } toReturn.ClubId = shooter.ClubId; toReturn.CompetitorId = competitor.CompetitorId; toReturn.FigureHitsTotal = figureHits; toReturn.HitsTotal = hits; toReturn.PointsTotal = points; toReturn.ShooterName = shooter.Surname + " " + shooter.Givenname; toReturn.FinalShootingPlace = competitor.FinalShootingPlace; return(toReturn); }
private List <ResultsReturn> markMedals(List <ResultsReturn> results) { int i = 0; Structs.Competition competition = myInterface.CompetitionCurrent; switch (competition.Type) { case Structs.CompetitionTypeEnum.Field: { if (useNorwegianCount) { foreach (ResultsReturn row in results) { i++; if (row.NorwegianPoints >= standardSilverMedal) { row.Medal = Structs.Medal.StandardSilver; } else if (row.NorwegianPoints >= standardBronsMedal) { row.Medal = Structs.Medal.StardardBrons; } else { row.Medal = Structs.Medal.None; } } } else { foreach (ResultsReturn row in results) { i++; if (row.HitsTotal >= standardSilverMedal) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= standardBronsMedal) { row.Medal = Structs.Medal.StardardBrons; } else { row.Medal = Structs.Medal.None; } } } break; } case Structs.CompetitionTypeEnum.MagnumField: { foreach (ResultsReturn row in results) { i++; if (row.HitsTotal >= standardSilverMedal) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= standardBronsMedal) { row.Medal = Structs.Medal.StardardBrons; } else { row.Medal = Structs.Medal.None; } } break; } case Structs.CompetitionTypeEnum.Precision: { int series = myInterface.GetStationsCount(); foreach (ResultsReturn row in results) { i++; if (row.HitsTotal >= standardSilverMedal) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= standardBronsMedal) { row.Medal = Structs.Medal.StardardBrons; } else { row.Medal = Structs.Medal.None; } Structs.Competitor competitor = myInterface.GetCompetitor(row.CompetitorId); Structs.Weapon weapon = myInterface.GetWeapon(competitor.WeaponId); Structs.ResultWeaponsClass wclass = CConvert.ConvertWeaponsClassToResultClass( weapon.WClass, competition.Type); switch (series) { case 6: { switch (wclass) { case Structs.ResultWeaponsClass.A: { if (row.HitsTotal >= 277) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 267 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.B: { if (row.HitsTotal >= 282) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 273 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.C: { if (row.HitsTotal >= 283) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 276 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } } break; } case 7: { switch (wclass) { case Structs.ResultWeaponsClass.A: { if (row.HitsTotal >= 323) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 312 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.B: { if (row.HitsTotal >= 329) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 319 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.C: { if (row.HitsTotal >= 330) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 322 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } } break; } case 10: { switch (wclass) { case Structs.ResultWeaponsClass.A: { if (row.HitsTotal >= 461) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 445 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.B: { if (row.HitsTotal >= 470) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 455 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.C: { if (row.HitsTotal >= 471) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 460 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } } break; } } } break; } default: throw new ApplicationException("Unknown competition type"); } return(results); }
private void saveCurrent() { int nrOfStations = (int)numNrOfSeries.Value; int nrOfShootsPerStation = (int)numNrOfShootPerSeries.Value; int shoots = 0; int figures = 0; switch (chkUseOnlyOneBoxForResult.Checked) { case true: figures = 1; shoots = 10 * nrOfShootsPerStation; break; case false: figures = nrOfShootsPerStation; shoots = 10 * nrOfShootsPerStation; break; } for (int i = 1; i <= CommonCode.GetStationsCount(); i++) { Structs.Station station = CommonCode.GetStation(i, false); station.Figures = figures; station.Shoots = shoots; CommonCode.UpdateStation(station); } while (CommonCode.GetStationsCount() < nrOfStations) { Structs.Station station = new Structs.Station(); station.CompetitionId = CommonCode.GetCompetitions()[0].CompetitionId; station.Figures = figures; station.Points = false; station.Shoots = shoots; station.StationNr = CommonCode.GetStationsCount() + 1; CommonCode.NewStation(station, false); } while (CommonCode.GetStationsCount() > nrOfStations) { Structs.Station station = CommonCode.GetStation(CommonCode.GetStationsCount(), false); CommonCode.DelStation(station); } Structs.Competition competition = CommonCode.GetCompetitions()[0]; int timeAvailable = competition.PatrolTimeBetween; int timeNeeded = calculateTimeRequirements(); if (timeNeeded > timeAvailable) { DialogResult res = MessageBox.Show("Du har avsatt " + timeAvailable.ToString() + " minuter för varje skjutlag.\r\n\r\n" + "Beräknad tid för varje skjutlag med hänsyn taget till " + "skjuttid (6 minuter per serie) och markeringstid " + "(6 minuter per serie) är " + timeNeeded.ToString() + " minuter.\r\n\r\n" + "Vill du öka upp avsatt tid?", "Kontrollberäkning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res == DialogResult.Yes) { competition.PatrolTimeBetween = timeNeeded; CommonCode.UpdateCompetition(competition); DateTime patrolStart = competition.StartTime; Structs.Patrol[] patrols = CommonCode.GetPatrols(); for (int i = 0; i < patrols.Length; i++) { Structs.Patrol patrol = patrols[i]; //Trace.WriteLine(patrol.StartDateTimeDisplay.ToShortTimeString()); patrol.StartDateTime = patrolStart; patrol.StartDateTimeDisplay = patrolStart; CommonCode.UpdatePatrol(patrol); patrolStart = patrolStart.AddMinutes(timeNeeded); } } } }
private List <ResultsReturn> getAllCompetitors(Structs.ResultWeaponsClass wclass, Structs.ShootersClass uclass, bool standardMedalsCalculation) { List <ResultsReturn> results = new List <ResultsReturn>(); Structs.Competition competition = myInterface.CompetitionCurrent; Hashtable shooters = new Hashtable(); Hashtable weapons = new Hashtable(); string selectString = ""; string standardClass = "ShooterClass=" + ((int)Structs.ShootersClass.Klass1).ToString() + " or ShooterClass=" + ((int)Structs.ShootersClass.Klass2).ToString() + " or ShooterClass=" + ((int)Structs.ShootersClass.Klass3).ToString() + " or ShooterClass=" + ((int)Structs.ShootersClass.Öppen).ToString(); string damClass = "ShooterClass=" + ((int)Structs.ShootersClass.Damklass1).ToString() + " or ShooterClass=" + ((int)Structs.ShootersClass.Damklass2).ToString() + " or ShooterClass=" + ((int)Structs.ShootersClass.Damklass3).ToString(); string extraClasses = "ShooterClass=" + ((int)Structs.ShootersClass.Juniorklass).ToString() + " or ShooterClass=" + ((int)Structs.ShootersClass.VeteranklassYngre).ToString() + " or ShooterClass=" + ((int)Structs.ShootersClass.VeteranklassÄldre).ToString(); if (standardMedalsCalculation) { if (wclass == Structs.ResultWeaponsClass.C && (competition.Championship == Structs.CompetitionChampionshipEnum.SM | competition.Championship == Structs.CompetitionChampionshipEnum.Landsdel)) { switch (uclass) { case Structs.ShootersClass.Klass: selectString = standardClass; break; case Structs.ShootersClass.Klass1: selectString = standardClass; break; case Structs.ShootersClass.Klass2: selectString = standardClass; break; case Structs.ShootersClass.Klass3: selectString = standardClass; break; case Structs.ShootersClass.Öppen: selectString = "ShooterClass=" + ((int)uclass).ToString(); break; case Structs.ShootersClass.Damklass: selectString = damClass; break; case Structs.ShootersClass.Damklass1: selectString = damClass; break; case Structs.ShootersClass.Damklass2: selectString = damClass; break; case Structs.ShootersClass.Damklass3: selectString = damClass; break; case Structs.ShootersClass.Juniorklass: selectString = "ShooterClass=" + ((int)Structs.ShootersClass.Juniorklass).ToString(); break; case Structs.ShootersClass.VeteranklassYngre: selectString = "ShooterClass=" + ((int)Structs.ShootersClass.VeteranklassYngre).ToString(); break; case Structs.ShootersClass.VeteranklassÄldre: selectString = "ShooterClass=" + ((int)Structs.ShootersClass.VeteranklassÄldre).ToString(); break; default: throw new NotImplementedException("uclass: " + uclass.ToString()); } } else { selectString = ""; // Everyone in one calculation } } else { // Fetch the shooters switch (uclass) { case Structs.ShootersClass.Damklass: selectString = damClass; break; case Structs.ShootersClass.Klass: selectString = standardClass; break; case Structs.ShootersClass.Okänd: selectString = ""; break; default: selectString = "ShooterClass=" + ((int)uclass).ToString(); break; } } foreach (DatabaseDataset.CompetitorsRow row in database.Competitors.Select(selectString)) { // What shootersclass is current user? #if DEBUG Structs.ShootersClass currentUclass = (Structs.ShootersClass)row.ShooterClass; // TODO Remove #endif // Setup a cache for weapons. Structs.Weapon weapon; if (weapons.ContainsKey(row.WeaponId)) { weapon = (Structs.Weapon)weapons[row.WeaponId]; } else { weapon = myInterface.GetWeapon(row.WeaponId); weapons.Add(row.WeaponId, weapon); } // For each competitor, find the result (competitorresults) // and add together /*if ( (myInterface.ConvertWeaponsClassToResultClass( * weapon.WClass) == wclass | * wclass == Structs.ResultWeaponsClass.Unknown) * & * ( uclass == currentUclass | uclass == Structs.ShootersClass.Okänd))*/ if (myInterface.ConvertWeaponsClassToResultClass( weapon.WClass) == wclass | wclass == Structs.ResultWeaponsClass.Unknown) { ResultsReturn thisResult = ResultsGetCompetitor(row.CompetitorId); if (thisResult.HitsTotal > 0) { results.Add(thisResult); } } } return(results); }
private void btnSave_Click(object sender, System.EventArgs e) { // Check input try { int.Parse(this.txtShooterFee1.Text); } catch (System.FormatException) { MessageBox.Show("Anmälningsavgift verkar innehålla annat än siffror.", "Inmatningsfel", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtShooterFee1.Focus(); return; } try { int.Parse(this.txtFirstPrice.Text); } catch (System.FormatException) { MessageBox.Show("Förstapris verkar innehålla annat än siffror.", "Inmatningsfel", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtFirstPrice.Focus(); return; } if ((Structs.PatrolConnectionTypeEnum)DDPatrolConnectionType.SelectedIndex != competition.PatrolConnectionType) { if (!checkChangePatrolConnectionTypeIsPossible()) { return; } } // ok, now save comps = CommonCode.GetCompetitions(); if (comps.Length >= 1) { competition = comps[0]; } competition.Name = this.txtName.Text; competition.Type = Structs.CompetitionTypeEnum.Field; competition.NorwegianCount = false; competition.PatrolSize = (int)this.numPatrolSize.Value; competition.PatrolTimeBetween = (int)this.numPatrolTimeBetween.Value; competition.StartTime = this.dateTimePicker1.Value.Date; competition.StartTime = competition.StartTime.AddHours((double)this.numStartHour.Value) .AddMinutes((double)this.numStartMinute.Value); competition.DoFinalShooting = this.chkFinal.Checked; competition.UsePriceMoney = this.chkUsePriceMoney.Checked; competition.ShooterFee1 = int.Parse(this.txtShooterFee1.Text); competition.ShooterFee2 = int.Parse(this.txtShooterFee2.Text); competition.ShooterFee3 = int.Parse(this.txtShooterFee3.Text); competition.ShooterFee4 = int.Parse(this.txtShooterFee4.Text); competition.FirstPrice = int.Parse(this.txtFirstPrice.Text); competition.PriceMoneyPercentToReturn = (int)this.numPriceMoneyReturn.Value; competition.PriceMoneyShooterPercent = (int)numShoterPercentWithPrice.Value; competition.Type = Structs.CompetitionTypeEnum.Precision; competition.Championship = (Structs.CompetitionChampionshipEnum)DDChampionship.SelectedIndex; competition.PatrolConnectionType = (Structs.PatrolConnectionTypeEnum)DDPatrolConnectionType.SelectedIndex; competition.OneClass = chkOneClass.Checked; if (comps.Length > 0) { competition.CompetitionId = comps[0].CompetitionId; CommonCode.UpdateCompetition(competition); } else { CommonCode.NewCompetition(competition); } this.Visible = false; this.EnableMain(); }
internal ResultsReturn[] GetResults( Structs.ResultWeaponsClass wclass, Structs.ShootersClass uclass, Structs.Competition competition, bool finalResults) { Trace.WriteLine("CResults.GetResults(" + wclass.ToString() + ", " + uclass.ToString() + ") started on thread \"" + System.Threading.Thread.CurrentThread.Name + "\" ( " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )"); while (resultsAlreadyRunning) { System.Threading.Thread.Sleep(50); } Trace.WriteLine("CResults: GetResults() " + " locking \"GetResultsLock\" on thread \"" + Thread.CurrentThread.Name + "\" ( " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )"); lock (GetResultsLock) { Trace.WriteLine("CResults: GetResults() " + " locked \"GetResultsLock\" on thread \"" + Thread.CurrentThread.Name + "\" ( " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )"); try { resultsAlreadyRunning = true; database = myInterface.databaseClass.Database; useNorwegianCount = competition.NorwegianCount; // First find out about the standard medals calculateStandardMedals(wclass, uclass); // Ok, now lets count the real ones if (competition.OneClass) { switch (uclass) { case Structs.ShootersClass.Damklass: uclass = Structs.ShootersClass.Damklass; break; case Structs.ShootersClass.Damklass1: uclass = Structs.ShootersClass.Damklass; break; case Structs.ShootersClass.Damklass2: uclass = Structs.ShootersClass.Damklass; break; case Structs.ShootersClass.Damklass3: uclass = Structs.ShootersClass.Damklass; break; case Structs.ShootersClass.Juniorklass: break; case Structs.ShootersClass.Klass: uclass = Structs.ShootersClass.Klass; break; case Structs.ShootersClass.Klass1: uclass = Structs.ShootersClass.Klass; break; case Structs.ShootersClass.Klass2: uclass = Structs.ShootersClass.Klass; break; case Structs.ShootersClass.Klass3: uclass = Structs.ShootersClass.Klass; break; case Structs.ShootersClass.VeteranklassYngre: break; case Structs.ShootersClass.VeteranklassÄldre: break; case Structs.ShootersClass.Öppen: break; default: throw new NotSupportedException("Structs.ShootersClass." + uclass.ToString() + " is not supported"); } } List <ResultsReturn> results = getAllCompetitors(wclass, uclass, false); results.Sort(); if (myInterface.CompetitionCurrent.Championship != Structs.CompetitionChampionshipEnum.Club) { results = markMedals(results); } else { // Mark all as not having medals foreach (ResultsReturn row in results) { row.Medal = Structs.Medal.None; } } if (finalResults) { results = markPriceMoney(results); } return(results.ToArray()); } finally { Trace.WriteLine("CResults: GetResults() " + " unlocking \"GetResultsLock\" on thread \"" + Thread.CurrentThread.Name + "\" ( " + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )"); Trace.WriteLine("CResults.GetResults ended."); resultsAlreadyRunning = false; } } }
private double writeResultsUser(pdfPage page, double yPos, ResultsReturn result, int place) { double newYPos = yPos; Structs.Club club = myInterface.GetClub(result.ClubId); if (competition.CompetitionId == 0) { competition = myInterface.GetCompetitions()[0]; } addText(page, place.ToString(), this.leftMargin, yPos, font, fontResultSize); addText(page, result.ShooterName, this.colResultNamePos, yPos, colResultClubPos - colResultNamePos, font, fontResultSize); addText(page, club.Name, this.colResultClubPos, yPos, colResultResultPos - colResultClubPos, font, fontResultSize); switch (competition.Type) { case Structs.CompetitionTypeEnum.Field: { if (competition.NorwegianCount) { addText(page, (result.HitsTotal + result.FigureHitsTotal).ToString(), colResultTotPos, yPos, font, fontResultSize); } else { addText(page, result.HitsTotal.ToString() + "/" + result.FigureHitsTotal.ToString(), colResultTotPos, yPos, font, fontResultSize); } addText(page, result.PointsTotal.ToString(), this.colResultPointsPos, yPos, font, fontResultSize); break; } case Structs.CompetitionTypeEnum.Precision: { addText(page, result.HitsTotal.ToString(), this.colResultPointsPos, yPos, font, fontResultSize); break; } default: throw new ApplicationException("Not implemented yet"); } string medalText = ""; switch ((Structs.Medal)result.Medal) { case Structs.Medal.StandardSilver: medalText = "S"; break; case Structs.Medal.StardardBrons: medalText = "B"; break; } newYPos = addText(page, medalText, this.colResultStmPos, yPos, font, fontResultSize); if (competition.UsePriceMoney && result.PriceMoney != 0) { newYPos = addText(page, result.PriceMoney.ToString() + ":-", this.colResultPricePos, yPos, font, fontResultSize); } string[] HitsPerStn = result.HitsPerStnString.Split(';'); double xPos = colResultResultPos; double xMaxPos = colResultTotPos; foreach (string thisStnPre in HitsPerStn) { if (thisStnPre != "") { string thisStn = thisStnPre; switch (competition.Type) { case Structs.CompetitionTypeEnum.Field: { if (competition.NorwegianCount) { } else { string[] parts = thisStn.Split('/'); int hits = int.Parse(parts[0]); int figureHits; figureHits = int.Parse(parts[1]); thisStn = hits.ToString(); } break; } case Structs.CompetitionTypeEnum.MagnumField: { string[] parts = thisStn.Split('/'); int hits = int.Parse(parts[0]); int figureHits; figureHits = int.Parse(parts[1]); if (competition.NorwegianCount) { thisStn = (hits + figureHits).ToString(); } else { thisStn = hits.ToString(); } break; } case Structs.CompetitionTypeEnum.Precision: { break; } default: throw new NotImplementedException(); } int maxXSizeInPoints = (int)((xMaxPos - xPos) / conversionPixelsToMM); if (font.getWordWidth(thisStn, fontSize) > maxXSizeInPoints) { xPos = colResultResultPos; yPos = newYPos; } newYPos = addText(page, thisStn, xPos, yPos, font, fontResultSize); xPos += conversionPixelsToMM * font.getWordWidth(thisStn, fontSize); } } if (result.FinalShootingPlace != 100) { addText(page, "(" + result.FinalShootingPlace.ToString() + ")", xPos, yPos, font, fontResultSize); } return(newYPos); }
private double writeResultsTeam(pdfPage page, double yPos, ResultsReturnTeam result, int place) { double newYPos = yPos; Structs.Club club = myInterface.GetClub(result.ClubId); if (competition.CompetitionId == 0) { competition = myInterface.GetCompetitions()[0]; } addText(page, place.ToString(), this.leftMargin, yPos, font, fontResultSize); addText(page, result.TeamName, this.colResultNamePos, yPos, colResultClubPos - colResultNamePos, font, fontResultSize); addText(page, club.Name, this.colResultClubPos, yPos, colResultResultPos - colResultClubPos, font, fontResultSize); switch (competition.Type) { case Structs.CompetitionTypeEnum.Field: { if (competition.NorwegianCount) { addText(page, (result.Hits + result.FigureHits).ToString(), colResultTotPos, yPos, font, fontResultSize); } else { addText(page, result.Hits.ToString() + "/" + result.FigureHits.ToString(), colResultTotPos, yPos, font, fontResultSize); } addText(page, result.Points.ToString(), this.colResultPointsPos, yPos, font, fontResultSize); break; } case Structs.CompetitionTypeEnum.Precision: { addText(page, result.Hits.ToString(), this.colResultPointsPos, yPos, font, fontResultSize); break; } default: throw new ApplicationException("Not implemented yet"); } /*if (competition.UsePriceMoney && * result.PriceMoney != 0) * { * newYPos = addText(page, result.PriceMoney.ToString() + ":-", * this.colResultPricePos, yPos, font, fontResultSize); * }*/ string[] HitsPerStn = result.HitsPerStn.Split(';'); double xPos = colResultResultPos; double xMaxPos = colResultTotPos; foreach (string thisStn in HitsPerStn) { int maxXSizeInPoints = (int)((xMaxPos - xPos) / conversionPixelsToMM); if (font.getWordWidth(thisStn, fontSize) > maxXSizeInPoints) { xPos = colResultResultPos; yPos = newYPos; } newYPos = addText(page, thisStn, xPos, yPos, font, fontResultSize); xPos += conversionPixelsToMM * font.getWordWidth(thisStn, fontSize); } Structs.Team team = myInterface.GetTeam(result.TeamId); foreach (int compid in (int[])team.CompetitorIds.ToArray(typeof(int))) { newYPos = writeResultsTeam(page, newYPos, colResultResultPos, colResultTotPos, compid); } return(newYPos); }