private void SetupPrecision(Structs.CompetitionTypeEnum CompetitionType, bool Norwegian, out ResultsReturn obj1, out ResultsReturn obj2, string testName, Structs.CompetitionChampionshipEnum ChampionShip) { obj1 = new ResultsReturn(CompetitionType, Norwegian, ChampionShip); obj1.ClubId = "01-42"; obj1.CompetitorId = 1; obj1.FigureHitsTotal = 12; obj1.FinalShootingPlace = 100; obj1.HitsTotal = 100; obj1.PointsTotal = 0; obj1.ShooterName = "First Shooter " + testName; obj1.HitsPerStn = new int[] { 50, 50 }; obj1.FigureHitsPerStn = new int[] { 0, 0 }; obj1.PointsPerStn = new int[] { 0, 0 }; obj2 = new ResultsReturn(CompetitionType, Norwegian, ChampionShip); obj2.ClubId = "01-42"; obj2.CompetitorId = 1; obj2.FigureHitsTotal = 12; obj2.FinalShootingPlace = 100; obj2.HitsTotal = 100; obj2.PointsTotal = 0; obj2.ShooterName = "Second Shooter " + testName; obj2.HitsPerStn = new int[] { 50, 50 }; obj2.FigureHitsPerStn = new int[] { 0, 0 }; obj2.PointsPerStn = new int[] { 0, 0 }; }
public ResultsReturn( Structs.CompetitionTypeEnum CompetitionType, bool norwegian, Structs.CompetitionChampionshipEnum ChampionShip) { this.CompetitionType = CompetitionType; this.Norwegian = norwegian; this.ChampionShip = ChampionShip; }
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; } } }
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 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; } } }
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; }
internal void enableMe() { CompetitionType = CommonCode.GetCompetitions()[0].Type; switch (CompetitionType) { case Structs.CompetitionTypeEnum.Field: break; case Structs.CompetitionTypeEnum.MagnumField: break; case Structs.CompetitionTypeEnum.Precision: lblPatrols.Text = "Skjutlag"; chkMoveNextShooter.Text = "Skrivning av en serie ger nästa skytt"; break; default: throw new ApplicationException("Unknown CompetitionType"); } this.Visible = true; this.Focus(); this.redrawStations(); this.PatrolsUpdate(); if (patrolsDs.Patrols.Count > 0) { ddPatrols.SelectedIndex = 0; ddPatrols_SelectedIndexChanged(); } this.viewCurrent(); this.resultIsChanged = false; }
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; }
static internal Structs.ResultWeaponsClass ConvertWeaponsClassToResultClass( Structs.WeaponClass weapon, Structs.CompetitionTypeEnum compType) { switch (compType) { case Structs.CompetitionTypeEnum.MagnumField: { switch (weapon) { case Structs.WeaponClass.M1: return(Structs.ResultWeaponsClass.M1); case Structs.WeaponClass.M2: return(Structs.ResultWeaponsClass.M2); case Structs.WeaponClass.M3: return(Structs.ResultWeaponsClass.M3); case Structs.WeaponClass.M4: return(Structs.ResultWeaponsClass.M4); case Structs.WeaponClass.M5: return(Structs.ResultWeaponsClass.M5); case Structs.WeaponClass.M6: return(Structs.ResultWeaponsClass.M6); case Structs.WeaponClass.M7: return(Structs.ResultWeaponsClass.M7); case Structs.WeaponClass.M8: return(Structs.ResultWeaponsClass.M8); case Structs.WeaponClass.M9: return(Structs.ResultWeaponsClass.M9); default: throw new CannotFindIdException("WeaponClass " + weapon + " is not used in MagnumField"); } } default: { switch (weapon) { case Structs.WeaponClass.A1: return(Structs.ResultWeaponsClass.A); case Structs.WeaponClass.A2: return(Structs.ResultWeaponsClass.A); case Structs.WeaponClass.A3: return(Structs.ResultWeaponsClass.A); case Structs.WeaponClass.B: return(Structs.ResultWeaponsClass.B); case Structs.WeaponClass.C: return(Structs.ResultWeaponsClass.C); case Structs.WeaponClass.M: return(Structs.ResultWeaponsClass.M); case Structs.WeaponClass.R: return(Structs.ResultWeaponsClass.R); default: throw new CannotFindIdException("Weaponclass " + weapon + " could not be found."); } } } }
private string RenderResults(ResultsReturn[] results) { try { Structs.CompetitionTypeEnum compType = myInterface.CompetitionCurrent.Type; StringBuilder toReturn = new StringBuilder(); if (compType == Structs.CompetitionTypeEnum.Precision) { toReturn.Append("Plats\tNamn\tKlubb\tResultat\tTot\tStm\r\n"); } else { toReturn.Append("Plats\tNamn\tKlubb\tResultat\tTot\tPoäng\tStm\r\n"); } bool norwegianCount = myInterface.CompetitionCurrent.NorwegianCount; Hashtable clubs = new Hashtable(); int place = 0; foreach (ResultsReturn res in results) { place++; toReturn.Append(place.ToString() + "\t"); toReturn.Append(res.ShooterName + "\t"); if (clubs[res.ClubId] == null) { clubs[res.ClubId] = myInterface.GetClub(res.ClubId).Name; } toReturn.Append((string)clubs[res.ClubId] + "\t"); switch (compType) { case Structs.CompetitionTypeEnum.Field: if (norwegianCount) { foreach (string stnRes in res.HitsPerStnString.Split(';')) { toReturn.Append(stnRes + " "); } toReturn.Append("\t" + (res.HitsTotal + res.FigureHitsTotal).ToString() + "\t"); } else { toReturn.Append("\"" + res.HitsPerStnString.Replace(';', ' ') + "\"\t"); toReturn.Append("\" " + res.HitsTotal.ToString() + "/" + res.FigureHitsTotal.ToString() + "\"\t"); } break; case Structs.CompetitionTypeEnum.MagnumField: if (norwegianCount) { foreach (string stnRes in res.HitsPerStnString.Split(';')) { try { if (stnRes.Trim() != "") { int hits = int.Parse(stnRes.Split('/')[0]); int figures = int.Parse(stnRes.Split('/')[1]); toReturn.Append((hits + figures).ToString() + " "); } } catch (System.FormatException exc) { Trace.WriteLine(exc.ToString()); } } toReturn.Append("\t" + (res.HitsTotal + res.FigureHitsTotal).ToString() + "\t"); } else { toReturn.Append("\"" + res.HitsPerStnString.Replace(';', ' ') + "\"\t"); toReturn.Append("\" " + res.HitsTotal.ToString() + "/" + res.FigureHitsTotal.ToString() + "\"\t"); } break; case Structs.CompetitionTypeEnum.Precision: foreach (string stnRes in res.HitsPerStnString.Split(';')) { try { if (stnRes.Trim() != "") { toReturn.Append(stnRes.Trim() + " "); } } catch (System.FormatException exc) { Trace.WriteLine(exc.ToString()); } } toReturn.Append("\t" + (res.HitsTotal + res.FigureHitsTotal).ToString() + "\t"); break; default: throw new NotImplementedException(); } if (compType != Structs.CompetitionTypeEnum.Precision) { toReturn.Append(res.PointsTotal.ToString() + "\t"); } Structs.Medal medal = (Structs.Medal)res.Medal; switch (medal) { case Structs.Medal.StandardSilver: toReturn.Append("S\t"); break; case Structs.Medal.StardardBrons: toReturn.Append("B\t"); break; default: toReturn.Append("\t"); break; } toReturn.Append("\r\n"); } return(toReturn.ToString()); } catch (Exception exc) { Trace.WriteLine(exc.ToString()); throw; } }