コード例 #1
0
        private static int Param_OffLineTime = AppSetting.Param_OffLineTime;   //离线参数(m)

        #region ISysSettingWCFService 成员

        public CommandResultViewModel VehicleOilControl(Guid vehicleCode, string tenantCode, string userCode, EnumOilCommandType commandType)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                PositionService positionServ = new PositionService();
                IList<EGPSCurrentInfo> ltCurrent = positionServ.GetCurrentInfoList(new Guid[] { vehicleCode }.ToList());
                if (!CheckCommandCondition(ltCurrent, vm, commandType)) return vm;

                InsertBreakOilHistoryRecord(ltCurrent[0], tenantCode, userCode, commandType);
                vm.CommandResult = EnumCommandResult.Success;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
            }
            return vm;
        }
コード例 #2
0
        public PagedDataList<PersonalSettingViewModel> PersonalSettingSearch(PersonalSettingSearchViewModel model)
        {
            EMVehicleService service = new EMVehicleService();
            PositionService positionServ = new PositionService();
            try
            {
                //int rowCount = 0;
                //IList<EMVehicle> list = service.Select(model.userCode,model.vehilceLikeStr,true,model.ltGpsTypeID, model.rowIndex,model.pageSize, out rowCount);
                //IList<Guid> ltVehicleCode_Paging = list.Select(p => p.VehicleCode).ToList();
                //IList<EGPSCurrentInfo> ltCurrentInfo = positionServ.GetCurrentInfoList(ltVehicleCode_Paging);

                //IDictionary<Guid, DateTime> CurrentInfoDic = ltCurrentInfo.ToDictionary(p => p.VehicleCode, p => p.ReportTime);
                //IList<EMOpenGPSInfo> listEntity = null;
                /////获取开启GPSCode的返回数据
                //if (model.OpenGPSCodeList != null && model.OpenGPSCodeList.Count > 0)
                //{
                   //  EMOpenGPSInfoService openGPSservice = new EMOpenGPSInfoService();
                   //  listEntity = openGPSservice.GetList(list.Select(p => p.GPSCode).ToList(), 1);
                //}
                //if (list != null && list.Count > 0 && rowCount > 0)
                //{
                //    List<PersonalSettingViewModel> newList = new List<PersonalSettingViewModel>();
                //    PagedDataList<PersonalSettingViewModel> pdl = new PagedDataList<PersonalSettingViewModel>();
                //    foreach (EMVehicle emVehicle in list)
                //    {
                //        PersonalSettingViewModel psvModel = new PersonalSettingViewModel();
                //        psvModel.GpsCode = emVehicle.GPSCode;
                //        psvModel.GpsTypeID = emVehicle.GPSTypeID;
                //        psvModel.VehicleInfo = emVehicle.LicenceNumber;
                //        psvModel.VehicleCode = emVehicle.VehicleCode;
                //        if (CurrentInfoDic.ContainsKey(emVehicle.VehicleCode))
                //        {
                //            TimeSpan timeSpan = DateTime.Now.Subtract(CurrentInfoDic[emVehicle.VehicleCode]);
                //            psvModel.IsEnable = !(timeSpan.TotalMinutes > Param_OffLineTime);
                //        }
                //        else
                //            psvModel.IsEnable = false;
                //        if (listEntity != null && listEntity.Count > 0)
                //        {
                //            foreach (EMOpenGPSInfo gpsInfo in listEntity)
                //            {
                //                if (psvModel.GpsCode == gpsInfo.GPSCode)
                //                {
                //                    psvModel.OpenResultContent = gpsInfo.Results;
                //                    psvModel.LastSetTime = gpsInfo.LastSetTime;
                //                }
                //            }
                //        }
                //        newList.Add(psvModel);
                //    }
                //    pdl.Datas = newList;
                //    pdl.RowCount = rowCount;
                //    return pdl;

                //代码优化
                int rowCount = 0;
                VehicleDAL vDal = new VehicleDAL();
                 List<EmPersonalSetting> pelist = service.NewSelect(model.userCode, model.vehilceLikeStr, true, model.ltGpsTypeID, model.rowIndex, model.pageSize, out rowCount, 1);
                
                if (pelist != null && pelist.Count > 0 && rowCount > 0)
                {
                     
                    PagedDataList<PersonalSettingViewModel> pdl = new PagedDataList<PersonalSettingViewModel>();
                    pdl.Datas = GetPerSettingViewModel(pelist); 
                    pdl.RowCount = rowCount;
                    return pdl;
                }
                return null;
                
                 
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                return null;
            }
        }
コード例 #3
0
ファイル: AndroidWCFService.cs プロジェクト: hhahh2011/CH.Gps
 private IList<LocationInfo> GetLocationInfo(List<LatLon> ltLatLon)
 {
     IPositionService service = new PositionService();
     IList<LocationInfo> ltLocationInfo = service.GetPosition(ltLatLon);
     return ltLocationInfo;
 }
コード例 #4
0
ファイル: AndroidWCFService.cs プロジェクト: hhahh2011/CH.Gps
        /// <summary>
        /// 发送断油断电或供油供电指令
        /// </summary>
        /// <param name="vehicleCode">车辆编号</param>
        /// <param name="commandType">2:断油断电,100:供油供电</param>
        /// <returns></returns>
        public AndroidData<object> SendCommand(string vehicleCode, int commandType, string tenantCode, string userCode)
        {
            AndroidData<object> data = new AndroidData<object>();

            IBreakOilLastRecordManager db = new BreakOilLastRecordManager();
            IBreakOilHistoryManager db2 = new MobileQueryBreakOilHistoryManager();

            IPositionService gpsTrackManager = new PositionService();

            try
            {
                //如果是断油断电,则判断车辆是否熄火5分钟以上,如果不是则不能发送指令。
                if (commandType == 2)
                {
                    bool accOff = db.IsAccOff(new Guid(vehicleCode));
                    if (!accOff)
                    {
                        data.Message = "车辆需要熄火5分钟以上才能发送断油断电";
                        data.ResultCode = ResultCodeEnum.Fail;
                        return data;
                    }
                }

                EBreakOilLastRecord record = db.Exists(new Guid(vehicleCode));

                EGPSCurrentInfo info = gpsTrackManager.GetCurrentInfoFromDB(new Guid(vehicleCode));
                EBreakOilHistoryRecord history = new EBreakOilHistoryRecord();

                TimeSpan timeSpan = DateTime.Now.Subtract(info.ReportTime);
                if (null == info || timeSpan.TotalMinutes > 10)
                {
                    data.Message = "车辆没有在线";
                    data.ResultCode = ResultCodeEnum.Fail;
                    return data;
                }
                else
                {
                    history.ACC = info.ACCState;
                    history.AntennaState = info.AntennaState;
                    history.Area = info.Area;
                    history.CommandType = commandType;
                    history.GPSCode = info.GPSCode;
                    history.IsBreakOil = commandType == 2 ? true : false;
                    history.LandMark = info.LandMark;
                    history.Latitude = Convert.ToDecimal(info.Latitude);
                    history.Longitude = Convert.ToDecimal(info.Longitude);
                    history.Oil = Convert.ToDecimal(info.OilBearing);
                    history.OilState = info.OilState;
                    history.RecordID = Guid.NewGuid();
                    history.Road = info.Road;
                    history.SerialNumber = Guid.NewGuid();
                    history.SetTime = DateTime.Now;
                    history.Speed = Convert.ToDecimal(info.Speed);
                    history.StarkMileage = Convert.ToDecimal(info.StarkMileage);
                    history.TenantCode = tenantCode;
                    history.UserCode = userCode;
                    history.VehicleCode = new Guid(vehicleCode);
                }
                if (null != record)
                {
                    db2.Add(history);
                    record.BreakOilHistoryRecord = history;
                    db.Update(record);
                }
                else
                {
                    db2.Add(history);
                    record = new EBreakOilLastRecord();
                    record.VehicleCode = new Guid(vehicleCode);
                    record.BreakOilHistoryRecord = history;
                    db.Add(record);
                }
                //发送指令待完善
                db.VehicleControl(vehicleCode, commandType, history.SerialNumber);
                data.ResultCode = ResultCodeEnum.Success;
                return data;
            }
            catch (Exception ex)
            {
                data.Message = ex.Message;
                data.ResultCode = ResultCodeEnum.Fail;
                return data;
            }
        }
コード例 #5
0
ファイル: AndroidWCFService.cs プロジェクト: hhahh2011/CH.Gps
        public List<CurrentInfoViewModel> GetCurrentInfoList(PositionRequestViewModel requestVM)
        {

            IPositionService currentInfoServ = new PositionService();
            IList<EGPSCurrentInfo> ltEGPSCurrentInfo = currentInfoServ.GetCurrentInfoList(requestVM.VehicleCodes);
            return ConvertToViewModel(ltEGPSCurrentInfo, requestVM.IsNeedRevise);

        }