Пример #1
0
        public IList<VRealTimeInfo> GetVehicleRealTimeInfo(string username, string password, string[] arrLicenceNumber)
        {

            Logger.Error(string.Format("{0},{1}", username, password));

            ////password = EncodeStr.EncodePassword(password);
            ////EUser user = null;
            ////try
            ////{
            ////    user = SSOProxy.LogonUser(username, password, PES.Guanaco.Entity.EnumLoginType.UserName, "127.0.0.1");

            ////    if (user == null || user.TenantList.Count == 0)
            ////    {
            ////        throw new Exception("User name or password error!");
            ////    }
            ////}
            ////catch (Exception ex)
            ////{
            ////    Logger.Error(ex);
            ////    throw new Exception("User name or password error!");
            ////}
            try
            {
                UserEntity user = GuanacoServiceFacade.Tenant.GetUser(username, EncodeStr.EncodePassword(password), EnumLoginType.UserName);
                if (user == null || GuanacoServiceFacade.Tenant.GetUserTenants(user.UserCode).Count == 0)
                {
                    throw new Exception("User name or password error!");
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new Exception("User name or password error!");
            }

            IVehicleManager vm = new VehicleManager();

            IList<VRealTimeInfo> ltCurrentInfo = new List<VRealTimeInfo>();

            IList<LatLon> ltLatLon = new List<LatLon>();

            foreach (string licenceNumber in arrLicenceNumber)
            {
                Guid vehicleCode = vm.GetVehicleCodeByLicenceNumber(licenceNumber);

                IGPSTrackManager trackManager = new GPSTrackManager();

                EGPSCurrentInfo currentInfo;

                try
                {
                    currentInfo = trackManager.GetCurrentInfo(vehicleCode);

                    ltLatLon.Add(new LatLon(currentInfo.Latitude, currentInfo.Longitude));

                    VRealTimeInfo realtimeInfo = new VRealTimeInfo();

                    realtimeInfo.CurrentGPSInfo = currentInfo;

                    EBaseVehicle vehicle = new EVehicle();

                    vehicle.LicenceNumber = licenceNumber;

                    realtimeInfo.VehicleInfo = vehicle;

                    ltCurrentInfo.Add(realtimeInfo);
                }
                catch (GPSCurrentInfoNullException ex)
                {
                    Logger.Error(ex);
                    throw ex;
                }
            }

            IMapService mapService = new PES.MapService.MapSearchService.MapService();

            IList<LocationInfo> ltLocationInfo = mapService.InverseGeocoding(ltLatLon.ToArray());

            for (int i = 0; i < ltCurrentInfo.Count; i++)
            {
                ltCurrentInfo[i].LocationInfo = ltLocationInfo[i];
            }

            return ltCurrentInfo;
        }
Пример #2
0
        private string GetAlarmInfo(Guid vehicleCode, VRealTimeInfo realTimeInfoViewEntity, IList<EVehicleRunningState> ltRunningState)
        {
            string alarmInfo = ((int)EnumRunningState.Running).ToString();
            try
            {
                var RunningState = ltRunningState.SingleOrDefault(s => s.VehicleCode == vehicleCode);
                if (RunningState != null)
                {
                    if (RunningState.State == (int)EnumRunningState.Alarming)
                    {
                        try
                        {
                            EnumSMSInfoType type = (EnumSMSInfoType)(RunningState.AlarmType);
                            alarmInfo = EnumSMSInfoHelper.GetString(type);
                        }
                        catch (Exception ex)
                        {
                            Logger.Error(ex);
                        }
                    }
                    else
                    {
                        alarmInfo = GetRunningState(realTimeInfoViewEntity.CurrentGPSInfo);
                    }
                }
                else
                {
                    alarmInfo = GetRunningState(realTimeInfoViewEntity.CurrentGPSInfo);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }

            return alarmInfo;
        }
Пример #3
0
 private void SetOilValue(EBaseVehicle vehicleInfo, VRealTimeInfo realTimeInfoViewEntity, EGPSCurrentInfo currentInfo, EGPSInstallationInfo installationInfo, bool isNotCalcOil)
 {
     if (!isNotCalcOil)      //isNotCalcOil 为真时,不取油耗数据
     {
         try
         {
             realTimeInfoViewEntity.OilValue = GetOilValue(vehicleInfo, currentInfo, installationInfo);
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
         }
     }
 }
Пример #4
0
 private void SetDriverInfo(EBaseVehicle vehicleInfo, VRealTimeInfo realTimeInfoViewEntity, IList<EDriver> ltDriver)
 {
     try
     {
         if (vehicleInfo.DefaultDriverCode != null)
         {
             EDriver driver = ltDriver.SingleOrDefault(s => s.RecordID == vehicleInfo.DefaultDriverCode);
             if (driver != null)
             {
                 realTimeInfoViewEntity.DriverMobile = driver.Mobile;
                 realTimeInfoViewEntity.DriverName = driver.Name;
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
Пример #5
0
 private void SetVehicleType(EBaseVehicle vehicleInfo, VRealTimeInfo realTimeInfoViewEntity, IList<VehicleType> ltVehicleType)
 {
     try
     {
         if (vehicleInfo.TypeCode != null)
         {
             VehicleType vehicleType = ltVehicleType.SingleOrDefault(s => s.RecordID == vehicleInfo.TypeCode.Value);
             if (vehicleType != null) realTimeInfoViewEntity.VehicleType = vehicleType.Name;
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
Пример #6
0
        private VRealTimeInfo CreateVRealTimeInfo(IList<EVehicleAndMileage> ltEVehicleAndMileage, SessionContext sessionContext,
            EGPSCurrentInfo currentInfo, EGPSInstallationInfo installationInfo, bool isNotCalcOil, IList<VehicleType> ltVehicleType
            , IList<EDriver> ltDriver, IList<EVehicleRunningState> ltRunningState)
        {
            LocationInfo locationInfo = null;

            Logger.Trace(string.Format("Vehicle:{0},Latidute:{1},Longitude:{2},EncodeLatLon{3}", currentInfo.VehicleCode.ToString(), currentInfo.Latitude, currentInfo.Longitude, currentInfo.EncodeLatLon));

            EBaseVehicle vehicleInfo = installationInfo.VehicleInfo;

            VRealTimeInfo realTimeInfoViewEntity = new VRealTimeInfo(currentInfo, vehicleInfo, locationInfo);

            SetVehicleType(vehicleInfo, realTimeInfoViewEntity,ltVehicleType);

            SetDriverInfo(vehicleInfo, realTimeInfoViewEntity,ltDriver);

            SetOilValue(vehicleInfo, realTimeInfoViewEntity, currentInfo, installationInfo,isNotCalcOil);

            UpdateMileage(ltEVehicleAndMileage, currentInfo, installationInfo);

            realTimeInfoViewEntity.AlarmInfo = GetAlarmInfo(currentInfo.VehicleCode.Value, realTimeInfoViewEntity,ltRunningState);

            return realTimeInfoViewEntity;
        }