Example #1
0
        public static void ReadGraduatePhoto(this IEnumerable <ReportStudent> students, IStatusReporter reporter)
        {
            Dictionary <string, ReportStudent> dicstudents = students.ToDictionary();
            List <string> keys = students.ToSC().ToKeys();

            Campus.FunctionSpliter <string, PhotoRecord> selectData = new Campus.FunctionSpliter <string, PhotoRecord>(300, 5);
            selectData.Function = delegate(List <string> ps)
            {
                List <PhotoRecord> photos = new List <PhotoRecord>();
                foreach (KeyValuePair <string, string> each in Photo.SelectGraduatePhoto(ps))
                {
                    photos.Add(new PhotoRecord(each.Key, each.Value));
                }
                return(photos);
            };
            List <PhotoRecord> updaterecords = selectData.Execute(keys);

            foreach (PhotoRecord each in updaterecords)
            {
                if (dicstudents.ContainsKey(each.ID))
                {
                    dicstudents[each.ID].GraduatePhoto = each.Photo;
                }
            }
        }
Example #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);
        }