public void doParkZoneTypeChange(string park_zone_type_id)
        {
            bool   isSuccess = false;
            string original_park_zone_type_id = string.Empty;
            string new_park_zone_type_id      = string.Empty;

            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                APARKZONETYPE using_park_zone_type   = parkZoneTypeDao.getUsingParkType(con);
                APARKZONETYPE changed_park_zone_type = parkZoneTypeDao.getByID(con, park_zone_type_id);
                if (using_park_zone_type != null && changed_park_zone_type != null)
                {
                    using_park_zone_type.IS_DEFAULT   = 0;
                    changed_park_zone_type.IS_DEFAULT = 1;
                    parkZoneTypeDao.upadate(con);
                    original_park_zone_type_id = using_park_zone_type.PARK_TYPE_ID;
                    new_park_zone_type_id      = changed_park_zone_type.PARK_TYPE_ID;
                    isSuccess = true;
                }
            }
            if (isSuccess)
            {
                setCurrentParkType();
                using (System.Transactions.TransactionScope tx = SCUtility.getTransactionScope())
                {
                    using (DBConnection_EF con = DBConnection_EF.GetUContext())
                    {
                        var original_parkzonedetails = parkZoneDetailDao.loadAllParkAdrByParkTypeID(con, original_park_zone_type_id);
                        var new_parkzonedetails      = parkZoneDetailDao.loadAllParkAdrByParkTypeID(con, new_park_zone_type_id);
                        if (original_parkzonedetails != null && new_parkzonedetails != null)
                        {
                            List <string> original_allParkAdr_id = original_parkzonedetails.Select(detail => detail.ADR_ID.Trim()).ToList();
                            List <string> new_allParkAdr_id      = new_parkzonedetails.Select(detail => detail.ADR_ID.Trim()).ToList();
                            List <string> unUseParkAdr           = original_allParkAdr_id.Except(new_allParkAdr_id).ToList();
                            List <string> newUseParkAdr          = new_allParkAdr_id.Except(original_allParkAdr_id).ToList();

                            List <AVEHICLE> in_unUse_Vhs = scApp.VehicleDao.loadParkVehicleByParkAdrID(unUseParkAdr);
                            foreach (AVEHICLE vh in in_unUse_Vhs)
                            {
                                scApp.ParkBLL.resetParkAdr(vh.PARK_ADR_ID);
                                scApp.VehicleBLL.resetVhIsInPark(vh.VEHICLE_ID);
                                vh.NotifyVhStatusChange();
                            }

                            List <AVEHICLE> in_newUse_Vhs = scApp.VehicleBLL.cache.getVhByAddressIDs(newUseParkAdr.ToArray());
                            foreach (AVEHICLE vh in in_newUse_Vhs)
                            {
                                if (vh.ACT_STATUS == ProtocolFormat.OHTMessage.VHActionStatus.Commanding)
                                {
                                    continue;
                                }
                                scApp.VehicleBLL.setVhIsInPark(vh.VEHICLE_ID, vh.CUR_ADR_ID);
                                scApp.ParkBLL.updateVhEntryParkingAdr(vh.VEHICLE_ID, vh.CUR_ADR_ID);
                                vh.NotifyVhStatusChange();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// //找出目前所有Park Adr停車的 跟 欲前往的方便得知目前為何沒有停車位
        /// </summary>
        /// <param name="con"></param>
        private void ParkAdrInfoTarce()
        {
            //DBConnection_EF con = DBConnection_EF.GetContext();
            List <APARKZONEDETAIL> lstAllParkDetail = null;

            //using (DBConnection_EF con = new DBConnection_EF())
            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                lstAllParkDetail = parkZoneDetailDao.loadAllParkAdrByParkTypeID(con,
                                                                                scApp.getEQObjCacheManager().getLine().Currnet_Park_Type);
            }
            if (lstAllParkDetail == null)
            {
                return;
            }
            foreach (APARKZONEDETAIL detail in lstAllParkDetail)
            {
                string   park_adr    = detail.ADR_ID;
                string   parkingVhID = detail.CAR_ID ?? string.Empty;
                string   onWayVhID   = string.Empty;
                AVEHICLE onWayVh     = null;
                if (scApp.VehicleBLL.hasVhReserveParkAdr(park_adr, out onWayVh))
                {
                    onWayVhID = onWayVh.VEHICLE_ID;
                }
                string park_warn_info =
                    string.Format("Park adr:[{0}] ,Parking vh id:[{1}] ,On way vh id:[{2}]"
                                  , park_adr
                                  , parkingVhID
                                  , onWayVhID);
                logger_ParkBllLog.Info(park_warn_info);
            }
        }
        public void doParkZoneTypeChange(string park_zone_type_id)
        {
            bool   isSuccess = false;
            string original_park_zone_type_id = string.Empty;
            string new_park_zone_type_id      = string.Empty;

            using (DBConnection_EF con = DBConnection_EF.GetUContext())
            {
                APARKZONETYPE using_park_zone_type   = parkZoneTypeDao.getUsingParkType(con);
                APARKZONETYPE changed_park_zone_type = parkZoneTypeDao.getByID(con, park_zone_type_id);
                if (using_park_zone_type != null && changed_park_zone_type != null)
                {
                    using_park_zone_type.IS_DEFAULT   = 0;
                    changed_park_zone_type.IS_DEFAULT = 1;
                    parkZoneTypeDao.upadate(con);
                    original_park_zone_type_id = using_park_zone_type.PARK_TYPE_ID;
                    new_park_zone_type_id      = changed_park_zone_type.PARK_TYPE_ID;
                    isSuccess = true;
                }
            }
            if (isSuccess)
            {
                using (System.Transactions.TransactionScope tx = SCUtility.getTransactionScope())
                {
                    using (DBConnection_EF con = DBConnection_EF.GetUContext())
                    {
                        var original_parkzonedetails = parkZoneDetailDao.loadAllParkAdrByParkTypeID(con, original_park_zone_type_id);
                        var new_parkzonedetails      = parkZoneDetailDao.loadAllParkAdrByParkTypeID(con, new_park_zone_type_id);
                        if (original_parkzonedetails != null && new_parkzonedetails != null)
                        {
                            List <string>   original_allParkAdr_id = original_parkzonedetails.Select(detail => detail.ADR_ID.Trim()).ToList();
                            List <string>   new_allParkAdr_id      = new_parkzonedetails.Select(detail => detail.ADR_ID.Trim()).ToList();
                            List <string>   unUseParkAdr           = original_allParkAdr_id.Except(new_allParkAdr_id).ToList();
                            List <AVEHICLE> vhs = scApp.VehicleDao.loadParkVehicleByParkAdrID(unUseParkAdr);
                            foreach (AVEHICLE vh in vhs)
                            {
                                scApp.ParkBLL.resetParkAdr(vh.PARK_ADR_ID);
                                scApp.VehicleBLL.resetVhIsInPark(vh.VEHICLE_ID);
                            }
                        }
                    }
                }
                setCurrentParkType();
            }
        }