73 lines
1.7 KiB
C#
73 lines
1.7 KiB
C#
|
namespace Web12306.Servers.TrainSuggestion
|
|||
|
{
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text.RegularExpressions;
|
|||
|
using Newtonsoft.Json;
|
|||
|
|
|||
|
public class RequestInfo
|
|||
|
{
|
|||
|
public string Key { get; set; }
|
|||
|
|
|||
|
public string From { get; set; }
|
|||
|
|
|||
|
public string To { get; set; }
|
|||
|
|
|||
|
public DateTime Date { get; set; }
|
|||
|
|
|||
|
[JsonProperty("tt")]
|
|||
|
public string[] SelectedTrain { get; set; }
|
|||
|
|
|||
|
[JsonProperty("ts")]
|
|||
|
public string[] SelectedSeats { get; set; }
|
|||
|
|
|||
|
public Dictionary<string, TrainInfoItem> Stops { get; set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>зǷ<D0B7><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>true
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public bool CheckIllegal()
|
|||
|
{
|
|||
|
if (Key != "stupid360" || Stops == null)
|
|||
|
return true;
|
|||
|
if (Stops.Values.Any(s => (s.TrainInfo.code == s.TrainInfo.from.code && s.TrainInfo.to.code == s.TrainInfo.end.code)))
|
|||
|
return true;
|
|||
|
|
|||
|
//add 2014<31><34>9<EFBFBD><39>4<EFBFBD><34> - <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ϯ<EFBFBD><CFAF>
|
|||
|
if (SelectedSeats == null)
|
|||
|
return true;
|
|||
|
if (SelectedSeats.Length > 0)
|
|||
|
{
|
|||
|
if (Stops.Values.Any(s => !SelectedSeats.Any(x => s.TrainInfo.ticketMap.ContainsKey(x[0]))))
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
//added 2014-9-9 <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (SelectedTrain != null && SelectedTrain.Length > 0)
|
|||
|
{
|
|||
|
var reg = new Regex("^(" + string.Join("|", SelectedTrain.Select(s => TrainSuggestionCommonData.FrequencyTrainCodeMap.GetValue(s).DefaultForEmpty(s))) + ")$", RegexOptions.IgnoreCase);
|
|||
|
if (Stops.Keys.Any(s => !reg.IsMatch(s)))
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
public void PreprocessData()
|
|||
|
{
|
|||
|
foreach (var trainInfoItem in Stops.ToArray())
|
|||
|
{
|
|||
|
if (trainInfoItem.Value.StopInfos == null)
|
|||
|
{
|
|||
|
Stops.Remove(trainInfoItem.Key);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
trainInfoItem.Value.PreprocessData(Date);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|