示例#1
0
 /// <summary>
 /// Sort DESC
 /// </summary>
 /// <param name="item1"></param>
 /// <param name="item2"></param>
 /// <returns></returns>
 private int CompareTime(ScheduleItem item1, ScheduleItem item2)
 {
     if (item1.ScheduleTime > item2.ScheduleTime)
         return 1;
     else
         return -1;
 }
示例#2
0
        private List<ScheduleItem> ParseInput(List<string> lines)
        {
            List<ScheduleItem> requests = new List<ScheduleItem>();
            if (lines.Count <= 0)
                return requests;
            else
            {
                foreach (string line in lines)
                {
                    ScheduleItem schedule = new ScheduleItem();
                    string[] words = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    if (words.Length == 1)
                    {
                        // ignore bad input
                        schedule.ScheduleTime = TextFormatHelper.ConvertTimeStrToNum(words[0]);
                        if (schedule.ScheduleTime < 0)
                            continue;
                    }
                    else if (words.Length > 1)
                    {
                        // ignore bad input
                        schedule.ScheduleTime = TextFormatHelper.ConvertTimeStrToNum(words[words.Length - 1]);
                        if (schedule.ScheduleTime < 0)
                            continue;
                        else
                        {
                            schedule.ScheduleName = string.Join(" ", words, 0, words.Length - 1);
                        }
                    }
                    else
                        break;

                    requests.Add(schedule);
                }
            }

            return requests;
        }