public bool tryAdjustTheVhParkingPositionByParkZoneAndPrio(APARKZONEMASTER want2AdjustZoneMater)
        {
            if (want2AdjustZoneMater == null)
            {
                return(false);
            }
            bool isSuccess  = true;
            int  first_Prio = 11;
            List <APARKZONEDETAIL> hasParkingDetail = null;

            //DBConnection_EF con = DBConnection_EF.GetContext();
            //using (DBConnection_EF con = new DBConnection_EF())
            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                hasParkingDetail = parkZoneDetailDao.loadByParkZoneIDAndVhOnAdr(con, want2AdjustZoneMater.PARK_ZONE_ID);
                if (hasParkingDetail == null || hasParkingDetail.Count == 0)
                {
                    return(false);
                }
                APARKZONEDETAIL nextParkZoneDetail = null;

                switch (want2AdjustZoneMater.PARK_TYPE)
                {
                case E_PARK_TYPE.OrderByAsc:
                    foreach (APARKZONEDETAIL parkDetail in hasParkingDetail)
                    {
                        if (parkDetail.PRIO > first_Prio)
                        {
                            nextParkZoneDetail = parkZoneDetailDao.
                                                 getByZoneIDAndPRIO(con, parkDetail.PARK_ZONE_ID, parkDetail.PRIO - 1);
                            if (nextParkZoneDetail != null &&
                                SCUtility.isEmpty(nextParkZoneDetail.CAR_ID))
                            {
                                //目前的寫法應該不用在檢查是否有人預約了下一個車位
                                bool hasReserve = scApp.VehicleBLL.hasVhReserveParkAdr(nextParkZoneDetail.ADR_ID);
                                if (!hasReserve)
                                {
                                    //scApp.CMDBLL.creatCommand_OHTC(packDetail.CAR_ID, string.Empty, string.Empty, E_CMD_TYPE.Move_Pack
                                    //     , packDetail.ADR_ID, nextPackZoneDetail.ADR_ID, 0, 0);
                                    //if (!scApp.CMDBLL.generateCmd_OHTC_Details())
                                    //{
                                    //    break;
                                    //}
                                    scApp.CMDBLL.doCreatTransferCommand(parkDetail.CAR_ID, string.Empty, string.Empty, E_CMD_TYPE.Move_Park
                                                                        , parkDetail.ADR_ID, nextParkZoneDetail.ADR_ID, 0, 0);
                                }
                            }
                        }
                    }
                    break;

                case E_PARK_TYPE.OrderByDes:
                    //1確認是否有其他車輛已經預約這個位置
                    //   是-找下一個位置是否有空位
                    //      是-往前移
                    //      否-先記住命令,再找下一台,直到找到最後一個可以往前移的空位時就一次下達
                    //hasPackingDetail.Reverse();
                    //APACKZONEDETAIL firstPackDetail = hasPackingDetail.First();
                    //APACKZONEDETAIL currentPackZoneDetail = null;

                    //bool hasOrtherVhReserve = scApp.VehicleBLL.hasVhReservePackAdr(firstPackDetail.ADR_ID);
                    //if (hasOrtherVhReserve)
                    //{
                    //    List<ACMD_OHTC> ACMD_OHTCs = new List<ACMD_OHTC>();
                    //    for (int next_prio = firstPackDetail.PRIO - 1; next_prio <= first_Prio; next_prio--)
                    //    {
                    //        currentPackZoneDetail = packZoneDetailDao.
                    //             getByZoneIDAndPRIO(con, firstPackDetail.PACK_ZONE_ID, next_prio + 1);
                    //        nextPackZoneDetail = packZoneDetailDao.
                    //             getByZoneIDAndPRIO(con, firstPackDetail.PACK_ZONE_ID, next_prio);
                    //        if (nextPackZoneDetail != null)
                    //        {
                    //            ACMD_OHTC prebuildCMD = scApp.CMDBLL.buildCommand_OHTC(currentPackZoneDetail.CAR_ID, string.Empty, E_CMD_TYPE.Move_Pack
                    //                , currentPackZoneDetail.ADR_ID, nextPackZoneDetail.ADR_ID, 0, 0);
                    //            ACMD_OHTCs.Add(prebuildCMD);
                    //            if (SCUtility.isEmpty(nextPackZoneDetail.CAR_ID))
                    //            {
                    //                foreach (ACMD_OHTC cmd in ACMD_OHTCs)
                    //                {
                    //                    scApp.CMDBLL.creatCommand_OHTC(cmd);
                    //                    if (!scApp.CMDBLL.generateCmd_OHTC_Details())
                    //                    {
                    //                        return false;
                    //                    }
                    //                    isSuccess = true;
                    //                }
                    //                return true;
                    //            }
                    //        }
                    //        else
                    //        {
                    //            return false;
                    //        }
                    //    }
                    //}
                    break;
                }
            }
            return(isSuccess);
        }
        public bool tryFindNearbyParkZoneHasVhToSupport(APARKZONEMASTER not_enough_zone, out APARKZONEDETAIL nearbyParkZoneDetail)
        {
            bool hasFind = false;

            nearbyParkZoneDetail = null;
            List <APARKZONEDETAIL> eachParkZoneFirstDetailHasVh = null;

            using (DBConnection_EF con = new DBConnection_EF())
            {
                eachParkZoneFirstDetailHasVh = parkZoneDetailDao.loadByEachParkZoneFirstVh(con
                                                                                           , scApp.getEQObjCacheManager().getLine().Currnet_Park_Type);
                if (eachParkZoneFirstDetailHasVh != null)
                {
                    List <KeyValuePair <List <APARKZONEDETAIL>, double> > lstParkDetailAndDis = new List <KeyValuePair <List <APARKZONEDETAIL>, double> >();
                    foreach (APARKZONEDETAIL park_zone_detail in eachParkZoneFirstDetailHasVh)
                    {
                        if (SCUtility.isMatche(park_zone_detail.PARK_ZONE_ID, not_enough_zone.PARK_ZONE_ID))
                        {
                            continue;
                        }
                        List <APARKZONEDETAIL> lastDetail = parkZoneDetailDao.
                                                            loadByParkZoneIDAndVhOnAdr(con, park_zone_detail.PARK_ZONE_ID);
                        APARKZONEMASTER zoneMasterTemp = parkZoneMasterDao.
                                                         getByID(con, park_zone_detail.PARK_ZONE_ID); //TODO 要依據ParkZoneType抓取
                        if (not_enough_zone.VEHICLE_TYPE != zoneMasterTemp.VEHICLE_TYPE ||
                            lastDetail.Count <= zoneMasterTemp.LOWER_BORDER)
                        {
                            continue;
                        }

                        KeyValuePair <string[], double> route_distance;
                        if (scApp.RouteGuide.checkRoadIsWalkable(zoneMasterTemp.ENTRY_ADR_ID, not_enough_zone.ENTRY_ADR_ID, out route_distance))
                        {
                            lstParkDetailAndDis.Add
                                (new KeyValuePair <List <APARKZONEDETAIL>, double>(lastDetail, route_distance.Value));
                        }
                        //string[] ReutrnFromAdr2ToAdr = scApp.RouteGuide.DownstreamSearchSection
                        //    (zoneMasterTemp.ENTRY_ADR_ID, not_enough_zone.ENTRY_ADR_ID, 1);
                        //if (ReutrnFromAdr2ToAdr.Length > 0 && SCUtility.isEmpty(ReutrnFromAdr2ToAdr[0]))
                        //    continue;
                        //string[] minRoute_From2To = ReutrnFromAdr2ToAdr[0].Split('=');

                        //double distance = 0;
                        //if (double.TryParse(minRoute_From2To[1], out distance))
                        //{
                        //    lstParkDetailAndDis.Add
                        //        (new KeyValuePair<List<APARKZONEDETAIL>, double>(lastDetail, distance));
                        //}
                        //else
                        //{
                        //    lstParkDetailAndDis.Add
                        //        (new KeyValuePair<List<APARKZONEDETAIL>, double>(lastDetail, double.MaxValue));
                        //}
                    }
                    if (lstParkDetailAndDis.Count > 0)
                    {
                        lstParkDetailAndDis = lstParkDetailAndDis.OrderBy(o => o.Value).ToList();

                        List <APARKZONEDETAIL> nearbyParkZoneDetails = lstParkDetailAndDis.First().Key.OrderBy(o => o.PRIO).ToList();

                        nearbyParkZoneDetail = nearbyParkZoneDetails.First();
                        hasFind = true;
                    }
                }
            }
            return(hasFind);
        }