Beispiel #1
0
        /// <summary>
        /// Rover move start process function
        /// </summary>
        /// <param name="coords"></param>
        /// <param name="directMoves"></param>
        public BaseOutputModel StartMoveOrientation(CoordinateModel coordInput, string orientations, PlateauModel plateauInput, DirectionEnum directionEnum = DirectionEnum.N)
        {
            var output = new BaseOutputModel {
                Success = true
            };

            XCoord         = coordInput.XCoord;
            YCoord         = coordInput.YCoord;
            RoverDirection = directionEnum;

            #region Control

            if (!PlateauCoordControl(plateauInput))
            {
                output.Error   = "!Coordinate Error: You coordinates ( " + XCoord + " , " + YCoord + " )" + ". Coordinates exceed plateu areas. You Plateaus: W => " + plateauInput.Width + " H=>" + plateauInput.Height + ". Please try again.";
                output.Success = false;
                return(output);
            }

            #endregion

            #region Move Function

            foreach (var orientation in orientations)
            {
                if (orientation == (char)MoveOrientationEnum.Left)
                {
                    LeftOrientation();
                }
                else if (orientation == (char)MoveOrientationEnum.Right)
                {
                    RightOrientation();
                }
                else if (orientation == (char)MoveOrientationEnum.Move)
                {
                    MoveOrientation();
                }
                else
                {
                    output.Error   = "Error : Unknown orientation you orientation " + orientation + " Orientation chracters (L,R,M). Please try again.";
                    output.Success = false;
                    return(output);
                }
            }
            #endregion

            output.Result = "XCoord : " + XCoord + " YCoord : " + YCoord + " Direction : " + RoverDirection.ToString();
            return(output);
        }
Beispiel #2
0
        public List <TraTravelInfoModel> DoQueryTrain()
        {
            //1.访问接口获取Json字符串
            string getStr = DoPostRequest();

            TraQueryTrainResponseModel trainResponseModel = new TraQueryTrainResponseModel();
            BaseOutputModel            model = new BaseOutputModel();

            //2.转换成对象
            try
            {
                model = JsonHelper.DeserializeJsonToObject <BaseOutputModel>(getStr);
                trainResponseModel = JsonHelper.DeserializeJsonToObject <TraQueryTrainResponseModel>(getStr);
            }
            catch (Exception)
            {
                throw new Exception("查询未成功,原因是: " + model.msg);
            }

            if (trainResponseModel.code == 200)
            {
                List <TraTravelInfoModel> resultList = new List <TraTravelInfoModel>();

                #region 对象转换


                if (trainResponseModel.code == 200)
                {
                    foreach (var m in trainResponseModel.data)
                    {
                        TraTravelInfoModel infoModel = new TraTravelInfoModel();
                        infoModel = AutoMapperHelper.DoMap <TraQueryTrainResponseDateModel, TraTravelInfoModel>(m);

                        resultList.Add(infoModel);
                        infoModel.DetailList = new List <TraTravelInfoDetailModel>();
                        //F
                        if (m.dw_num != "--" && m.dw_num != "*" && !string.IsNullOrEmpty(m.dw_price) && m.dw_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.DW;
                            exa.SeatPrice = m.dwx_price;
                            exa.SeatCount = m.dw_num;
                            infoModel.DetailList.Add(exa);
                        }
                        //9
                        if (m.swz_num != "--" && m.swz_num != "*" && !string.IsNullOrEmpty(m.swz_price) && m.swz_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.SWZ;
                            exa.SeatPrice = m.swz_price;
                            exa.SeatCount = m.swz_num;
                            infoModel.DetailList.Add(exa);
                        }
                        //P
                        if (m.tdz_num != "--" && m.tdz_num != "*" && !string.IsNullOrEmpty(m.tdz_price) && m.tdz_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.TDZ;
                            exa.SeatPrice = m.tdz_price;
                            exa.SeatCount = m.tdz_num;
                            infoModel.DetailList.Add(exa);
                        }

                        //M
                        if (m.ydz_num != "--" && m.ydz_num != "*" && !string.IsNullOrEmpty(m.ydz_price) && m.ydz_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.YDZ;
                            exa.SeatPrice = m.ydz_price;
                            exa.SeatCount = m.ydz_num;
                            infoModel.DetailList.Add(exa);
                        }
                        //O
                        if (m.edz_num != "--" && m.edz_num != "*" && !string.IsNullOrEmpty(m.edz_price) && m.edz_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.EDZ;
                            exa.SeatPrice = m.edz_price;
                            exa.SeatCount = m.edz_num;
                            infoModel.DetailList.Add(exa);
                        }

                        //6
                        if (m.gjrw_num != "--" && m.gjrw_num != "*" && !string.IsNullOrEmpty(m.gjrw_price) && m.gjrw_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.GJRW;
                            exa.SeatPrice = m.gjrw_price;
                            exa.SeatCount = m.gjrw_num;
                            infoModel.DetailList.Add(exa);
                        }

                        //4
                        if (m.rw_num != "--" && m.rw_num != "*" && !string.IsNullOrEmpty(m.rw_price) && m.rw_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.RW;
                            exa.SeatPrice = m.rwx_price;
                            exa.SeatCount = m.rw_num;
                            infoModel.DetailList.Add(exa);
                        }

                        //3
                        if (m.yw_num != "--" && m.yw_num != "*" && !string.IsNullOrEmpty(m.yw_price) && m.yw_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.YW;
                            exa.SeatPrice = m.ywx_price;
                            exa.SeatCount = m.yw_num;
                            infoModel.DetailList.Add(exa);
                        }



                        //2
                        if (m.rz_num != "--" && m.rz_num != "*" && !string.IsNullOrEmpty(m.rz_price) && m.rz_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.RZ;
                            exa.SeatPrice = m.rz_price;
                            exa.SeatCount = m.rz_num;
                            infoModel.DetailList.Add(exa);
                        }


                        //1
                        if (m.yz_num != "--" && m.yz_num != "*" && !string.IsNullOrEmpty(m.yz_price) && m.yz_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.YZ;
                            exa.SeatPrice = m.yz_price;
                            exa.SeatCount = m.yz_num;
                            infoModel.DetailList.Add(exa);
                        }



                        //暂无
                        if (m.qtxb_num != "--" && m.qtxb_num != "*" && !string.IsNullOrEmpty(m.qtxb_price) && m.qtxb_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.QTXB;
                            exa.SeatPrice = m.qtxb_price;
                            exa.SeatCount = m.qtxb_num;
                            infoModel.DetailList.Add(exa);
                        }

                        //无座
                        if (m.wz_num != "--" && m.wz_num != "*" && !string.IsNullOrEmpty(m.wz_price) && m.wz_price.Trim() != "")
                        {
                            var exa = TrainTypeEnum.WZ;
                            exa.SeatPrice = m.wz_price;
                            exa.SeatCount = m.wz_num;
                            infoModel.DetailList.Add(exa);
                        }
                        infoModel.DetailList.OrderBy(a => a.SeatIndex);
                        if (infoModel.DetailList.Count == 0)
                        {
                            resultList.Remove(infoModel);
                        }
                    }
                    return(resultList);
                }
                else
                {
                    throw new Exception();
                }
                #endregion
            }
            else
            {
                throw new Exception("查询未成功,原因是: " + model.msg);
            }
        }