/* Input example * plateNumber -- GHB-7891 * date -- 08/31/2015 * time -- 10:00 * */ public static List <string> predictProcedure(string plateNumber, string date, string time) { try { List <string> result = new List <string>(); predictorData dataList = xmlParser.readXml(); string lastNumber = plateNumber.Substring(plateNumber.Length - 1, 1); DateTime predictDate = DateTime.Parse(date, new CultureInfo("en-US")); int dayNumber = (int)predictDate.DayOfWeek; predictorTime predictTime = new predictorTime(time); List <predictorItem> items = dataList.getPredictorItem; for (int i = 0; i < items.Count; i++) { predictorItem item = items[i]; if (item.getDayNumber == dayNumber) { if (item.getPlacas.getTypes.Contains(lastNumber)) { if (item.getExceptions.getTypes.Contains(lastNumber) || item.getExceptions.getTypes.Contains(plateNumber)) { return(result); } else { List <scheduleItem> listSchedules = item.getPicos.getSchedules; for (int j = 0; j < listSchedules.Count; j++) { predictorTime begin = listSchedules[j].getBegin; predictorTime end = listSchedules[j].getEnd; if (predictTime.isAfter(begin) && predictTime.isBefore(end)) { //List all street that the car can't circulate. return(item.getStreets.getStreets); } } } } break; } } return(result); } catch (Exception exc) { throw new Exception("Unexpected error , try again"); } }
public bool isBefore(predictorTime timeCompare) { if (this.getHour < timeCompare.getHour) { return(true); } else if (this.getHour == timeCompare.getHour) { if (this.minute <= timeCompare.getMinute) { return(true); } else { return(false); } } else { return(false); } }
public bool isAfter(predictorTime timeCompare) { if (this.getHour > timeCompare.getHour) { return(true); } else if (this.getHour == timeCompare.getHour) { if (this.minute >= timeCompare.getMinute) { return(true); } else { return(false); } } else { return(false); } }
public scheduleItem(string begin, string end) { this.begin = new predictorTime(begin); this.end = new predictorTime(end); }