Example #1
0
        public void GetAllRating()
        {
            var schedule = new List <int>()
            {
            };
            var connection    = new DBConnection();
            var eval          = new Evaluator();
            var scheduleQuery = $"select GeneratedPlanId from GeneratedPlan where GeneratedPlanId > 600";
            var schedules     = connection.ExecuteToDT(scheduleQuery);

            foreach (DataRow schedulesRow in schedules.Rows)
            {
                schedule.Add((int)schedulesRow["GeneratedPlanId"]);
            }


            foreach (int scheduleId in schedule)
            {
                var parameterQuery = $"select ParameterSetId from GeneratedPlan where GeneratedPlanId={scheduleId}";
                var parameterId    = (int)connection.ExecuteToDT(parameterQuery).Rows[0]["ParameterSetId"];

                var parameterSetQuery = $"select ParameterSet.MajorID, SchoolID, TimePeriod, MaxNumberOfQuarters, NumberCoreCoursesPerQuarter, CreditsPerQuarter, SummerPreference, DepartmentId from ParameterSet join Major on ParameterSet.MajorID = Major.MajorID" +
                                        $" join TimePreference on TimePreference.TimePreferenceID = ParameterSet.TimePreferenceID" +
                                        $" where ParameterSetId = {parameterId}";
                var parameterSetResult = connection.ExecuteToDT(parameterSetQuery);

                var parameters = Preferences.ConvertFromDatabase(parameterSetResult, parameterId);

                var query = "select CourseNumber, QuarterID, YearID, Course.CourseId, Course.DepartmentID from StudyPlan" +
                            " join course on Course.CourseID = StudyPlan.CourseID" +
                            $" where GeneratedPlanID = {scheduleId}";

                var results = connection.ExecuteToDT(query);
                var model   = ScheduleModel.ConvertFromDatabase(results, scheduleId, parameters);
                var rating  = eval.evalaute(model);

                RatingHelper.UpdateWeakLabelScore(scheduleId, rating);
            }
        }
        public string Get(int id)
        {
            var connection     = new DBConnection();
            var parameterQuery = $"select ParameterSetId from GeneratedPlan where GeneratedPlanId={id}";
            var parameterId    = (int)connection.ExecuteToDT(parameterQuery).Rows[0]["ParameterSetId"];

            var parameterSetQuery = $"select ParameterSet.MajorID, SchoolID, TimePeriod, MaxNumberOfQuarters, NumberCoreCoursesPerQuarter, CreditsPerQuarter, SummerPreference, DepartmentId from ParameterSet join Major on ParameterSet.MajorID = Major.MajorID" +
                                    $" join TimePreference on TimePreference.TimePreferenceID = ParameterSet.TimePreferenceID" +
                                    $" where ParameterSetId = {parameterId}";
            var parameterSetResult = connection.ExecuteToDT(parameterSetQuery);

            var parameters = Preferences.ConvertFromDatabase(parameterSetResult, parameterId);
            var query      = "select CourseNumber, QuarterID, YearID, Course.CourseId, DepartmentId from StudyPlan" +
                             " join course on Course.CourseID = StudyPlan.CourseID" +
                             $" where GeneratedPlanID = {id}";


            var results = connection.ExecuteToDT(query);
            var model   = ScheduleModel.ConvertFromDatabase(results, id, parameters);

            var response = JsonConvert.SerializeObject(model);

            return(response);
        }