Beispiel #1
0
        private static StudentObj FillStudentFileData(string[] lines)
        {
            bool isValid = false;

            StudentObj saObj = new StudentObj();

            foreach (string line in lines)
            {
                if (line.Contains("S_StringConn"))
                {
                    string value = line.Substring(line.IndexOf("=") + 1).Trim();
                    isValid          = value != string.Empty && value != "?";
                    saObj.StringConn = line.Substring(line.IndexOf("=") + 1).Trim();
                }

                if (line.Contains("S_PATH_JSON_FILE"))
                {
                    string value = line.Substring(line.IndexOf("=") + 1).Trim();
                    isValid    = value != string.Empty && value != "?";
                    saObj.path = line.Substring(line.IndexOf("=") + 1).Trim();
                }
            }
            saObj.IsValid = isValid;
            return(saObj);
        }
Beispiel #2
0
            /// <summary>
            /// Takes in a AccessNet username and creates a StudentObj with the user's first, last, and middle name
            /// already split
            /// </summary>
            /// <param name="accessNet">AccessNet username</param>
            /// <returns>StudentObj</returns>
            public static StudentObj GetStudentPersonInfoByAccessNet(string accessNet)
            {
                try
                {
                    WS_Student_Search.WS_Student proxy   = new WS_Student_Search.WS_Student();
                    WS_Student_Search.Result     results = new WS_Student_Search.Result();
                    results = proxy.GetPersonalInfoByAccessNet(webServiceUsername, webServicePassword, accessNet);

                    StudentObj student = new StudentObj();

                    if (results.Status == "OK")
                    {
                        WS_Student_Search.Student[] s = results.Students;
                        student.firstName  = IsNull(s[0].firstName);
                        student.middleInit = IsNull(s[0].middleInitial);
                        student.lastName   = IsNull(s[0].lastName);
                    }

                    return(student);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
Beispiel #3
0
            /// <summary>
            /// takes in a TUID and creates a StudentObj with Full name, Email, TUID, Major, and College Code
            /// </summary>
            /// <param name="TUID"></param>
            /// <returns></returns>
            public static StudentObj getStudentInfo(string TUID)
            {
                //////// Get LDAP Info
                StudentObj student = new StudentObj();
                LDAPuser   entry   = getLDAPEntryByTUID(TUID);

                if (entry != null)
                {
                    //Split users name into first, middle, and last
                    student = GetStudentPersonInfoByAccessNet(entry.uID);

                    student.email = entry.mail;
                    student.tuid  = entry.templeEduID;

                    //////// Get Academic Info
                    WS_Student studentProxy = new WS_Student();
                    Result     results      = new Result();
                    results = studentProxy.GetAcademicInfoByTUID(webServiceUsername, webServicePassword, TUID);

                    // Check if request was successful
                    if (results.Status == "OK")     // Success
                    {
                        Student[] s = results.Students;
                        student.major1 = s[0].major1;
                        student.major2 = s[0].major2;
                        student.school = s[0].collegeCode;
                    }
                    else     // Something went wrong...
                    {
                        return(null);
                    }
                }

                return(student);
            }
Beispiel #4
0
            /// <summary>
            /// takes in a TUID and creates a StudentObj with Full name, Email, TUID, Major, and College Code
            /// </summary>
            /// <param name="TUID"></param>
            /// <returns></returns>
            public static StudentObj getStudentInfo(string TUID)
            {
                //////// Get LDAP Info
                StudentObj student = new StudentObj();
                LDAPuser   entry   = getLDAPEntryByTUID(TUID);

                if (entry != null)
                {
                    String[] name = entry.cn.Split(null); // splits 'cn' into first, middle, last

                    if (name.Length == 2)                 // No middle initial
                    {
                        student.firstName  = name[0];
                        student.middleInit = "";
                        student.lastName   = name[1];
                    }
                    else if (name.Length == 3) // Has middle initial
                    {
                        student.firstName  = name[0];
                        student.middleInit = name[1];
                        student.lastName   = name[2];
                    }
                    else if (name.Length == 4) // Special case for people with 4 part names
                    {
                        student.firstName  = name[0];
                        student.middleInit = name[1] + " " + name[2];
                        student.lastName   = name[3];
                    }

                    student.email = entry.mail;
                    student.tuid  = entry.templeEduID;

                    //////// Get Academic Info
                    WS_StudentSearch.WS_Student studentProxy = new WS_StudentSearch.WS_Student();
                    WS_StudentSearch.Result     results      = new WS_StudentSearch.Result();
                    results = studentProxy.GetAcademicInfoByTUID(webServiceUsername, webServicePassword, TUID);

                    // Check if request was successful
                    if (results.Status == "OK") // Success
                    {
                        WS_StudentSearch.Student[] s = results.Students;
                        student.major1 = s[0].major1;
                        student.major2 = s[0].major2;
                        student.school = s[0].collegeCode;
                    }
                    else // Something went wrong...
                    {
                        return(null);
                    }
                }

                return(student);
            }
        public void AddStudent(int id, StudentDTO item)
        {
            var tempStudent = new StudentObj
            {
                SSN  = item.SSN,
                Name = item.Name
            };

            _db.Student.Add(tempStudent);
            _db.SaveChanges();

            var tempEnrollment = new EnrollmentObj
            {
            };
        }
Beispiel #6
0
        private static ListObjectInfo ReadConfigFile()
        {
            string[] lines = File.ReadAllLines("config.txt");

            StudentAuthObj studentAuthObj = FillAuthenticationFileData(lines);

            StudentObj studentObj = FillStudentFileData(lines);

            ExternalObject externalObject = FillExternalFileData(lines);

            return(new ListObjectInfo
            {
                StudentAuthObj = studentAuthObj,
                StudentObj = studentObj,
                ExternalObject = externalObject
            });
        }
Beispiel #7
0
        private void BgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <ClassRecord> classRecords = K12.Data.Class.SelectByIDs(ClassIDList);


            List <StudentRecord>         studentRecords    = K12.Data.Student.SelectByClassIDs(ClassIDList);
            List <JHSemesterScoreRecord> semesterScoreList = JHSemesterScore.SelectBySchoolYearAndSemester(studentRecords.Select(x => x.ID).ToList(), selSchoolYear, selSemester);

            Dictionary <string, ClassRecord> classIdToRecord = new Dictionary <string, ClassRecord>();

            //班級名稱對照
            foreach (ClassRecord cr in classRecords)
            {
                if (!classIdToRecord.ContainsKey(cr.ID))
                {
                    classIdToRecord.Add(cr.ID, cr);
                }
            }

            //學生物件整理
            List <StudentObj> stuObjs = new List <StudentObj>();

            foreach (StudentRecord s in studentRecords)
            {
                StudentObj obj = new StudentObj(s);
                obj.ClassRecord = classIdToRecord.ContainsKey(s.RefClassID) ? classIdToRecord[s.RefClassID] : new ClassRecord();
                stuObjs.Add(obj);
            }

            stuObjs.Sort(delegate(StudentObj x, StudentObj y)
            {
                string x1 = x.ClassRecord.DisplayOrder.PadLeft(3, '0');
                string xx = (x.ClassRecord.GradeYear + "").PadLeft(3, '0');
                xx       += x1 == "000" ? "999" : x1;
                xx       += x.ClassRecord.Name.PadLeft(20, '0');
                xx       += (x.StudentRecord.SeatNo + "").PadLeft(3, '0');

                string y1 = y.ClassRecord.DisplayOrder.PadLeft(3, '0');
                string yy = (y.ClassRecord.GradeYear + "").PadLeft(3, '0');
                yy       += y1 == "000" ? "999" : y1;
                yy       += y.ClassRecord.Name.PadLeft(20, '0');
                yy       += (y.StudentRecord.SeatNo + "").PadLeft(3, '0');

                return(xx.CompareTo(yy));
            });

            // 領域補對照
            Dictionary <string, Dictionary <string, DomainScore> > MakeUpDomainDic = new Dictionary <string, Dictionary <string, DomainScore> >();

            // 科目補考對照
            Dictionary <string, Dictionary <string, SubjectScore> > MakeUpSubjDic = new Dictionary <string, Dictionary <string, SubjectScore> >();

            // 處理需要補考學期成績
            foreach (JHSemesterScoreRecord JHssr in semesterScoreList)
            {
                //領域
                foreach (KeyValuePair <string, DomainScore> item in JHssr.Domains)
                {
                    if (item.Value.Score.HasValue && item.Value.Score.Value < 60)
                    {
                        if (!MakeUpDomainDic.ContainsKey(JHssr.RefStudentID))
                        {
                            MakeUpDomainDic.Add(JHssr.RefStudentID, new Dictionary <string, DomainScore>());
                        }

                        MakeUpDomainDic[JHssr.RefStudentID].Add(item.Key, item.Value);
                    }
                }

                //科目
                foreach (string subj in JHssr.Subjects.Keys)
                {
                    SubjectScore ss = JHssr.Subjects[subj];
                    if (JHssr.Subjects[subj].Score.HasValue && JHssr.Subjects[subj].Score.Value < 60)
                    {
                        if (!MakeUpSubjDic.ContainsKey(JHssr.RefStudentID))
                        {
                            MakeUpSubjDic.Add(JHssr.RefStudentID, new Dictionary <string, SubjectScore>());
                        }

                        //科目名稱不應該有重覆
                        MakeUpSubjDic[JHssr.RefStudentID].Add(subj, ss);
                    }
                }
            }

            // templae
            Workbook  wb     = null;
            Worksheet wst    = null;
            int       rowIdx = 1;

            // 使用領域
            if (userSelectDoamin)
            {
                wb     = new Workbook(new MemoryStream(Properties.Resources.匯出學期領域成績_領域));
                wst    = wb.Worksheets[0];
                rowIdx = 1;

                if (MakeUpDomainDic.Count > 0)
                {
                    foreach (StudentObj so in stuObjs)
                    {
                        //只列印一般生
                        if (so.StudentRecord.Status != StudentRecord.StudentStatus.一般)
                        {
                            continue;
                        }

                        if (MakeUpDomainDic.ContainsKey(so.StudentRecord.ID))
                        {
                            foreach (string dName in MakeUpDomainDic[so.StudentRecord.ID].Keys)
                            {
                                // 學號 0
                                wst.Cells[rowIdx, 0].PutValue(so.StudentRecord.StudentNumber);

                                // 班級 1
                                wst.Cells[rowIdx, 1].PutValue(so.ClassRecord.Name);

                                // 座號 2
                                if (so.StudentRecord.SeatNo.HasValue)
                                {
                                    wst.Cells[rowIdx, 2].PutValue(so.StudentRecord.SeatNo.Value);
                                }

                                // 姓名 3
                                wst.Cells[rowIdx, 3].PutValue(so.StudentRecord.Name);

                                // 領域 4
                                wst.Cells[rowIdx, 4].PutValue(dName);
                                // 學年度 5
                                wst.Cells[rowIdx, 5].PutValue(selSchoolYear);

                                // 學期 6
                                wst.Cells[rowIdx, 6].PutValue(selSemester);

                                // 補考成績 7
                                if (MakeUpDomainDic[so.StudentRecord.ID][dName].ScoreMakeup.HasValue)
                                {
                                    wst.Cells[rowIdx, 7].PutValue(MakeUpDomainDic[so.StudentRecord.ID][dName].ScoreMakeup.Value);
                                }

                                rowIdx++;
                            }
                        }
                    }
                }
                e.Result = wb;
            }
            else
            {
                wb     = new Workbook(new MemoryStream(Properties.Resources.匯出學期科目成績_科目));
                wst    = wb.Worksheets[0];
                rowIdx = 1;

                if (MakeUpSubjDic.Count > 0)
                {
                    foreach (StudentObj so in stuObjs)
                    {
                        //只列印一般生
                        if (so.StudentRecord.Status != StudentRecord.StudentStatus.一般)
                        {
                            continue;
                        }

                        if (MakeUpSubjDic.ContainsKey(so.StudentRecord.ID))
                        {
                            foreach (string sName in MakeUpSubjDic[so.StudentRecord.ID].Keys)
                            {
                                // 學號 0
                                wst.Cells[rowIdx, 0].PutValue(so.StudentRecord.StudentNumber);

                                // 班級 1
                                wst.Cells[rowIdx, 1].PutValue(so.ClassRecord.Name);

                                // 座號 2
                                if (so.StudentRecord.SeatNo.HasValue)
                                {
                                    wst.Cells[rowIdx, 2].PutValue(so.StudentRecord.SeatNo.Value);
                                }

                                // 姓名 3
                                wst.Cells[rowIdx, 3].PutValue(so.StudentRecord.Name);

                                // 領域 4
                                wst.Cells[rowIdx, 4].PutValue(MakeUpSubjDic[so.StudentRecord.ID][sName].Domain);

                                // 科目 5
                                wst.Cells[rowIdx, 5].PutValue(MakeUpSubjDic[so.StudentRecord.ID][sName].Subject);

                                // 學年度 6
                                wst.Cells[rowIdx, 6].PutValue(selSchoolYear);

                                // 學期 7
                                wst.Cells[rowIdx, 7].PutValue(selSemester);

                                // 補考成績 8
                                if (MakeUpSubjDic[so.StudentRecord.ID][sName].ScoreMakeup.HasValue)
                                {
                                    wst.Cells[rowIdx, 8].PutValue(MakeUpSubjDic[so.StudentRecord.ID][sName].ScoreMakeup.Value);
                                }

                                rowIdx++;
                            }
                        }
                    }
                }

                e.Result = wb;
            }
        }