2014-11-27 23:25:36 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using TrainInfomationProviderService.StationInfo;
|
|
|
|
|
using TrainInfomationProviderService.StationInfo.Entities;
|
|
|
|
|
|
|
|
|
|
namespace TrainInfomationProviderService.TrainInfo.Entities
|
|
|
|
|
{
|
|
|
|
|
public class TrainLineSegment
|
|
|
|
|
{
|
|
|
|
|
StationDetailInfo _toStation;
|
|
|
|
|
StationDetailInfo _fromStation;
|
|
|
|
|
TimeSpan? _elapsedTime;
|
|
|
|
|
|
|
|
|
|
public Train Train { get; private set; }
|
|
|
|
|
|
|
|
|
|
public TrainStop From { get; private set; }
|
|
|
|
|
|
|
|
|
|
public TrainStop To { get; private set; }
|
|
|
|
|
|
2014-12-01 02:17:13 +08:00
|
|
|
|
public bool IsBegin {
|
|
|
|
|
get { return From.Arrive == null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsEnd {
|
|
|
|
|
get { return To.Left == null; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-27 23:25:36 +08:00
|
|
|
|
public StationDetailInfo FromStation
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_fromStation == null)
|
|
|
|
|
_fromStation = StationManager.Instance.Storage.Stations.GetValue(From.Code);
|
|
|
|
|
return _fromStation;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StationDetailInfo ToStation
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_toStation == null)
|
|
|
|
|
_toStation = StationManager.Instance.Storage.Stations.GetValue(To.Code);
|
|
|
|
|
return _toStation;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 历时
|
|
|
|
|
/// </summary>
|
|
|
|
|
public TimeSpan ElapsedTime
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_elapsedTime == null)
|
|
|
|
|
_elapsedTime = To.Arrive - From.Left;
|
|
|
|
|
return _elapsedTime ?? TimeSpan.Zero;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int? _calculatedMinutesBase;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 进行时间对比的基础分钟数
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int CalculatedMinutesBase
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_calculatedMinutesBase == null)
|
|
|
|
|
{
|
|
|
|
|
var minutes = ElapsedTime.TotalMinutes;
|
2014-12-01 02:17:13 +08:00
|
|
|
|
|
|
|
|
|
_calculatedMinutesBase = Utility.CalculateTimeForCompare(Train.TrainClass, minutes);
|
2014-11-27 23:25:36 +08:00
|
|
|
|
}
|
|
|
|
|
return _calculatedMinutesBase ?? 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建 <see cref="TrainLineSegment" /> 的新实例(TrainLineSegment)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="train"></param>
|
|
|
|
|
/// <param name="from"></param>
|
|
|
|
|
/// <param name="to"></param>
|
2014-12-01 21:50:08 +08:00
|
|
|
|
public TrainLineSegment(Train train, TrainStop from, TrainStop to, DateTime baseDate)
|
2014-11-27 23:25:36 +08:00
|
|
|
|
{
|
|
|
|
|
Train = train;
|
|
|
|
|
From = from;
|
|
|
|
|
To = to;
|
2014-12-01 21:50:08 +08:00
|
|
|
|
|
|
|
|
|
_left = baseDate.Date.Add(from.Left.Value.AddDays(-from.Left.Value.Days));
|
|
|
|
|
if (_left < baseDate)
|
|
|
|
|
_left = _left.AddDays(1);
|
|
|
|
|
_arrive = _left.Add(to.Arrive.Value - from.Left.Value);
|
2014-11-27 23:25:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 21:50:08 +08:00
|
|
|
|
DateTime _left, _arrive;
|
|
|
|
|
|
|
|
|
|
public DateTime LeftTime
|
|
|
|
|
{
|
|
|
|
|
get { return _left; }
|
|
|
|
|
}
|
2014-11-27 23:25:36 +08:00
|
|
|
|
|
2014-12-01 21:50:08 +08:00
|
|
|
|
public DateTime ArriveTime
|
|
|
|
|
{
|
|
|
|
|
get { return _arrive; }
|
|
|
|
|
}
|
2014-11-27 23:25:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|