예제 #1
0
        private void CreateReport(String filePath, FitnessClassList fitnessClassList)
        {
            FileStream   outFile;
            StreamWriter writer;

            outFile = new FileStream(filePath, FileMode.Create,
                                     FileAccess.Write);
            writer = new StreamWriter(outFile);

            for (int i = 0; i < fitnessClassList.Count(); i++)
            {
                FitnessClassOpportunity f = fitnessClassList.getFitnessClass(i);

                // output fitness class opportunity details and enclose these details with the xml root tags

                if (i == 0)
                {
                    writer.WriteLine("<fitnessclasses>");
                }

                writer.WriteLine(f.ToString());

                if (i == fitnessClassList.Count() - 1)
                {
                    writer.WriteLine("</fitnessclasses>");
                }
            }

            // close writer
            writer.Close();

            // close file
            outFile.Close();
        }
예제 #2
0
        /// <summary>
        /// Creates a list new list derived from the orginal fitness class list then the sort method is called to created the same list but sorted numrically by ID
        /// </summary>
        /// <param name="fitnessClassList"> A list of fitness classes to be sorted </param>
        /// <returns> A Fitness Class sorted numerically by ID </returns>
        public static FitnessClassList SortById(FitnessClassList fitnessClassList)
        {
            FitnessClassList sortedFitnessClassList = new FitnessClassList();

            for (int i = 0; i < fitnessClassList.Count(); i++)
            {
                sortedFitnessClassList.addFitnessClass(fitnessClassList.getFitnessClass(i));
            }

            sortedFitnessClassList.Sort();

            return(sortedFitnessClassList);
        }
        public void WriteFitnessClassListToFile(FitnessClassList fitnessClassList, String filePath)
        {
            FileStream      outFile;
            BinaryFormatter bFormatter = new BinaryFormatter();

            // open file for output
            outFile = new FileStream(filePath, FileMode.Create, FileAccess.Write);

            // output object to file via serialization
            bFormatter.Serialize(outFile, fitnessClassList);

            // close file
            outFile.Close();
        }
예제 #4
0
        /// <summary>
        /// Filter through the class list selecting the classes that match the location specified then create list with classes at that location
        /// </summary>
        /// <param name="fitnessClassList"> A list of all fitness classes</param>
        /// <param name="selectedLocation"> A location where fitness classes occur </param>
        /// <returns> A list of fitness classes at a specified location </returns>
        public static FitnessClassList FilterLocation(FitnessClassList fitnessClassList, String selectedLocation)
        {
            FitnessClassList filteredFitnessClassList = new FitnessClassList();

            for (int i = 0; i < fitnessClassList.Count(); i++)
            {
                if (fitnessClassList.getFitnessClass(i).Location == selectedLocation)
                {
                    filteredFitnessClassList.addFitnessClass(fitnessClassList.getFitnessClass(i));
                }
            }

            return(filteredFitnessClassList);
        }
        public FitnessClassList ReadFitnessClassListFromFile(String filePath)
        {
            FileStream       inFile;
            FitnessClassList fitnessClassList = null;
            BinaryFormatter  bFormatter       = new BinaryFormatter();

            // open file for input
            inFile = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            // keep going while there are still records to read
            while (inFile.Position < inFile.Length)
            {
                // obtain object from file via serialization
                fitnessClassList = (FitnessClassList)bFormatter.Deserialize(inFile);
            }

            // close file
            inFile.Close();

            return(fitnessClassList);
        }
예제 #6
0
 public TextReportGenerator(FitnessClassList fitnessClassList)
 {
     this.fitnessClassList = fitnessClassList;
 }