예제 #1
0
    public void ProcessText(string rawText)
    {
        List <ClassInfomation> dataList = new List <ClassInfomation>();

        string[] weeklyData = CropByWeek(rawText);
        for (int i = 1; i < weeklyData.Length; i++)
        {
            string weekData = weeklyData[i];
            //print("Week]" + weekData);
            string[]   timeData   = CropByTime(weekData);
            string[][] dailyDatas = { CropByDay(timeData[0]),
                                      CropByDay(timeData[1]),
                                      CropByDay(timeData[2]) };
            for (int j = 1; j < dailyDatas[0].Length; j++)
            {
                string   date;
                string[] moContents = FetchContentAtMorning(dailyDatas[0][i], out date);

                string[] afContents = FetchContentOther(dailyDatas[1][i]);
                string[] evContents = FetchContentOther(dailyDatas[2][i]);

                ClassInfomation tempInfo = new ClassInfomation();
                if (TryConvertStringsToInfo(moContents, date, ClassSession.Morning, type, ref tempInfo))
                {
                    dataList.Add(tempInfo);
                }
                if (TryConvertStringsToInfo(afContents, date, ClassSession.Afternoom, type, ref tempInfo))
                {
                    dataList.Add(tempInfo);
                }
                if (TryConvertStringsToInfo(evContents, date, ClassSession.Evening, type, ref tempInfo))
                {
                    dataList.Add(tempInfo);
                }
            }
        }

        result = dataList;
    }
예제 #2
0
    bool TryConvertStringsToInfo(string[] contents, string date, ClassSession session, FetchType type, ref ClassInfomation info)
    {
        if (contents == null)
        {
            return(false);
        }
        switch (type)
        {
        case FetchType.Teacher:
            info = new ClassInfomation()
            {
                date      = DateTime.Parse(date),
                session   = session,
                classCode = contents[0],
                className = contents[1],
                classRoom = contents[2]
            };
            break;

        case FetchType.ClassCode:
            info = new ClassInfomation()
            {
                date      = DateTime.Parse(date),
                session   = session,
                teacher   = contents[0],
                className = contents[1],
                classRoom = contents[2]
            };
            break;

        default:
            return(false);
        }

        return(true);
    }