예제 #1
0
        private async Task ExecuteLoadCoursesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                CourseCollection.Clear();
                var courses = await DataStore.GetItemsAsync(true);

                foreach (var item in courses)
                {
                    CourseCollection.Add(item);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                throw;
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #2
0
 public IFFFile(string filename)
 {
     FileName            = filename;
     Part                = new PartCollection();
     Card                = new CardCollection();
     Caddie              = new CaddieCollection();
     Item                = new ItemCollection();
     LevelUpPrizeItem    = new LevelUpPrizeItemCollection();
     Character           = new CharacterCollection();
     Ball                = new BallCollection();
     Ability             = new AbilityCollection();
     Skin                = new SkinCollection();
     CaddieItem          = new CaddieItemCollection();
     Club                = new ClubCollection();
     ClubSet             = new ClubSetCollection();
     Course              = new CourseCollection();
     CutinInformation    = new CutinInformationCollection();
     Desc                = new DescCollection();
     Furniture           = new FurnitureCollection();
     FurnitureAbility    = new FurnitureAbilityCollection();
     Mascot              = new MascotCollection();
     TikiSpecialTable    = new TikiSpecialTableCollection();
     TikiRecipe          = new TikiRecipeCollection();
     TikiPointTable      = new TikiPointTableCollection();
     CadieMagicBox       = new CadieMagicBoxCollection();
     CadieMagicBoxRandom = new CadieMagicBoxRandomCollection();
     HairStyle           = new HairStyleCollection();
     Match               = new MatchCollection();
     SetItem             = new SetItemCollection();
     Enchant             = new EnchantCollection();
     Achievement         = new AchievementCollection();
     AuxPart             = new AuxPartCollection();
 }
예제 #3
0
        public CourseCollection GetAllCourses(string sGrade, string sTerm, string sSubjects, string sLevels, bool bUseGroup)
        {
            var courseCollection = new CourseCollection();

            foreach (var sLevel in sLevels.Split(',').Select(s => s.Trim()).ToList())
            {
                foreach (var sSubject in sSubjects.Split(',').Select(s => s.Trim()).ToList())
                {
                    var sUrl =
                        $"http://sbj.speiyou.com/search/index/grade:{sGrade}/subject:{sSubject}/level:{sLevel}/term:{sTerm}/gtype:time";
                    var nPageCount = CourseSelectorHelper.GetPages(sUrl);
                    if (nPageCount > 0)
                    {
                        var waitHandles = new WaitHandle[nPageCount];
                        for (var i = 1; i <= nPageCount; i++)
                        {
                            waitHandles[i - 1] = new ManualResetEvent(false);
                            var pageUrl =
                                $"http://sbj.speiyou.com/search/index/grade:{sGrade}/subject:{sSubject}/level:{sLevel}/term:{sTerm}/period:/teaid:/m:/d:/time:/bg:n/nu:/service:/curpage:{i}";
                            ThreadPool.QueueUserWorkItem(e =>
                            {
                                var collection = CourseSelectorHelper.GetCourses(((object[])e)[1].ToString());
                                lock (courseCollection)
                                    courseCollection.AddRange(collection);
                                ((ManualResetEvent)((object[])e)[0]).Set();
                            }, new object[] { waitHandles[i - 1], pageUrl });
                        }
                        WaitHandle.WaitAll(waitHandles);
                    }
                }
            }

            return(bUseGroup ? SetBestGroup(courseCollection) : courseCollection);
        }
예제 #4
0
 public Order()
 {
     CreatedOn  = DateTime.UtcNow;
     OrderLines = new OrderLineCollection();
     Courses    = new CourseCollection();
     Guests     = new GuestCollection();
 }
예제 #5
0
        public void TestDegreeProgramConstructor()
        {
            CourseCollection courses = new CourseCollection();
            DegreeProgram    degree  = new DegreeProgram("Bachelors of Science", courses);

            Assert.AreEqual(degree.Name, "Bachelors of Science");
            Assert.AreEqual(degree.RequiredCourses, courses);
        }
예제 #6
0
        public CalculateProgress(CourseCollection courses)
        {
            InitializeComponent();
            InitializeBackgroundWorker();

            _clear_data = false;
            _courses    = courses;
        }
예제 #7
0
        public static CourseCollection GetCourseCollection()
        {
            var toReturn = new CourseCollection();
            IPredicateExpression filter    = new PredicateExpression();
            IRelationCollection  relations = new RelationCollection();

            toReturn.GetMulti(filter, 0, null, relations);
            return(toReturn);
        }
 private void reFillCheckList()
 {
     courses = CourseDAL.SelectAll();
     for (int i = 0; i < courses.Count; i++)
     {
         ComboboxItem b = new ComboboxItem();
         b.Text  = courses[i].Name;
         b.Value = courses[i].Id;
         checkedListBox1.Items.Add(b.Text);
     }
 }
예제 #9
0
        public static List <bool> DeleteSomeids(CourseCollection c)
        {
            List <bool> b = new List <bool>();

            for (int i = 0; i < c.Count; i++)
            {
                SqlCommand sqlCommand = new SqlCommand(string.Format("delete from Course where id = {0}", c[i].Id));
                b.Add(DBLayer.ExecuteNonQuery(sqlCommand) > 0);
            }
            return(b);
        }
예제 #10
0
        public CalculateResult(CourseCollection courses)
        {
            InitializeComponent();

            _courses = courses;
            foreach (Course each in courses.Values)
            {
                ListViewItem item = new ListViewItem(each.CourseName);
                item.Tag = each;
                CourseList.Items.Add(item);
            }
        }
 public Admin_deleteCourse()
 {
     InitializeComponent();
     courses = new CourseCollection();
     courses = CourseDAL.SelectAll();
     for (int i = 0; i < courses.Count; i++)
     {
         ComboboxItem b = new ComboboxItem();
         b.Text  = courses[i].Name;
         b.Value = courses[i].Id;
         checkedListBox1.Items.Add(b.Text);
     }
 }
예제 #12
0
        protected void SearchCourses(object sender, EventArgs args)
        {
            // Default to error message.
            CourseCount.Text = "Error retrieving course list.";

            // Clear course list
            CourseList.Items.Clear();

            CourseCollection courses = null;

            // Title search terms (lowered for case-insensitive search)
            string titleSearch = CourseFilter.Text.ToLower();

            // Parse org unit Guid and search courses
            try
            {
                string orgUnitStr  = Request.Form["CourseOrgUnit_mapping_0"];
                Guid   orgUnitGuid = new Guid(orgUnitStr);

                // Get courses in org unit
                courses = CourseCollection.GetByOrgUnit(orgUnitGuid, true, false, false);

                // Filter if search term specified
                if (!String.IsNullOrEmpty(titleSearch))
                {
                    courses.ApplyFilter(course => course.Title.ToLower().Contains(titleSearch));
                }

                // Sort by course title
                courses.SortProperty  = "Title";
                courses.SortDirection = CLL.S3.Framework.CSLA.SortDirection.Asc;
                courses.ApplySort();
            }
            catch (Exception ex)
            {
                // Log
                new FrameworkException("Error searching courses.", ex, ExceptionSeverity.Warning);
            }

            if (courses != null)
            {
                // Display count of courses found
                CourseCount.Text = String.Format("{0:n0} courses found:", courses.Count);

                // Add course items to list)
                foreach (Course course in courses)
                {
                    CourseList.Items.Add(new ListItem(course.Title, course.CourseId));
                }
            }
        }
 private void Delete_Click(object sender, EventArgs e)
 {
     clChecked = new CourseCollection();
     for (int i = 0; i < checkedListBox1.Items.Count; i++)
     {
         if (checkedListBox1.GetItemChecked(i))
         {
             clChecked.Add(courses[i]);
             checkedListBox1.Items.RemoveAt(i);
         }
     }
     CourseDAL.DeleteSomeids(clChecked);
     UpdateCombobx();
 }
예제 #14
0
        public static CourseCollection GetCourses(params string[] courseList)
        {
            DSResponse rsp = QueryCourse.GetCourseById(courseList);

            CourseCollection courses = new CourseCollection();

            foreach (XmlElement each in rsp.GetContent().GetElements("Course"))
            {
                Course course = new Course(each);
                courses.Add(course.Identity, course);
            }

            return(courses);
        }
예제 #15
0
 private static void CreateCourseTemplateReference(CourseCollection courses, ExamTemplateCollection templates)
 {
     foreach (Course each in courses.Values)
     {
         if (templates.ContainsKey(each.ExamTemplateId))
         {
             each.SetExamTemplate(templates[each.ExamTemplateId]);
         }
         else
         {
             Console.WriteLine("Course Error:" + each.Identity);
         }
     }
 }
예제 #16
0
        private void LoadCourseItems()
        {
            Cursor.Current = Cursors.WaitCursor;

            var courseItems = new CourseCollection();

            courseItems.LoadAllItemsFromDb();

            cboCourse.Items.Clear();
            foreach (var item in courseItems.Items)
            {
                cboCourse.Items.Add(item);
            }
        }
예제 #17
0
        public static CourseCollection SelectAll()
        {
            DataTable        dt     = database.DBLayer.ExecuteQuery("select * from Course");
            CourseCollection result = new CourseCollection();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int    courseId   = Convert.ToInt32(dt.Rows[i]["id"]);
                string courseName = dt.Rows[i]["course_Name"].ToString();
                int    deptid     = int.Parse(dt.Rows[i]["FK_department"].ToString());
                Course c          = new Course(courseId, courseName, deptid);
                result.Add(c);
            }
            return(result);
        }
예제 #18
0
 private static void CreateCourseStudentTwoWayReference(CourseCollection courses, SCAttendCollection scattends)
 {
     foreach (SCAttend each in scattends.Values)
     {
         if (courses.ContainsKey(each.CourseIdentity))
         {
             Course course = courses[each.CourseIdentity];
             course.SCAttends.Add(each.Identity, each);
             each.SetCourse(course);
         }
         else
         {
             Console.WriteLine("SCAttend Error:" + each.Identity);
         }
     }
 }
        public static CourseCollection GetCourses(string sUrl)
        {
            var      courseCollection = new CourseCollection();
            var      htmlWeb          = new HtmlWeb();
            HtmlNode docNode          = null;

            for (int i = 0; i < 3; i++)
            {
                try
                {
                    docNode = htmlWeb.Load(sUrl).DocumentNode;
                    break;
                }
                catch
                {
                    if (i == 2)
                    {
                        throw new Exception("获取信息失败,这可能是由于网站访问量太大导致。");
                    }
                }
            }
            if (docNode != null)
            {
                foreach (var node in docNode.SelectNodes("//div[@class='s-r-list']"))
                {
                    var course = new Course
                    {
                        称   = node.FirstChild.NextSibling.FirstChild.NextSibling.FirstChild.NextSibling.FirstChild.InnerText,
                        老师  = node.FirstChild.FirstChild.NextSibling.InnerText,
                        课地点 =
                            node.FirstChild.NextSibling.FirstChild.NextSibling.FirstChild.NextSibling.NextSibling
                            .NextSibling.NextSibling.NextSibling.InnerText,
                        课时间 =
                            node.FirstChild.NextSibling.FirstChild.NextSibling.FirstChild.NextSibling.NextSibling
                            .NextSibling.NextSibling.FirstChild.NextSibling.InnerText,
                        学科 =
                            node.FirstChild.NextSibling.FirstChild.NextSibling.FirstChild.NextSibling.NextSibling
                            .NextSibling.FirstChild.InnerText,
                        剩余 = node.FirstChild.NextSibling.FirstChild.NextSibling.NextSibling.FirstChild.FirstChild.InnerText
                    };
                    courseCollection.Add(course);
                }
            }
            return(courseCollection);
        }
예제 #20
0
        public ExamGeneration()
        {
            InitializeComponent();

            course = new Course();
            adm    = new Admin();
            adm.Id = 1;
            exam   = new Exam(false, adm);

            courses = CourseDAL.SelectAll();

            for (int i = 0; i < courses.Count; i++)
            {
                ComboboxItem item = new ComboboxItem();
                item.Text  = courses[i].Name;
                item.Value = courses[i].Id;
                CourseNameComboBox.Items.Add(item);
                CourseNameComboBox.SelectedIndex = 0;
            }
            updateCourse();

            exams = ExamDAL.getAll(adm);
            for (int i = 0; i < exams.Count; i++)
            {
                ComboboxItem item = new ComboboxItem();
                item.Text  = exams[i].Id.ToString();
                item.Value = exams[i].Id;
                ExamsComboBox.Items.Add(item);
                ExamsComboBox.SelectedIndex = 0;
            }

            QuestionCollection col = QuestionDAL.GetByType(1);

            MCQnumLabel.Text = col.Count.ToString();
            QuestionCollection col2 = QuestionDAL.GetByType(2);

            TFnumLabel.Text = col2.Count.ToString();
            QuestionCollection col3 = QuestionDAL.GetByType(3);

            EssaynumLabel.Text = col3.Count.ToString();

            updateExamSessions();
        }
예제 #21
0
        private CourseCollection SetBestGroup(CourseCollection courseCollection)
        {
            var listSubject = courseCollection.GroupBy(c => c.学科).Select(c => c.Key).Distinct().ToList();

            foreach (var gSubjectPlace in courseCollection.GroupBy(c => c.课地点))
            {
                if (gSubjectPlace.Select(d => d.期别).Any(d => d.Contains("期")))
                {
                    foreach (var sTerm in gSubjectPlace.Select(d => d.期别).Distinct())
                    {
                        var listSubjectPlace = gSubjectPlace.Where(a => a.期别 == sTerm).OrderBy(a => a.课时间).ToList();
                        for (var i = 0; i < listSubjectPlace.Count - listSubject.Count; i++)
                        {
                            var listNSubject = listSubjectPlace.Skip(i).Take(listSubject.Count).ToList();
                            if (listNSubject.Select(a => a.学科).Distinct().Count() == listSubject.Count &&
                                listNSubject.Select(b => b.课时间).Distinct().Count() == listSubject.Count &&
                                listNSubject.All(e => e.组合 == null))
                            {
                                listNSubject.ForEach(c => c.组合 = gSubjectPlace.Key + "-" + sTerm + "-" + (i + 1));
                            }
                        }
                    }
                }
                else if (gSubjectPlace.Select(d => d.期别).Any(d => d.Contains("周")))
                {
                    var listSubjectPlace = gSubjectPlace.OrderBy(a => a.课时间).ToList();
                    for (var i = 0; i < listSubjectPlace.Count - listSubject.Count; i++)
                    {
                        var listNSubject = listSubjectPlace.Skip(i).Take(listSubject.Count).ToList();
                        if (listNSubject.Select(a => a.学科).Distinct().Count() == listSubject.Count &&
                            listNSubject.Select(b => b.课时间).Distinct().Count() == listSubject.Count &&
                            listNSubject.All(e => e.组合 == null))
                        {
                            var sGroup = gSubjectPlace.Key + "-" + (i + 1);
                            listNSubject.ForEach(c => c.组合 = sGroup);
                        }
                    }
                }
            }
            return(courseCollection);
        }
        private void Admin_viewCourses_Load(object sender, EventArgs e)
        {
            courses     = new CourseCollection();
            departments = new DepartmentCollection();
            Course c = new Course();

            courses     = CourseDAL.SelectAll();
            departments = DepartmentDAL.GetAll();
            for (int i = 0; i < courses.Count; i++)
            {
                for (int j = 0; j < departments.Count; j++)
                {
                    if (courses[i].Deparment.Id == departments[j].Id)
                    {
                        courses[i].Deparment.Name = departments[j].Name;
                        break;
                    }
                }
                this.dataGridView1.Rows.Add((i + 1).ToString(), courses[i].Name, courses[i].Deparment.Name, "Update");
            }
        }
예제 #23
0
        public CourseScoreUpdater(CourseCollection courses, IProgressUI progress, bool clearData)
        {
            _courses    = courses;
            _progress   = progress;
            _clear_data = clearData;

            _packings = new List <List <Course> >();
            List <Course> package      = new List <Course>();
            int           currentIndex = 0;

            foreach (Course each in courses.Values)
            {
                if (currentIndex % PackingSize == 0)
                {
                    package = new List <Course>();
                    _packings.Add(package);
                }

                package.Add(each);
                currentIndex++;
            }
        }
        public List <Transcript.StudentCourseReport> GetDegreeReport(string studentIDCheck)
        {
            DegreeProgramDAL programDAL      = new DegreeProgramDAL();
            String           degreeProgram   = programDAL.GetDegreeProgramByStudentID(studentIDCheck);
            CourseCollection requiredCourses = programDAL.GetCoursesByDegreeProgram(degreeProgram);
            DegreeProgram    program         = new DegreeProgram(degreeProgram, requiredCourses);
            StudentDAL       studentDal      = new StudentDAL();
            Student          student         = studentDal.GetStudentByStudentID(studentIDCheck);
            CourseDAL        courseDal       = new CourseDAL();
            List <Course>    coursesTaken    = courseDal.GetCoursesByStudentID(studentIDCheck);
            Transcript       transcript      = new Transcript(program, student, coursesTaken);
            CourseTimeDAL    courseTimeDal   = new CourseTimeDAL();

            foreach (var course in transcript.Courses)
            {
                char?      grade = studentDal.GetGradeByCourseAndStudentID(course.CRN, studentIDCheck);
                CourseTime time  = courseTimeDal.GetCourseTimeByCRN(course.CRN);
                Transcript.StudentCourseReport courseReport = new Transcript.StudentCourseReport(course, program, student, grade, time);
                transcript.CourseReports.Add(courseReport);
            }
            return(transcript.CourseReports);
        }
        //*************************************************************************
        //Method: OpenCoursebutton_Click
        //
        //Purpose: Button-click event handler for the OpenCoursebutton, it will
        //provide the user with an OpenFileDialog to open a .json file containing
        //course data, and will deseralize data into the cc CourseCollection
        //member variable.
        //*************************************************************************
        private void OpenCoursebutton_Click(object sender, RoutedEventArgs e)
        {
            string name = "";
            //Creates an OpenFileDialog set to the current directory, will only open .json files.
            OpenFileDialog opf = new OpenFileDialog();

            opf.InitialDirectory = Environment.CurrentDirectory;
            opf.Filter           = "JSON files (*.json)|*.json";
            opf.FilterIndex      = 1;
            opf.Title            = "Open Course Collection From JSON";
            opf.RestoreDirectory = true;
            //If user selects a file it will go through this if-statement.
            if (opf.ShowDialog() == true)
            {
                name = opf.FileName;
                //Deseralizes data into the CourseCollection member variable.
                FileStream cReader = new FileStream(name, FileMode.Open, FileAccess.Read);
                DataContractJsonSerializer cInput;
                cInput = new DataContractJsonSerializer(typeof(CourseCollection));
                cc     = (CourseCollection)cInput.ReadObject(cReader);
                cReader.Close();
                //Provides message to show file was opened.
                MessageBox.Show("File Opened Succesfully");
                //Sets the CourseFileName textbox to the name of the file location,
                //if the user selects cancel or does not open a file, nothing will occur, and the
                //previously opened filename will remain in the CourseFileName textbox.
                textBoxCourseFileName.Text = name;
            }
            //Clears all corresponding textboxes.
            textBoxCourseIdData.Text    = "";
            textBoxCreditsData.Text     = "";
            textBoxDescriptionData.Text = "";
            textBoxDesignatorData.Text  = "";
            textBoxTitleData.Text       = "";
            textBoxNumberData.Text      = "";
            textBoxFindCourseId.Text    = "";
            textBoxFindDesignator.Text  = "";
            textBoxFindNumber.Text      = "";
        }
예제 #26
0
        public ViewCourses()
        {
            InitializeComponent();
            Label  label11  = new Label();
            Label  label22  = new Label();
            Button button11 = new Button();

            courses    = new CourseCollection();
            deparments = new DepartmentCollection();
            c          = new Course();
            courses    = CourseDAL.SelectAll();
            deparments = DepartmentDAL.GetAll();
            for (int i = 0; i < courses.Count; i++)
            {
                for (int j = 0; j < deparments.Count; j++)
                {
                    if (courses[i].Deparment.Id == deparments[i].Id)
                    {
                        courses[i].Deparment.Name = deparments[i].Name;
                    }
                }
            }
        }
예제 #27
0
        public CourseCollection GetCoursesByDegreeProgram(string degreeProgramName)
        {
            if (degreeProgramName == null)
            {
                throw new Exception("Degree name cannot be null");
            }
            MySqlConnection  dbConnection    = DbConnection.GetConnection();
            CourseCollection coursesRequired = new CourseCollection();

            using (dbConnection)
            {
                dbConnection.Open();

                var selectQuery =
                    "SELECT * FROM degree_requires_courses, degree_programs, courses WHERE degree_programs.degree_id = degree_requires_courses.degree_id AND degree_programs.name = @degree_program_name AND degree_programs.name = courses.course_name";

                using (MySqlCommand cmd = new MySqlCommand(selectQuery, dbConnection))
                {
                    cmd.Parameters.AddWithValue("@degree_program_name", degreeProgramName);
                    using (MySqlDataReader queryResultReader = cmd.ExecuteReader())
                    {
                        int CRNOrdinal = queryResultReader.GetOrdinal("CRN");

                        while (queryResultReader.Read())
                        {
                            int       crn            = queryResultReader[CRNOrdinal] == DBNull.Value ? default(int) : queryResultReader.GetInt32(CRNOrdinal);
                            CourseDAL courseDal      = new CourseDAL();
                            Course    courseRequired = courseDal.GetCourseByCRN(crn);
                            coursesRequired.Add(courseRequired);
                        }

                        return(coursesRequired);
                    }
                }
            }
        }
        public void TestCourseCollectionConstructor()
        {
            CourseCollection collection = new CourseCollection();

            Assert.AreEqual(collection.Courses.Count, 0);
        }
 public CourseScoreCalculate(CourseCollection courses)
 {
     _courses = courses;
 }
예제 #30
0
 /// <summary>
 /// Constructor for degree program
 /// </summary>
 /// <param name="name">name of the program</param>
 /// <param name="requiredCourses"> courses required</param>
 public DegreeProgram(string name, CourseCollection requiredCourses)
 {
     this.name            = name;
     this.RequiredCourses = requiredCourses;
 }
예제 #31
0
 protected void UpdateCourses()
 {
     CourseDB courseDb = new CourseDB();
     courseCollection = courseDb.SelectDBWithoutSerialization();
 }