private PagedDataList<DeviceManageViewModel> GetDeviceManageViewModel(string tenantCode, EMTenant tenant,
            int rowIndex, int pageSize)
        {

            //获取车辆信息
            EMVehicleService vehicleService = new EMVehicleService();
            int rowCount = 0;
            IList<EMVehicle> vehicleList = vehicleService.SelectAll(new string[] { tenantCode }.ToList(), rowIndex,
                pageSize, ref rowCount, "InstallTime", false);
            if (rowCount == 0)
            {
                return null;
            }
            //获取当前服务器时间
            DateTime nowTime = DateTime.Now;
            //拼装ViewModel
            List<DeviceManageViewModel> modelList = new List<DeviceManageViewModel>();
            foreach (EMVehicle vehicle in vehicleList)
            {
                DeviceManageViewModel model = GetDeviceManageVM(nowTime, vehicle, tenant);
                modelList.Add(model);
            }
            return new PagedDataList<DeviceManageViewModel>()
            {
                Datas = modelList,
                RowCount = rowCount
            };
        }
        private List<DeviceManageViewModel> GetDeviceManageViewModel(IList<EMTenant> tenantList)
        {
            //获取车辆信息
            IEMVehicleService vehicleService = new EMVehicleService();
            IList<EMVehicle> vehicleList = vehicleService.SelectAll(tenantList.Select(f => f.TenantCode).ToList()).OrderByDescending(f => f.InstallTime).ToList();

            //获取当前服务器时间
            DateTime nowTime = DateTime.Now;

            //拼装ViewModel
            List<DeviceManageViewModel> modelList = new List<DeviceManageViewModel>();
            foreach (EMVehicle vehicle in vehicleList)
            {
                EMTenant tenant = tenantList.Where(f => f.TenantCode == vehicle.TenantCode).FirstOrDefault();

                DeviceManageViewModel model = GetDeviceManageVM(nowTime, vehicle, tenant);

                modelList.Add(model);
            }
            return modelList;
        }
示例#3
0
        /// <summary>
        /// 获取客户下车辆分页
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public AndroidData<RPage<List<RVehicleInfo>>> GetPageVehicleList(PPage<PSearchVehicleData> param)
        {
            AndroidData<RPage<List<RVehicleInfo>>> result = new AndroidData<RPage<List<RVehicleInfo>>>() { Message = "此客户暂无车辆数据!", ResultCode = (int)ResultCodeEnum.Fail };
            try
            {
                int rowCount = 0;
                EMVehicleService service = new EMVehicleService();
                IList<EMVehicle> vehicleList = service.SelectAll(new List<string>() { param.PageSearchEntity.TenantCode }, param.RowIndex, param.PageSize, ref rowCount);

                if (vehicleList.IsNullOrEmpty())
                    return result;

                List<RVehicleInfo> RList = new List<RVehicleInfo>();
                foreach (EMVehicle vehicle in vehicleList)
                {
                    RVehicleInfo info = new RVehicleInfo();
                    info.VehicleCode = vehicle.VehicleCode;
                    info.LicenceNumber = vehicle.LicenceNumber;

                    RList.Add(info);
                }

                RPage<List<RVehicleInfo>> rPageLIstInfo = new RPage<List<RVehicleInfo>>() {
                     PageList = RList,
                     RowCount = rowCount
                };
                result.Message = string.Empty;
                result.ResultCode = (int)ResultCodeEnum.Success;
                result.ResultData = rPageLIstInfo;
                //Logger.Info("[GetPageVehicleList]:" + param.PageSearchEntity.TenantCode);
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.ResultCode = (int)ResultCodeEnum.Fail;
                Logger.Error("[GetPageVehicleList]:" + ex.Message, ex);
            }
            return result;
        }
示例#4
0
        /// <summary>
        /// 客户的车辆列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public AndroidData<List<RVehicleInfo>> GetVehicleList(PSearchVehicleData param)
        {
            AndroidData<List<RVehicleInfo>> result = new AndroidData<List<RVehicleInfo>>() { Message = "此客户暂无车辆数据!", ResultCode = (int)ResultCodeEnum.Fail };
            try
            {
                EMVehicleService service = new EMVehicleService();
                IList<EMVehicle> vehicleList = service.SelectAll(param.TenantCode);
                if (vehicleList.IsNullOrEmpty())
                    return result;
                List<RVehicleInfo> RList = new List<RVehicleInfo>();
                foreach (EMVehicle vehicle in vehicleList)
                {
                    RVehicleInfo info = new RVehicleInfo();
                    info.VehicleCode = vehicle.VehicleCode;
                    info.LicenceNumber = vehicle.LicenceNumber;

                    RList.Add(info);
                }
                result.Message = string.Empty;
                result.ResultCode = (int)ResultCodeEnum.Success;
                result.ResultData = RList;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.ResultCode = (int)ResultCodeEnum.Fail;
                Logger.Error("[GetMobileGuestList]:"+ex.Message,ex);
            }
            return result;
        }
 public DBProcessResult DeleteCustomer(string tenantCode)
 {
     DBProcessResult result = new DBProcessResult() { IsSuccess = false, Message = "删除失败!" };
     try
     {
         EMTenantService tenantServ = new EMTenantService();
         UserService userService = new UserService();
         EMVehicleService vehicleServ = new EMVehicleService();
         IList<EMVehicle> ltEMVehicle = vehicleServ.SelectAll(tenantCode);
         if (ltEMVehicle != null && ltEMVehicle.Count > 0)
         {
             result.Message = "对不起,客户下还存在车辆,不能删除!";
             result.IsSuccess = false;
         }
         else
         {
             EMTenant emTenant = tenantServ.Select(tenantCode);
             if (emTenant != null)
             {
                 //EMUser emUser = userService.GetUser(emTenant.RegisterUserCode);
                 userService.Delete(emTenant.RegisterUserCode);//删除注册账号
                 tenantServ.Delete(emTenant);//删除运营商信息
                 result.Message = "删除成功!";
                 result.IsSuccess = true;
             }
             
             //tenantServ.Delete(tenantCode);
             //result.Message = "删除成功!";
             //result.IsSuccess = true;
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message);
     }
     return result;
 }
        public List<VehicleAreaLocusViewModel> GetAreaLocus(string tenantCode, DateTime beginTime, DateTime endTime, double minLon, double minLat, double maxLon, double maxLat, EnumMapType mapType)
        {
            IEMVehicleService vehicleServ = new EMVehicleService();
            IList<EMVehicle> list = vehicleServ.SelectAll(tenantCode);
            if (list == null || list.Count == 0)
            {
                return null;
            }
            Dictionary<string, List<AreaLocusViewModel>> dic = new Dictionary<string, List<AreaLocusViewModel>>();

            //IMapService mapService = new PES.GPS.MapService.MapSearchService.MapService();
            //IList<LatLon> latlonWeb = new List<LatLon>{ new LatLon(maxLat, maxLon), new LatLon(minLat, minLon) };
            //IList<LatLon> latlonReal = mapService.ConvertToRealLatLon(latlonWeb);

            foreach (var vehicle in list) 
            {
                List<AreaLocusViewModel> listAreaLocus = GetSectionLocus(vehicle, beginTime, endTime, new LatLon(maxLat, maxLon), new LatLon(minLat, minLon),mapType);
                if (listAreaLocus.Count > 0) 
                {
                    dic.Add(vehicle.LicenceNumber, listAreaLocus);
                }
            }

            List<VehicleAreaLocusViewModel> listVehicleAreaLocus = dic.Select(o => new VehicleAreaLocusViewModel() { LicenceNumber = o.Key, AreaLocus = o.Value }).ToList();

            return listVehicleAreaLocus;
        }