Esempio n. 1
0
        /*
        * Method: ReadFromCSV
        * Parameters: N/A
        * Output: Saved file in the CSV format
        * Created By: Jeffrey Allen
        * Date: 5/4/2015
        * Modified By: 
        * 
        * Description: Reads the data from an output CSV file
        *  
        */
        public void ReadOutput(string filename)
        {

            if (filename != "")
            {
                System.IO.StreamReader file =
                    new System.IO.StreamReader(filename);

                Globals.totalEnrollemntsFileName = filename;

                string[] splitFileName = filename.Split('.');
                string extention = splitFileName[1];
                string[] semesterAndYear;

                string semesterAndYearLine = file.ReadLine();
                char delimitingFactor = '0';

                if (extention == "csv")
                {
                    delimitingFactor = ',';
                    semesterAndYear = semesterAndYearLine.Split(delimitingFactor);
                    
                }
                else
                {
                    delimitingFactor = ' ';
                    semesterAndYear = semesterAndYearLine.Split(delimitingFactor);
                }

                Globals.semester = semesterAndYear[0];
                Globals.year = semesterAndYear[1];

                // read enrollments file name
                Globals.totalEnrollemntsFileName = file.ReadLine();
                CompressedClassTimes ct = new CompressedClassTimes(Globals.totalEnrollemntsFileName);
                Globals.compressedTimes = ct.GetCompressedClassTimes();

                // read time constraints
                string days = file.ReadLine();
                string starttime = file.ReadLine();
                string lengthofexam = file.ReadLine();
                string btwclass = file.ReadLine();
                string lunchtime = file.ReadLine();

                TimeConstraints readConstraints = new TimeConstraints(Convert.ToInt32(days),
                                                    Convert.ToInt32(starttime), Convert.ToInt32(lengthofexam),
                                                    Convert.ToInt32(btwclass), Convert.ToInt32(lunchtime));

                Globals.timeConstraints = readConstraints;

                // read adminApproved
                string adminApp = file.ReadLine();
                if (adminApp[0] == 'S')
                {
                    Globals.adminApproved = true;
                } 
                else
                {
                    Globals.adminApproved = false;
                }
				Scheduler schedule = new Scheduler(Globals.compressedTimes, Globals.timeConstraints);
				schedule.Schedule();
				Globals.examWeek = schedule.GetExams();

				//string nextLine = file.ReadLine();

				//while (nextLine != "")
				//{
				//	nextLine = file.ReadLine();
				//}

				//// Read and display lines from the file until the end of
				//// the file is reached.
				//while ((nextLine = file.ReadLine()) != null)
				//{
				//	// if header, discard and get next line
				//	if (nextLine[0] == 'D')
				//		nextLine = file.ReadLine();

				//	// if line has single digit, then increment day
				//	if (nextLine[0] == ' ')
				//		continue;
                    

				//	// if line has two exam times, 
				//}

            }
        }
Esempio n. 2
0
        /*
        * Method: RunCompression()
        * Parameters: N/A
        * Output: N/A
        * Created By: Riley Smith
        * Date: 3/30/2015
        * Modified By: Joshua Ford
        * 
        *Description: This will run the compression.
        */
        public void RunCompression()
        {
			string enrollmentWarning = "";
			string oneDayWarning = "";

            if (Globals.totalEnrollemntsFileName != "")
            {
                CompressedClassTimes compressedClassTimes =
                    new CompressedClassTimes(Globals.totalEnrollemntsFileName);

                if (compressedClassTimes.GetErrorList().Count != 0)
                {
                    string errorMsg = "";
                    foreach (string ele in compressedClassTimes.GetErrorList())
                    {
                        errorMsg = errorMsg + ele + "\n";
                    }

                    MessageBox.Show(errorMsg, "ERROR");
                    Globals.compressedTimes = null;
                }
                if (compressedClassTimes.GetWarningLessThanOneStudents() != 0)
                {
                    enrollmentWarning = "Warning - There were "
                        + compressedClassTimes.GetWarningLessThanOneStudents()
                        + " class times flagged for less than 1 students " + 
						"enrolled";       
                }
				if (compressedClassTimes.GetWarningForOneDayClass() != 0)
                {
                    oneDayWarning = "Warning - There were "
                        + compressedClassTimes.GetWarningForOneDayClass()
                        + " class times flagged as night classes and/or "
                        + "one day classes that were "
                        + "less than 1 hour long and/or labs";
					if (enrollmentWarning == "")
					{
						MessageBox.Show(oneDayWarning, "Warning");
					}
                }
				if (enrollmentWarning != "" && oneDayWarning != "")
				{
					enrollmentWarning += "\n" + oneDayWarning;
					MessageBox.Show(enrollmentWarning, "Warning");
				}

                Globals.compressedTimes = 
					compressedClassTimes.GetCompressedClassTimes();
                MessageBox.Show("Enrollment File Accepted");
            }
           
        }