private string createPatrolHtmls(Structs.Patrol patrol) { StringBuilder html = new StringBuilder(); html.Append("<table>\r\n"); html.Append("<tr>"); html.Append("<td>Figur</td>"); html.Append("<td>Namn</td>"); html.Append("<td>Klass</td>"); html.Append("<td>Vapen</td>"); html.Append("</tr>\r\n"); Structs.Competitor[] comps = myInterface.GetCompetitors(patrol); for(int lane=1;lane<=myInterface.GetCompetitions()[0].PatrolSize;lane++) { bool found = false; foreach(Structs.Competitor comp in comps) { if (comp.Lane == lane) { html.Append(createPatrolHtmlCompetitor(comp)); found = true; } } if (!found) { html.Append(createPatrolHtmlEmpty(lane)); } } html.Append("</table>\r\n"); return html.ToString(); }
private string createPatrolHeader(Structs.Patrol patrol) { StringBuilder html = new StringBuilder(); html.Append("<b>Patrull " + patrol.PatrolId + " - " + patrol.StartDateTime.ToShortTimeString() + "</b>\r\n"); return html.ToString(); }
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 CPrintResultLabels(ref Common.Interface newCommon, Structs.Patrol PatrolToPrint, int AlreadyPrintedLabels) : base() { CommonCode = newCommon; Patrol = PatrolToPrint; labelCount = AlreadyPrintedLabels; }
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."); } } } }
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 CResultHolder(Structs.ResultWeaponsClass wclass, Structs.ShootersClass uclass, bool norwegianCount, bool finalResults, ResultsReturn[] results) { WClass = wclass; UClass = uclass; NorwegianCount = norwegianCount; FinalResults = finalResults; Results = results; }
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 byte[] ExportResults(Structs.ResultWeaponsClass wclass, Structs.ShootersClass uclass, bool finalResults) { ResultsReturn[] results = myInterface.resultClass.GetResults( wclass, uclass, myInterface.CompetitionCurrent); string resultString = RenderResults(results); Encoding enc = ASCIIEncoding.GetEncoding(1252); return enc.GetBytes(resultString); }
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 DSResults getAllTeams(Structs.ResultWeaponsClass wclass) { DSResults results = new DSResults(); // Add columns for each station (used later for sorting) int stationCount = myInterface.GetStationsCount(); for(int stationNr=1;stationNr<=stationCount;stationNr++) { results.TeamResults.Columns.Add("Station" + stationNr.ToString(), typeof(int)); } if (myInterface.CompetitionCurrent.Type == Structs.CompetitionTypeEnum.Precision) { for(int stationNr=myInterface.GetStationsCount();stationNr>=1;stationNr--) { for(int i=10; i>0; i--) { results.TeamResults.Columns.Add("Station" + stationNr.ToString() + "-" + i.ToString(), typeof(int)); } } } foreach(DatabaseDataset.TeamsRow teamrow in database.Teams) { if (teamrow.WClass == (int)wclass) { ArrayList comps = new ArrayList(); if (!teamrow.IsCompetitorId1Null()) comps.Add((DatabaseDataset.CompetitorsRow) database.Competitors.Select("CompetitorId=" + teamrow.CompetitorId1.ToString())[0]); if (!teamrow.IsCompetitorId2Null()) comps.Add((DatabaseDataset.CompetitorsRow) database.Competitors.Select("CompetitorId=" + teamrow.CompetitorId2.ToString())[0]); if (!teamrow.IsCompetitorId3Null()) comps.Add((DatabaseDataset.CompetitorsRow) database.Competitors.Select("CompetitorId=" + teamrow.CompetitorId3.ToString())[0]); if (!teamrow.IsCompetitorId4Null()) comps.Add((DatabaseDataset.CompetitorsRow) database.Competitors.Select("CompetitorId=" + teamrow.CompetitorId4.ToString())[0]); if (!teamrow.IsCompetitorId5Null()) comps.Add((DatabaseDataset.CompetitorsRow) database.Competitors.Select("CompetitorId=" + teamrow.CompetitorId5.ToString())[0]); Hashtable teamHits = new Hashtable(); Hashtable teamFigureHits = new Hashtable(); Hashtable teamCountNrOfTens = new Hashtable(); int totPoints = 0; foreach(DatabaseDataset.CompetitorsRow compsRow in (DatabaseDataset.CompetitorsRow[]) comps.ToArray(typeof(DatabaseDataset.CompetitorsRow))) { foreach(DatabaseDataset.CompetitorResultsRow compresrow in (DatabaseDataset.CompetitorResultsRow[]) compsRow.GetChildRows("CompetitorsCompetitorResults")) { DatabaseDataset.StationsRow stationsRow = (DatabaseDataset.StationsRow)database.Stations.Select("StationId=" + compresrow.StationId.ToString())[0]; int teamHitsThisStn = 0; if (teamHits.ContainsKey(stationsRow.StationNr)) teamHitsThisStn = (int)teamHits[stationsRow.StationNr]; int teamFigureHitsThisStn = 0; if (teamFigureHits.ContainsKey(stationsRow.StationNr)) teamFigureHitsThisStn = (int)teamFigureHits[stationsRow.StationNr]; teamHitsThisStn += compresrow.Hits; teamFigureHitsThisStn += compresrow.FigureHits; totPoints += compresrow.Points; teamHits[stationsRow.StationNr] = teamHitsThisStn; teamFigureHits[stationsRow.StationNr] = teamFigureHitsThisStn; if (CompetitionType == Structs.CompetitionTypeEnum.Precision) { foreach(string strn in compresrow.StationFigureHits.Split(';')) { if (strn != "" && int.Parse(strn) != 0) { string columnName = "Station" + stationsRow.StationNr.ToString() + "-" + strn; int thisValue = 0; if (teamCountNrOfTens.ContainsKey(columnName)) thisValue = (int)teamCountNrOfTens[columnName]; thisValue++; teamCountNrOfTens[columnName] = thisValue; } } } } } int totFigureHits = 0; int totHits = 0; string stnHits = ""; DSResults.TeamResultsRow newTeamRow = results.TeamResults.NewTeamResultsRow(); if (myInterface.GetCompetitions()[0].Type == Structs.CompetitionTypeEnum.Precision) { for(int stationNr=myInterface.GetStationsCount();stationNr>=1;stationNr--) { for(int i=10; i>0; i--) { newTeamRow["Station" + stationNr.ToString() + "-" + i.ToString()] = 0; } } } for(int stationNr=1;stationNr<=stationCount;stationNr++) { int hitsThisStn = 0; int figureHitsThisStn = 0; if (teamHits.ContainsKey(stationNr)) hitsThisStn =(int)teamHits[stationNr]; if (teamFigureHits.ContainsKey(stationNr)) figureHitsThisStn = (int)teamFigureHits[stationNr]; totHits += hitsThisStn; totFigureHits += figureHitsThisStn; switch(CompetitionType) { case Structs.CompetitionTypeEnum.Field: { if (this.useNorwegianCount) { stnHits += (hitsThisStn + figureHitsThisStn).ToString() + ";"; newTeamRow["Station" + stationNr.ToString()] = hitsThisStn + figureHitsThisStn; } else { stnHits += hitsThisStn.ToString() + "/" + figureHitsThisStn.ToString() + ";"; newTeamRow["Station" + stationNr.ToString()] = hitsThisStn; } break; } case Structs.CompetitionTypeEnum.Precision: { stnHits += hitsThisStn.ToString() + ";"; newTeamRow["Station" + stationNr.ToString()] = hitsThisStn; for(int i=10;i>=1;i--) { string columnName = "Station" + stationNr.ToString() + "-" + i.ToString(); if (teamCountNrOfTens.ContainsKey(columnName)) { newTeamRow[columnName] = (int)teamCountNrOfTens[columnName]; } else { newTeamRow[columnName] = 0; } } break; } } } newTeamRow.ClubId = teamrow.ClubId; newTeamRow.FigureHits = totFigureHits; newTeamRow.Hits = totHits; newTeamRow.NorwPoints = totFigureHits + totHits; newTeamRow.Points = totPoints; newTeamRow.TeamId = teamrow.TeamId; newTeamRow.TeamName = teamrow.Name; newTeamRow.HitsPerStn = stnHits; results.TeamResults.AddTeamResultsRow(newTeamRow); } } return results; }
public Structs.Patrol[] GetPatrols(Structs.PatrolClass patrolClass, bool AlsoIncludeUnknownClass, bool OnlyIncludePatrolsWithSpace, int PatrolIdToAlwaysView) { if (serverInterface != null) { //serverInterface.Sync(); return serverInterface.GetPatrols(patrolClass, AlsoIncludeUnknownClass, OnlyIncludePatrolsWithSpace, PatrolIdToAlwaysView); } else { if (databaseClass.Database == null) throw new ApplicationException( "Database not initialized when trying to fetch Patrols"); return databaseClass.getPatrols(patrolClass, AlsoIncludeUnknownClass, OnlyIncludePatrolsWithSpace, PatrolIdToAlwaysView); } }
public Structs.Patrol[] GetPatrols(Structs.PatrolClass patrolClass, bool AlsoIncludeUnknownClass) { if (serverInterface != null) { //serverInterface.Sync(); return serverInterface.GetPatrols(patrolClass, AlsoIncludeUnknownClass); } else { if (databaseClass.Database == null) throw new ApplicationException( "Database not initialized when trying to fetch Patrols"); return databaseClass.getPatrols(patrolClass, AlsoIncludeUnknownClass, false, -1); } }
/// <summary> /// Converts WeaponsClass to ResultClass /// </summary> /// <param name="weapon">Weapon</param> /// <returns></returns> public Structs.ResultWeaponsClass ConvertWeaponsClassToResultClass( Structs.WeaponClass weapon) { return CConvert.ConvertWeaponsClassToResultClass(weapon, CompetitionCurrent.Type); }
internal ResultsReturn ResultsGetCompetitor( Structs.Competitor competitor) { return result.ResultsGetCompetitor(competitor); }
public Structs.Shooter[] GetShooters(Structs.Club ClubToFetch) { if (serverInterface != null) { //serverInterface.Sync(); return serverInterface.GetShooters(ClubToFetch); } else { if (databaseClass.Database == null) throw new ApplicationException( "Database not initialized when trying to fetch Shooters"); return databaseClass.GetShooters(ClubToFetch); } }
/// <summary> /// Calculates the results for a wclass and shooters class for team /// </summary> /// <param name="wclass">wclass</param> /// <param name="uclass">uclass</param> /// <param name="NorwegianCount">NorwegianCount</param> /// <param name="FinalResults"></param> /// <returns></returns> public ResultsReturnTeam[] ResultsGetTeams(Structs.ResultWeaponsClass wclass, Structs.Competition competition) { if (serverInterface != null) try { return serverInterface.ResultsGetTeams(wclass, competition); } catch(System.InvalidOperationException) { return this.ResultsGetTeams(wclass, competition); } else { if (databaseClass.Database == null) throw new ApplicationException("Database not initialized when trying to view results"); return this.resultTeamClass.GetTeamResults(wclass, competition); } }
/// <summary> /// /// </summary> /// <param name="wclass"></param> /// <returns></returns> public Structs.ShootersClass[] ResultsGetUClasses(Structs.ResultWeaponsClass wclass) { if (serverInterface != null) { return serverInterface.ResultsGetUClasses(wclass); } else { if (databaseClass.Database == null) throw new ApplicationException("Database not initialized when trying to view results"); return resultClass.ResultsGetUClasses(wclass); } }
/// <summary> /// Calculates the results for a wclass and shooters class /// </summary> /// <param name="wclass">wclass</param> /// <param name="uclass">uclass</param> /// <param name="NorwegianCount">NorwegianCount</param> /// <param name="FinalResults"></param> /// <returns></returns> public ResultsReturn[] ResultsGet(Structs.ResultWeaponsClass wclass, Structs.ShootersClass uclass, Structs.Competition competition, bool FinalResults) { if (serverInterface != null) try { return serverInterface.ResultsGet(wclass, uclass, competition, FinalResults); } catch (System.InvalidOperationException) { return this.ResultsGet(wclass, uclass, competition, FinalResults); } else { if (databaseClass.Database == null) throw new ApplicationException("Database not initialized when trying to view results"); return resultClass.GetResults(wclass, uclass, competition, FinalResults); } }
/// <summary> /// Calculates the results for a wclass and shooters class /// </summary> /// <param name="wclass">wclass</param> /// <param name="uclass">uclass</param> /// <param name="NorwegianCount">NorwegianCount</param> /// <param name="FinalResults"></param> /// <returns></returns> public ResultsReturn ResultsGetCompetitor(Structs.Competitor competitor) { if (serverInterface != null) try { return serverInterface.ResultsGetCompetitor(competitor); } catch (System.InvalidOperationException) { return this.ResultsGetCompetitor(competitor); } else { if (databaseClass.Database == null) throw new ApplicationException("Database not initialized when trying to view results"); return resultClass.ResultsGetCompetitor(competitor); } }
public bool CheckChangePatrolConnectionTypeIsPossible( Structs.Patrol patrol, Structs.PatrolConnectionTypeEnum newPatrolConnectionType) { if (serverInterface != null) return serverInterface.CheckChangePatrolConnectionTypeIsPossible( patrol, newPatrolConnectionType); else { if (databaseClass.Database == null) throw new ApplicationException("Database not initialized when trying to check patrol"); return patrolClass.CheckChangePatrolConnectionTypeIsPossible( patrol, newPatrolConnectionType); } }
internal void UpdatedShooter(Structs.Shooter shooter) { lock (resultHolders) { resultHolders.Clear(); } }
public Structs.Competitor[] GetCompetitors(Structs.Patrol PatrolToFetch, string sorting) { if (serverInterface != null) { //serverInterface.Sync(); return serverInterface.GetCompetitors(PatrolToFetch, sorting); } else { if (databaseClass.Database == null) throw new ApplicationException( "Database not initialized when trying to fetch Competitors"); return databaseClass.getCompetitors(PatrolToFetch, sorting); } }
internal void UpdatedCompetitorResult(Structs.CompetitorResult compResult) { lock (resultHolders) { resultHolders.Clear(); } }
public Structs.Competitor[] GetCompetitorsWithNoPatrol(Structs.PatrolClass thisClass) { if (serverInterface != null) { //serverInterface.Sync(); return serverInterface.GetCompetitorsWithNoPatrol(thisClass); } else { if (databaseClass.Database == null) throw new ApplicationException( "Database not initialized when trying to fetch Competitors"); return databaseClass.GetCompetitorsWithNoPatrol(thisClass); } }
internal Structs.ShootersClass[] ResultsGetUClasses( Structs.ResultWeaponsClass wclass) { return result.ResultsGetUClasses(wclass); }
public Structs.Competitor[] GetCompetitors(Structs.Club ClubToFetch, Structs.ResultWeaponsClass wclass, string sorting) { if (serverInterface != null) { //serverInterface.Sync(); return serverInterface.GetCompetitors(ClubToFetch, wclass, sorting); } else { if (databaseClass.Database == null) throw new ApplicationException( "Database not initialized when trying to fetch Shooters"); return databaseClass.GetCompetitors(ClubToFetch, wclass, sorting); } }
/// <summary> /// Creates an html-page for results for a wclass/uclass /// </summary> /// <param name="wclass"></param> /// <param name="uclass"></param> /// <param name="finalResults"></param> /// <returns></returns> public byte[] InternetExcelExportResults(Structs.ResultWeaponsClass wclass, Structs.ShootersClass uclass, bool finalResults) { if (serverInterface != null) return serverInterface.InternetExcelExportResults(wclass, uclass, finalResults); else return internetExcelExportClass.ExportResults(wclass, uclass, finalResults); }
/// <summary> /// Converts WeaponsClass to PatrolClass /// </summary> /// <param name="weapon">wclass</param> /// <returns></returns> public Structs.PatrolClass ConvertWeaponsClassToPatrolClass(Structs.WeaponClass weapon, Structs.PatrolConnectionTypeEnum newPatrolConnectionType) { return CConvert.ConvertWeaponsClassToPatrolClass(weapon, newPatrolConnectionType); }