public long GetVehicleCount(HVehicleQuery mTargetQuery) { var builder = Builders <VehicleObject> .Filter; var filter = builder.Gt("CreateTime", new BsonDateTime(Convert.ToDateTime(mTargetQuery.timeStart))) & builder.Lt("CreateTime", new BsonDateTime(Convert.ToDateTime(mTargetQuery.timeEnd))); if (!string.IsNullOrEmpty(mTargetQuery.queryCphm)) { filter = filter & builder.Regex("vehicle.Hphm", new BsonRegularExpression(mTargetQuery.queryCphm)); } if (!string.IsNullOrEmpty(mTargetQuery.queryClys)) { string[] vehicle_color = mTargetQuery.queryClys.Split(','); filter = filter & builder.In("vehicle.Csys", vehicle_color); } if (!string.IsNullOrEmpty(mTargetQuery.queryCllx)) { filter = filter & builder.Eq("vehicle.Cllx", mTargetQuery.queryCllx); } if (!string.IsNullOrEmpty(mTargetQuery.queryClpp)) { filter = filter & builder.Regex("vehicle.Clpp", mTargetQuery.queryClpp); } if (!string.IsNullOrEmpty(mTargetQuery.queryXwtz)) { filter = filter & builder.Regex("vehicle.Xwtz", mTargetQuery.queryXwtz); } return(mVehicleObjectCollection.Count(filter)); }
public List <VehicleObject> GetVehicleList(HVehicleQuery mTargetQuery) { var builder = Builders <VehicleObject> .Filter; var filter = builder.Gt("CreateTime", new BsonDateTime(Convert.ToDateTime(mTargetQuery.timeStart))) & builder.Lt("CreateTime", new BsonDateTime(Convert.ToDateTime(mTargetQuery.timeEnd))); if (!string.IsNullOrEmpty(mTargetQuery.queryCphm)) { filter = filter & builder.Regex("vehicle.Hphm", new BsonRegularExpression(mTargetQuery.queryCphm)); } if (!string.IsNullOrEmpty(mTargetQuery.queryClys)) { string[] vehicle_color = mTargetQuery.queryClys.Split(','); filter = filter & builder.In("vehicle.Csys", vehicle_color); } if (!string.IsNullOrEmpty(mTargetQuery.queryCllx)) { filter = filter & builder.Eq("vehicle.Cllx", mTargetQuery.queryCllx); } if (!string.IsNullOrEmpty(mTargetQuery.queryClpp)) { filter = filter & builder.Regex("vehicle.Clpp", mTargetQuery.queryClpp); } if (!string.IsNullOrEmpty(mTargetQuery.queryXwtz)) { filter = filter & builder.Regex("vehicle.Xwtz", mTargetQuery.queryXwtz); } var sort = Builders <VehicleObject> .Sort.Descending("CreateTime"); //var cursor = mVehicleObjectCollection.Find(new BsonDocument()).Skip((PageNumber - 1) * PageSize).Limit(PageSize).ToList(); var cursor = mVehicleObjectCollection.Find(filter).Sort(sort).Skip((mTargetQuery.PageNumber - 1) * mTargetQuery.PageSize).Limit(mTargetQuery.PageSize).ToList(); return(cursor); }
public ObjectId GetVehicleFirstId(HVehicleQuery mTargetQuery) { var builder = Builders <VehicleObject> .Filter; var filter = builder.Gt("CreateTime", new BsonDateTime(Convert.ToDateTime(mTargetQuery.timeStart))) & builder.Lt("CreateTime", new BsonDateTime(Convert.ToDateTime(mTargetQuery.timeEnd))); ObjectId object_id = new ObjectId(); try { if (!string.IsNullOrEmpty(mTargetQuery.queryClpp)) { filter = filter & builder.Regex("vehicle.Clpp", mTargetQuery.queryClpp); } //var sort = Builders<VehicleObject>.Sort.Descending("CreateTime"); var cursor = mVehicleObjectCollection.Find(filter).Limit(1).ToList(); if (cursor.Count > 0) { object_id = cursor[cursor.Count - 1].Id; } } catch (Exception ex) { Console.WriteLine(ex); } return(object_id); }
public List <VehicleObject> GetVehicleListGtId(ObjectId id, HVehicleQuery mTargetQuery) { var builder = Builders <VehicleObject> .Filter; var filter = builder.Gt("CreateTime", new BsonDateTime(Convert.ToDateTime(mTargetQuery.timeStart))) & builder.Lt("CreateTime", new BsonDateTime(Convert.ToDateTime(mTargetQuery.timeEnd))); if (!string.IsNullOrEmpty(mTargetQuery.queryClpp)) { filter = filter & builder.Regex("vehicle.Clpp", mTargetQuery.queryClpp); } filter = filter & builder.Gte("_id", id); //var sort = Builders<VehicleObject>.Sort.Ascending("CreateTime"); var cursor = mVehicleObjectCollection.Find(filter).Limit(mTargetQuery.PageSize).ToList(); return(cursor); }
private void SearchFaceMongo() { mCardVehResultList.Clear(); mSortedVehResult.Clear(); mSortedVehResultList.Clear(); HVehicleQuery vehicleQuery = new HVehicleQuery(); vehicleQuery.timeStart = Convert.ToDateTime(dtpStrartTime.EditValue.ToString()).ToString("yyyy-MM-dd HH:mm:ss"); vehicleQuery.timeEnd = Convert.ToDateTime(dtpEndTime.EditValue.ToString()).ToString("yyyy-MM-dd HH:mm:ss"); vehicleQuery.queryClpp = mQueryClpp; LogHelper.WriteLog(typeof(FrmVehSearchByPic), "count start"); //int mTotalVehCount = Convert.ToInt32(VehicleMongoDAL.GetInstance().GetVehicleCount()); int mTotalVehCount = Convert.ToInt32(VehicleMongoDAL.GetInstance().GetVehicleCount(vehicleQuery)); LogHelper.WriteLog(typeof(FrmVehSearchByPic), "count end " + mTotalVehCount); int RecordsPerPage = 1000; int pageCount = mTotalVehCount / RecordsPerPage; if (mTotalVehCount % RecordsPerPage == 0) { pageCount = mTotalVehCount / RecordsPerPage; } else { pageCount = mTotalVehCount / RecordsPerPage + 1; } vehicleQuery.PageSize = RecordsPerPage; LogHelper.WriteLog(typeof(FrmVehSearchByPic), "query start"); //ObjectId fistId = VehicleMongoDAL.GetInstance().GetVehicleFirstId(vehicleQuery); for (int i = 1; i <= pageCount; i++) { LogHelper.WriteLog(typeof(FrmVehSearchByPic), "mongo start" + i); //List<FaceObject> TempFaceObjList = FaceMongoDAL.GetInstance().GetFaceList(i, RecordsPerPage); vehicleQuery.PageNumber = i; //List<VehicleObject> TempFaceObjList = VehicleMongoDAL.GetInstance().GetVehicleListGtId(fistId, vehicleQuery); List <VehicleObject> TempFaceObjList = VehicleMongoDAL.GetInstance().GetVehicleList(vehicleQuery); /* * if (null != TempFaceObjList) * { * if (TempFaceObjList.Count > 0) * { * fistId = TempFaceObjList[TempFaceObjList.Count - 1].Id; * } * }*/ LogHelper.WriteLog(typeof(FrmVehSearchByPic), "mongo end"); double progress = (double)i / (double)pageCount * 100; try { this.Invoke(new DelegateProgress(ShowProgress), Convert.ToInt32(progress)); } catch { } foreach (var faceObj in TempFaceObjList) { if (mVehSearchResult.Veh[nSelectedIndex].Cbdm != faceObj.vehicle.Cbdm) { continue; } VehicleCompareResult faceResult = new VehicleCompareResult(); float score = 0;// (float)VehSimCos.HCARREGSimCos(mSearchFaceBase64, faceObj.vehicle.Cltzxx);//Feature.Compare(mSearchFaceBase64, faceObj.FaceFeature); faceResult.Score = score; faceResult.CreateTime = faceObj.CreateTime.AsDateTime.AddHours(8).ToString("yyyy-MM-dd HH:mm:ss"); faceResult.ImagePath = faceObj.ImagePath; faceResult.Clpp = faceObj.vehicle.Clpp; faceResult.Clwz = faceObj.vehicle.Clwz; faceResult.Cphm = faceObj.vehicle.Hphm; mSortedVehResult.Add(faceResult); if (mSortedVehResult.Count > 100) { mSortedVehResult.Remove(mSortedVehResult.Last()); } } } mSortedVehResultList = mSortedVehResult.ToList(); LogHelper.WriteLog(typeof(FrmVehSearchByPic), "query end"); try { this.Invoke(new DelegateBindHandler(BindDataSource)); } catch { } }