Esempio n. 1
0
        /// <summary>
        /// 傳入不包含學生的學生IDList,取得一般或輟學學生
        /// </summary>
        /// <param name="NotInStudentIDList"></param>
        /// <returns></returns>
        public static List <ReportStudent> GetStudentsDef(List <string> NotInStudentIDList)
        {
            List <string> StudentIDList = new List <string>();

            List <ReportStudent> students = new List <ReportStudent>();

            foreach (JHStudentRecord each in JHStudent.SelectAll())
            {
                // 不包含
                if (NotInStudentIDList.Contains(each.ID))
                {
                    continue;
                }

                if (each.Status == K12.Data.StudentRecord.StudentStatus.一般 ||
                    each.Status == K12.Data.StudentRecord.StudentStatus.輟學)
                {
                    ReportStudent rs = new ReportStudent(each);
                    students.Add(rs);
                    StudentIDList.Add(each.ID);
                }
            }

            // 取得學生類別List
            List <StudentTagRecord> StudTagRecList = StudentTag.SelectByStudentIDs(StudentIDList);


            // 取得特種身分學生,加分比
            Dictionary <string, decimal> StudAddWeightDict = DAL.DALTransfer.GetStudentAddWeightFormUDTByStudentTag(StudTagRecList, DAL.DALTransfer._SchoolType);
            // 取得特種身分學生名稱
            Dictionary <string, string> StudSpecTypeDict = DAL.DALTransfer.GetStudentSpcTypeFormUDTByStudentTag(StudTagRecList, DAL.DALTransfer._SchoolType);
            Dictionary <string, K12.Data.UpdateRecordRecord> studUpdateRec = DAL.DALTransfer.GetStudentUpdareDate3ByStudentID(StudentIDList);

            foreach (ReportStudent rs in students)
            {
                // 加分比
                if (StudAddWeightDict.ContainsKey(rs.StudentID))
                {
                    rs.AddWeight = StudAddWeightDict[rs.StudentID];
                }

                // 學生身分
                if (StudSpecTypeDict.ContainsKey(rs.StudentID))
                {
                    rs.SpcStudTypeName = StudSpecTypeDict[rs.StudentID];
                }

                // 轉入學生異動
                if (studUpdateRec.ContainsKey(rs.StudentID))
                {
                    if (studUpdateRec[rs.StudentID] != null)
                    {
                        DateTime dt;

                        if (DateTime.TryParse(studUpdateRec[rs.StudentID].UpdateDate, out dt))
                        {
                            rs.TransUpdateDateStr = (dt.Year - 1911).ToString() + "/" + dt.Month + "/" + dt.Day;
                        }
                        else
                        {
                            rs.TransUpdateDateStr = "";
                        }

                        rs.LastEnterSchoolyear = studUpdateRec[rs.StudentID].SchoolYear;
                        rs.LastEnterSemester   = studUpdateRec[rs.StudentID].Semester;
                        int gr;
                        if (int.TryParse(studUpdateRec[rs.StudentID].GradeYear, out gr))
                        {
                            rs.LastEnterGradeYear = gr;
                        }
                    }
                }
            }
            return(students);
        }
Esempio n. 2
0
        public static void ReadUpdateRecordDate(this IEnumerable <ReportStudent> students, IStatusReporter reporter)
        {
            int t1 = Environment.TickCount;
            Dictionary <string, ReportStudent> dicstudents = students.ToDictionary();
            List <string> keys = students.ToSC().ToKeys();

            Campus.FunctionSpliter <string, JHUpdateRecordRecord> selectData = new Campus.FunctionSpliter <string, JHUpdateRecordRecord>(500, 5);
            selectData.Function = delegate(List <string> ps)
            {
                return(JHUpdateRecord.SelectByStudentIDs(ps));
            };
            List <JHUpdateRecordRecord> updaterecords = selectData.Execute(keys);

            Dictionary <string, List <JHUpdateRecordRecord> > dicupdaterecords = new Dictionary <string, List <JHUpdateRecordRecord> >();
            string ValidCodes = "1:2";  //新生:1 轉入:3 復學:6,畢業:2

            foreach (JHUpdateRecordRecord each in updaterecords)
            {
                //不是要處理的代碼,就跳過。
                if (ValidCodes.IndexOf(each.UpdateCode) < 0)
                {
                    continue;
                }

                if (!dicupdaterecords.ContainsKey(each.StudentID))
                {
                    dicupdaterecords.Add(each.StudentID, new List <JHUpdateRecordRecord>());
                }
                dicupdaterecords[each.StudentID].Add(each);
            }

            foreach (KeyValuePair <string, List <JHUpdateRecordRecord> > each in dicupdaterecords)
            {
                each.Value.Sort(delegate(JHUpdateRecordRecord x, JHUpdateRecordRecord y)
                {
                    DateTime xx, yy;

                    if (!DateTime.TryParse(x.UpdateDate, out xx))
                    {
                        xx = DateTime.MinValue;
                    }

                    if (!DateTime.TryParse(y.UpdateDate, out yy))
                    {
                        yy = DateTime.MinValue;
                    }

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

            string ECodes = "1"; //入學
            string GCodes = "2"; //畢業

            foreach (KeyValuePair <string, List <JHUpdateRecordRecord> > each in dicupdaterecords)
            {
                if (!dicstudents.ContainsKey(each.Key))
                {
                    continue;
                }
                ReportStudent student = dicstudents[each.Key];

                JHUpdateRecordRecord e = each.Value[0];
                JHUpdateRecordRecord g = each.Value[each.Value.Count - 1];

                if (ECodes.IndexOf(e.UpdateCode) >= 0)
                {
                    DateTime dt;

                    if (DateTime.TryParse(e.UpdateDate, out dt))
                    {
                        student.EntranceDate    = string.Format("{0}/{1}/{2}", dt.Year - 1911, dt.Month, dt.Day);
                        student.EngEntranceDate = dt.ToString(Util.EnglishFormat, Util.USCulture);
                    }
                }

                if (GCodes.IndexOf(g.UpdateCode) >= 0)
                {
                    DateTime dt;

                    if (DateTime.TryParse(g.UpdateDate, out dt))
                    {
                        student.GraduateDate    = string.Format("{0}/{1}/{2}", dt.Year - 1911, dt.Month, dt.Day);
                        student.EngGraduateDate = dt.ToString(Util.EnglishFormat, Util.USCulture);
                    }
                }
            }

            Console.WriteLine(Environment.TickCount - t1);
        }