public async Task <IActionResult> Update([FromBody] PlateViewModel model) { var plate = await _plateService.FindByIdAsync(model.Id); if (plate == null) { return(Ok(new { error = "پلاکی یافت نشد." })); } if (ModelState.IsValid) { plate.Description = model.Description; plate.FullName = model.FullName; // plate.IsActive = model.IsActive; // plate.IsTechnicalDiagnosis = model.IsTechnicalDiagnosis; plate.Mobile = model.Mobile; plate.PlateAlphabet = model.PlateAlphabet; plate.PlateFirstNumber = model.PlateFirstNumber; plate.PlateLastNumber = model.PlateLastNumber; plate.PlateState = model.PlateState; plate.ServiceDate = model.ServiceDate.ToGregorianDateTime() ?? DateTime.Now; await _uow.SaveChangesAsync(); return(Ok()); } return(Ok(new { error = ModelState.AllMessage() })); }
public async Task <IActionResult> Add([FromBody] PlateViewModel model) { if (ModelState.IsValid) { var result = await _plateService.InsertAsync(new Plate { FullName = model.FullName, Mobile = model.Mobile, PlateAlphabet = model.PlateAlphabet, PlateFirstNumber = model.PlateFirstNumber, PlateLastNumber = model.PlateLastNumber, Description = model.Description, // IsTechnicalDiagnosis = model.IsTechnicalDiagnosis, IsActive = true, PlateState = model.PlateState, ServiceDate = model.ServiceDate.ToGregorianDateTime() ?? DateTime.Now, TypeVehicleId = model.typeVehicleId }); if (result) { await _uow.SaveChangesAsync(); return(Ok()); } else { return(Ok(new { error = "متاسفانه مشکلی در ثبت اطلاعات به وجود آمده است." })); } } return(Ok(new { error = ModelState.AllMessage() })); }
public List <string> DetectLicensePlate(PlateViewModel plateViewModel) { List <string> licenses; int mode = 0; do { _plateViewModel = plateViewModel; _plateViewModel.filteredCharatersInSinglePlate = new List <List <UMat> >(); _plateViewModel.FilteredDetectedCharacters = new ObservableCollection <ImageSource>(); _plateViewModel.DetectedPlates = new ObservableCollection <ImageSource>(); licenses = new List <string>(); using (Mat gray = new Mat()) using (Mat canny = new Mat()) using (VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint()) { CvInvoke.CvtColor(plateViewModel.Mat, gray, ColorConversion.Bgr2Gray); Image <Bgr, Byte> grayCVcontrasted = PreTreatment(gray, mode); CvInvoke.Canny(grayCVcontrasted, canny, 250, 100, 3, false); plateViewModel.MonoImage = grayCVcontrasted.Bitmap.ToBitmapImage(); plateViewModel.CannyImage = canny.Bitmap.ToBitmapImage(); int[,] hierachy = CvInvoke.FindContourTree(canny, contours, ChainApproxMethod.ChainApproxSimple); FindLicensePlateAndCharacters(contours, hierachy, 0, gray, canny, licenses); } mode++; } while (_plateViewModel.FilteredDetectedCharacters.Count <= 5 && mode <= 3); return(licenses); }
public HeatExchangeViewModel() { RecupList = HeatExchange.GetTypes(); RotorVM = new RotorViewModel(); PlateVM = new PlateViewModel(); PlateBypassVM = new PlateWithBypassViewModel(); GlycolVM = new GlycolViewModel(); PageViewHeatExchangeModels.Add(new EmptyVM()); PageViewHeatExchangeModels.Add(RotorVM); PageViewHeatExchangeModels.Add(PlateVM); PageViewHeatExchangeModels.Add(PlateBypassVM); PageViewHeatExchangeModels.Add(GlycolVM); CurrentRecupViewPage = PageViewHeatExchangeModels[0]; SelectedValueHeaterExchange = RecupList[0]; IsPressureSensor = false; IsTempSensor = false; }
public void RecognizePlate() { PlateViewModel plateViewModel = new PlateViewModel { MainViewModel = _model, Mat = _mat }; plateViewModel.MainViewModel.LogTextBox = String.Empty; DataContext = plateViewModel; ProcessingPlate processingPlate = new ProcessingPlate(); processingPlate.DetectLicensePlate(plateViewModel); InitializeRecognition initializeRecognition = new InitializeRecognition(plateViewModel.MainViewModel, _initializeNeutralNetwork, _globalSettings); IsRecognise = initializeRecognition.Recognize(plateViewModel.filteredCharatersInSinglePlate); }
/// <summary> /// Get Truck Information /// </summary> /// <param name="excelId">excel detail Id</param> /// <returns>View</returns> public ActionResult GetInfoRegis(int excelId, int?excelDetailId) { try { var model = new GetRegisInfoViewModel(); int truckOnProcessingId = 0; if (TempData[Resource_GetTruck.truckinfo] != null) { var truckinfo = (TRUCK)TempData[Resource_GetTruck.truckinfo]; if (truckinfo.ID != 0) { model.Truck = truckinfo; } } var lstExcelDetail = _excelDetailService.GetListByFileExcelId(excelId).ToList(); if (lstExcelDetail.Any()) { var chuathaotac = new ExcelDetail(); if (excelDetailId == null) { chuathaotac = lstExcelDetail.Where(x => x.TruckStatus == TruckStatus.NotYetCheck).FirstOrDefault(); } else { chuathaotac = lstExcelDetail.Where(x => x.Id == excelDetailId).FirstOrDefault(); } if (chuathaotac != null) { ConnectToVR(); model.OnProcessing = true; model.ExcelDetailId = chuathaotac.Id; model.FileExcelId = chuathaotac.FileExcelId; if (chuathaotac.TruckNo != null) { model.LicensePlate = chuathaotac.TruckNo; } else { model.LicensePlate = chuathaotac.ChassisNo; } truckOnProcessingId = chuathaotac.Id; model.CaptchaURL = TempData[Resource_GetTruck.captchaURL].ToString(); model.HaveNotCheckYet = true; } else { var randomtruck = lstExcelDetail.FirstOrDefault(); truckOnProcessingId = randomtruck.Id; if (randomtruck.TruckNo != null) { model.Truck = _oraTruckService.GetByTruckNo(randomtruck.TruckNo); } else { model.Truck = _oraTruckService.GetByTruckNo(randomtruck.ChassisNo); } model.LicensePlate = randomtruck.TruckNo; //model.Status = TruckStatus.OnProcessing; model.OnProcessing = true; model.HaveNotCheckYet = false; } lstExcelDetail.ForEach(x => { var newPlate = new PlateViewModel { PlateStatus = x.TruckStatus, ExcelDetailId = x.Id, }; if (x.Id == truckOnProcessingId) { newPlate.OnProcessing = true; } if (x.TruckNo != null) { newPlate.PlateNo = x.TruckNo; } else { newPlate.PlateNo = x.ChassisNo; } model.PlateLst.Add(newPlate); }); var getFileExceldata = _fileExcelService.GetById(lstExcelDetail.FirstOrDefault().FileExcelId); model.Customer = _customerService.GetById(getFileExceldata.CustomerId.Value).NAME; //model.Customer = "Green Feed"; //for testing model.VesselName = _oraVoyageService.GetByVoyCode(getFileExceldata.VoyCode).NAME; //model.VesselName = "Thong Nhat 1"; //for testing if (TempData[Resource_GetTruck.errorWhenSubmit] != null) { TempData[Resource_GetTruck.message] = TempData[Resource_GetTruck.errorWhenSubmit].ToString(); } } return(View(model)); } catch (Exception ex) { Logger.Info("GetInfoRegis:", ex); return(View()); //for testing } }