示例#1
0
        public void WriteFullXml(string filename, RelayVariations relayVariations, EventDB eventDB, Id <Course> courseId)
        {
            this.relayVariations  = relayVariations;
            this.eventDB          = eventDB;
            this.courseId         = courseId;
            this.modificationDate = DateTimeOffset.Now;
            this.courseName       = eventDB.GetCourse(courseId).name;

            // Create the XML writer.
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent   = true;
            settings.Encoding = new UTF8Encoding(false);
            xmlWriter         = XmlWriter.Create(filename, settings);

            WriteStart();

            WriteAllTeams();

            WriteEnd();

            // And done.
            xmlWriter.Close();
            eventDB   = null;
            xmlWriter = null;
        }
示例#2
0
        public void WriteXml(string filename, RelayVariations relayVariations, EventDB eventDB, Id<Course> courseId)
        {
            this.relayVariations = relayVariations;
            this.eventDB = eventDB;
            this.courseId = courseId;
            this.modificationDate = DateTimeOffset.Now;
            this.courseName = eventDB.GetCourse(courseId).name;

            // Create the XML writer.
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.Encoding = new UTF8Encoding(false);
            xmlWriter = XmlWriter.Create(filename, settings);

            WriteStart();

            for (int teamNumber = 1; teamNumber < relayVariations.NumberOfTeams; ++teamNumber) {
                WriteTeam(teamNumber);
            }

            WriteEnd();

            // And done.
            xmlWriter.Close();
            eventDB = null;
            xmlWriter = null;
        }
示例#3
0
            public int totalScore; // Total score for all forks.

            public TeamAssignment(RelayVariations relayVariations)
            {
                outer = relayVariations;

                legAssignForFork = new Dictionary <Fork, LegAssignmentForOneFork>();
                foreach (Fork fork in outer.allForks)
                {
                    legAssignForFork[fork] = new LegAssignmentForOneFork();
                }
            }
示例#4
0
        public void WriteTeamsPart(XmlWriter xmlWriter, RelayVariations relayVariations, EventDB eventDB, Id <Course> courseId)
        {
            this.xmlWriter        = xmlWriter;
            this.relayVariations  = relayVariations;
            this.eventDB          = eventDB;
            this.courseId         = courseId;
            this.modificationDate = DateTimeOffset.Now;
            this.courseName       = eventDB.GetCourse(courseId).name;

            WriteAllTeams();
        }
示例#5
0
        public void WriteCsv(string fileName, RelayVariations relayVariations)
        {
            this.relayVariations = relayVariations;

            using (writer = new StreamWriter(fileName, false, Encoding.ASCII)) {
                WriteHeaderLine();
                WriteTeams();
            }

            writer = null;
            relayVariations = null;
        }
示例#6
0
        public void WriteCsv(string fileName, RelayVariations relayVariations)
        {
            this.relayVariations = relayVariations;

            using (writer = new StreamWriter(fileName, false, Encoding.ASCII)) {
                WriteHeaderLine();
                WriteTeams();
            }

            writer          = null;
            relayVariations = null;
        }
示例#7
0
 void WriteTeamAssignments()
 {
     foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB))
     {
         if (QueryEvent.HasVariations(eventDB, courseId))
         {
             Course course = eventDB.GetCourse(courseId);
             if (course.relaySettings.relayTeams > 0)
             {
                 RelayVariations relayVariations = new RelayVariations(eventDB, courseId, course.relaySettings);
                 WriteRelayVariations(courseId, relayVariations);
             }
         }
     }
 }
示例#8
0
        // Given a VariationChoices, select all the course designators that match.
        public static IEnumerable<CourseDesignator> GetDesignatorsFromVariationChoices(EventDB eventDB, Id<Course> courseId, VariationChoices variationChoices)
        {
            switch (variationChoices.Kind) {
                case VariationChoices.VariationChoicesKind.Combined:
                    return new[] { new CourseDesignator(courseId) };

                case VariationChoices.VariationChoicesKind.AllVariations:
                    return (from vi in GetAllVariations(eventDB, courseId)
                            select new PurplePen.CourseDesignator(courseId, vi)).ToArray();

                case VariationChoices.VariationChoicesKind.ChosenVariations:
                    return (from vi in GetAllVariations(eventDB, courseId)
                            where variationChoices.ChosenVariations.Contains(vi.CodeString)
                            select new PurplePen.CourseDesignator(courseId, vi)).ToArray();

                case VariationChoices.VariationChoicesKind.ChosenTeams:
                    Course course = eventDB.GetCourse(courseId);
                    RelayVariations relayVariations = new RelayVariations(eventDB, courseId, course.relayTeams, course.relayLegs);

                    List<CourseDesignator> result = new List<CourseDesignator>();
                    for (int team = variationChoices.FirstTeam; team <= variationChoices.LastTeam; ++team) {
                        for (int leg = 1; leg <= relayVariations.NumberOfLegs; ++leg) {
                            result.Add(new CourseDesignator(courseId, relayVariations.GetVariation(team, leg)));
                        }
                    }

                    return result;

                default:
                    Debug.Fail("Bad variation choices kind");
                    return null;
            }
        }
示例#9
0
            public TeamAssignment(RelayVariations relayVariations)
            {
                outer = relayVariations;

                legAssignForFork = new Dictionary<Fork, LegAssignmentForOneFork>();
                foreach (Fork fork in outer.allForks) {
                    legAssignForFork[fork] = new LegAssignmentForOneFork();
                }
            }
示例#10
0
 protected override void WriteRelayVariations(Id <Course> courseId, RelayVariations relayVariations)
 {
     // Version 2 does not have ability to write relay variations. Do nothing.
 }
示例#11
0
        protected override void WriteRelayVariations(Id <Course> courseId, RelayVariations relayVariations)
        {
            ExportRelayVariations3 exportVariations = new ExportRelayVariations3();

            exportVariations.WriteTeamsPart(xmlWriter, relayVariations, eventDB, courseId);
        }
示例#12
0
 protected abstract void WriteRelayVariations(Id <Course> courseId, RelayVariations relayVariations);