Exemplo n.º 1
0
        public static void PlaneProhibit()
        {
            //飞机航线限制
            //失败
            Airline B0001 = new Airline()
            {
                ID              = "B0001",
                StartAirPort    = "SH",
                EndAirPort      = "BJ",
                StartTime       = new DateTime(2017, 3, 15, 8, 0, 0),
                EndTime         = new DateTime(2017, 3, 15, 11, 0, 0),
                ModifiedPlaneID = "1"
            };

            CheckCondition.CheckAirLine(B0001);

            //正常
            Airline B0002 = new Airline()
            {
                ID              = "B0002",
                StartAirPort    = "SH",
                EndAirPort      = "BJ",
                StartTime       = new DateTime(2017, 3, 15, 8, 0, 0),
                EndTime         = new DateTime(2017, 3, 15, 11, 0, 0),
                ModifiedPlaneID = "2"
            };

            CheckCondition.CheckAirLine(B0002);
        }
Exemplo n.º 2
0
        private static Problem GetProblem(Airline airline)
        {
            //机场限制和航班限制
            var problem = CheckCondition.CheckAirLine(airline);
            //限制没有问题,则检查故障表
            var TyphoonProblem = CheckCondition.IsExistTyphoon(airline);

            if (airline.PreviousAirline != null)
            {
                if (airline.PreviousAirline.FixMethod == enmFixMethod.EmptyFly ||
                    (airline.ModifiedPlaneID != null && airline.PlaneID != null && !airline.ModifiedPlaneID.Equals(airline.PlaneID)))
                {
                    //向上查找第一个不是取消的航班
                    var PreviousNotCancel = airline.PreviousAirline;
                    while (PreviousNotCancel.FixMethod == enmFixMethod.Cancel)
                    {
                        if (PreviousNotCancel.PreviousAirline != null)
                        {
                            PreviousNotCancel = PreviousNotCancel.PreviousAirline;
                        }
                    }
                    //从这个开始的最后一个不是取消的航班
                    //检查一下是否过站时间有问题
                    if (airline.ModifiedStartTime.Subtract(PreviousNotCancel.ModifiedEndTime).TotalMinutes < Utility.StayAtAirPortMinutes)
                    {
                        problem.IsNotEnoughStayAirportTime      = true;
                        problem.TakeoffAfterThisTimeFixStayTime = PreviousNotCancel.ModifiedEndTime.AddMinutes(Utility.StayAtAirPortMinutes);
                    }
                }
            }

            //检查是否同时有两个问题
            if (problem.DetailType != ProblemType.None && TyphoonProblem.DetailType != ProblemType.None)
            {
                //台风提早起飞的6小时检查时候,可能遇见台风和
                problem.DetailType = ProblemType.AirPortTyphoonMix;
                return(problem);
            }
            ;
            if (TyphoonProblem.DetailType != ProblemType.None)
            {
                TyphoonProblem.IsNotEnoughStayAirportTime      = problem.IsNotEnoughStayAirportTime;
                TyphoonProblem.TakeoffAfterThisTimeFixStayTime = problem.TakeoffAfterThisTimeFixStayTime;
                return(TyphoonProblem);
            }
            return(problem);
        }
Exemplo n.º 3
0
        public static void CheckAirPortProhibit()
        {
            //航班一览
            //失败:起飞机场关闭
            Airline A0001 = new Airline()
            {
                ID           = "A0001",
                StartAirPort = "SH",
                EndAirPort   = "BJ",
                StartTime    = new DateTime(2017, 3, 15, 20, 0, 0),
                EndTime      = new DateTime(2017, 3, 15, 23, 0, 0)
            };
            var problem = CheckCondition.CheckAirLine(A0001);

            Utility.Log("StartTime:" + A0001.StartTime);
            Utility.Log("TakeOffEarlyTime:" + problem.TakeOffBeforeThisTime + " TakeoffLateTime:" + problem.TakeoffAfterThisTime);


            //失败:起飞机场关闭(跨日)
            Airline A0002 = new Airline()
            {
                ID           = "A0002",
                StartAirPort = "BJ",
                EndAirPort   = "SH",
                StartTime    = new DateTime(2017, 3, 14, 23, 30, 0),
                EndTime      = new DateTime(2017, 3, 15, 3, 0, 0)
            };

            problem = CheckCondition.CheckAirLine(A0002);
            Utility.Log("StartTime:" + A0002.StartTime);
            Utility.Log("LandEarlyTime:" + problem.TakeOffBeforeThisTime + " LandLateTime:" + problem.TakeoffAfterThisTime);

            Airline A0003 = new Airline()
            {
                ID           = "A0003",
                StartAirPort = "BJ",
                EndAirPort   = "SH",
                StartTime    = new DateTime(2017, 3, 15, 1, 30, 0),
                EndTime      = new DateTime(2017, 3, 15, 4, 0, 0)
            };

            problem = CheckCondition.CheckAirLine(A0003);
            Utility.Log("StartTime:" + A0003.StartTime);
            Utility.Log("TakeOffBeforeThisTime:" + problem.TakeOffBeforeThisTime + " TakeoffAfterThisTime:" + problem.TakeoffAfterThisTime);

            //失败:降落机场关闭
            Airline B0001 = new Airline()
            {
                ID           = "B0001",
                StartAirPort = "BJ",
                EndAirPort   = "SH",
                StartTime    = new DateTime(2017, 3, 15, 15, 0, 0),
                EndTime      = new DateTime(2017, 3, 15, 19, 0, 0)
            };

            problem = CheckCondition.CheckAirLine(B0001);
            Utility.Log("EndTime:" + B0001.EndTime);
            Utility.Log("TakeOffBeforeThisTime:" + problem.TakeOffBeforeThisTime + " TakeoffAfterThisTime:" + problem.TakeoffAfterThisTime);


            //失败:降落机场关闭(跨日,次日)
            Airline B0002 = new Airline()
            {
                ID           = "B0002",
                StartAirPort = "SH",
                EndAirPort   = "BJ",
                StartTime    = new DateTime(2017, 3, 14, 22, 30, 0),
                EndTime      = new DateTime(2017, 3, 15, 1, 0, 0)
            };

            problem = CheckCondition.CheckAirLine(B0002);
            Utility.Log("EndTime:" + B0002.EndTime);
            Utility.Log("TakeOffBeforeThisTime:" + problem.TakeOffBeforeThisTime + " TakeoffAfterThisTime:" + problem.TakeoffAfterThisTime);

            //失败:降落机场关闭(跨日,当日)
            Airline B0003 = new Airline()
            {
                ID           = "B0003",
                StartAirPort = "SH",
                EndAirPort   = "BJ",
                StartTime    = new DateTime(2017, 3, 14, 21, 30, 0),
                EndTime      = new DateTime(2017, 3, 14, 23, 0, 0)
            };

            problem = CheckCondition.CheckAirLine(B0003);
            Utility.Log("EndTime:" + B0003.EndTime);
            Utility.Log("TakeOffBeforeThisTime:" + problem.TakeOffBeforeThisTime + " TakeoffAfterThisTime:" + problem.TakeoffAfterThisTime);
        }