private ResultsReturnTeam[] convertIntoArray(DSResults results) { ResultsReturnTeam[] returnArray = new ResultsReturnTeam[results.TeamResults.Count]; int i = 0; foreach(DSResults.TeamResultsRow row in results.TeamResults) { returnArray[i] = new ResultsReturnTeam(); returnArray[i].ClubId = row.ClubId; returnArray[i].TeamId = row.TeamId; returnArray[i].Hits = row.Hits; returnArray[i].Points = row.Points; returnArray[i].TeamName = row.TeamName; returnArray[i].FigureHits = row.FigureHits; returnArray[i].HitsPerStn = row.HitsPerStn; i++; } return returnArray; }
private DSResults sortTeams(DSResults results) { string sortExpression = ""; int StationsCount = myInterface.GetStationsCount(); switch(CompetitionType) { case Structs.CompetitionTypeEnum.Field: { if (this.useNorwegianCount) { // Poängfäljtskjutning sortExpression = "NorwPoints desc, Points desc, "; // Add columns for each station for (int stationNr = StationsCount; stationNr >= 1; stationNr--) { sortExpression += "Station" + stationNr.ToString() + " desc, "; } } else { // Fältskjutning sortExpression = "Hits desc, FigureHits desc, Points desc, "; for (int stationNr = StationsCount; stationNr >= 1; stationNr--) { sortExpression += "Station" + stationNr.ToString() + " desc, "; } } break; } case Structs.CompetitionTypeEnum.MagnumField: { if (this.useNorwegianCount) { // Poängfältskjutning sortExpression = "NorwPoints desc, Points desc, "; // Add columns for each station for (int stationNr = StationsCount; stationNr >= 1; stationNr--) { sortExpression += "Station" + stationNr.ToString() + " desc, "; } } else { // Fältskjutning sortExpression = "Hits desc, FigureHits desc, Points desc, "; for (int stationNr = StationsCount; stationNr >= 1; stationNr--) { sortExpression += "Station" + stationNr.ToString() + " desc, "; } } break; } case Structs.CompetitionTypeEnum.Precision: { sortExpression = "Hits desc, "; for(int stationNr=StationsCount;stationNr>=1;stationNr--) { sortExpression += "Station" + stationNr.ToString() + " desc, "; } for(int stationNr=StationsCount;stationNr>=1;stationNr--) { for(int i=10;i>=1;i--) { sortExpression += "Station" + stationNr.ToString() + "-" + i.ToString() + " desc, "; } } break; } default: throw new NotImplementedException(CompetitionType.ToString()); } sortExpression = sortExpression.Trim(); if (sortExpression.Substring(sortExpression.Length-1, 1) == ",") { sortExpression = sortExpression.Substring(0,sortExpression.Length-1); } DataRow[] dataRows = results.TeamResults.Select("", sortExpression); DSResults newResults = new DSResults(); foreach(DataRow row in dataRows) { DSResults.TeamResultsRow newRow = newResults.TeamResults.NewTeamResultsRow(); newRow.ClubId = (string)row["ClubId"]; newRow.TeamId = (int)row["TeamId"]; newRow.Hits = (int)row["Hits"]; newRow.FigureHits = (int)row["FigureHits"]; newRow.Points = (int)row["Points"]; newRow.TeamName = (string)row["TeamName"]; newRow.HitsPerStn = (string)row["HitsPerStn"]; newRow.NorwPoints = (int)row["NorwPoints"]; newResults.TeamResults.AddTeamResultsRow(newRow); } return newResults; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); DSResults ds = new DSResults(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "TeamResultsDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return 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 static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { DSResults ds = new DSResults(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }