/// /// <summary> /// Check if Truck or Remooc's checking date still valid /// </summary> /// <param name="trkNo">Truck(or Remooc) No</param> /// <param name="voyId">Voyage Id</param> /// <returns></returns> /// private TruckStatus IsTruckValidForVoy(string trkNo, int voyId) { Logger.Info("SaveExcelDetail voyId=" + voyId); try { //Get a Truck by Truck No TRUCK truck = _oraTruckService.GetByTruckNo(trkNo); //Get a Voyage by Voyage Id VOYAGE voyage = _oraVoyageRepository.GetById(voyId); if (truck != null) { if (truck.GCN_DATE.HasValue) { //Check if voyage has ATB time if (voyage.ATB.HasValue) { //Check if Truck's checking date after Actual Time Board if (truck.GCN_DATE >= voyage.ATB) { //There is a truck in database and still valid return(TruckStatus.HaveInfoAndValid); } } //or ETB time else if (voyage.ETB.HasValue) { if (truck.GCN_DATE >= voyage.ETB) { //There is a truck in database and still valid return(TruckStatus.HaveInfoAndValid); } } } } //There is no Truck in database or not valid and need to be checked again return(TruckStatus.NotYetCheck); } catch (Exception e) { Logger.Error("IsTruckValidForVoy Error: ", e); throw e; } }
/// <summary> /// Get truck info by return json to view /// </summary> /// <param name="exceldetailId">excel detail Id</param> /// <returns>string</returns> public ActionResult GetJsonPlateInfo(int exceldetailId) { var exceldetailinfo = _excelDetailService.GetById(exceldetailId); if (exceldetailinfo != null) { if (exceldetailinfo.TruckStatus == TruckStatus.NotYetCheck) { var exceldetailJson = new JsonTruckInfo(); exceldetailJson.Status = TruckStatus.NotYetCheck.ToString(); exceldetailJson.ExcelDetailId = exceldetailId; if (exceldetailinfo.TruckNo != null) { exceldetailJson.PlateNumber = exceldetailinfo.TruckNo; } else { exceldetailJson.PlateNumber = exceldetailinfo.ChassisNo; } ConnectToVR(); exceldetailJson.ImgCaptcha = TempData[Resource_GetTruck.captchaURL].ToString(); return(Json(exceldetailJson, JsonRequestBehavior.AllowGet)); } else { var getTruck = new TRUCK(); if (exceldetailinfo.TruckNo != null) { getTruck = _oraTruckService.GetByTruckNo(exceldetailinfo.TruckNo); } else { getTruck = _oraTruckService.GetByTruckNo(exceldetailinfo.ChassisNo); } return(Json(getTruck, JsonRequestBehavior.AllowGet)); } } return(Json(new { message = "Có lỗi xảy ra", JsonRequestBehavior.AllowGet })); }
/// /// <summary> /// Store truck's info in file excel into database /// </summary> /// <param name="detail">truck's info</param> /// private void InsertTruckAfterChecking(ExcelDetail detail, string truckType) { Logger.Info("InsertTruck truckType=" + truckType); try { TRUCK truck = null; if (!string.IsNullOrEmpty(detail.TruckNo)) { //Find truck in database by Truck No truck = _oraTruckService.GetByTruckNo(detail.TruckNo); } else { //Not a truck or tractor //Find truck by Remooc No truck = _oraTruckService.GetByTruckNo(detail.ChassisNo); } if (truck == null) { //There isn't the truck in database before //Create new truck object List <ExcelDetail> lstExcel = new List <ExcelDetail>(); lstExcel.Add(detail); //get Truck No or Chassis No var TruckNo = !string.IsNullOrEmpty(detail.TruckNo) ? detail.TruckNo : detail.ChassisNo; TRUCK newTruck = new TRUCK { TRK_NO = TruckNo, TRK_TYPE = truckType }; var addedTruck = _oraTruckRepository.Insert(newTruck); } } catch (Exception e) { Logger.Error("InsertTruck Error: ", e); throw e; } }
/// <summary> /// Get data from html result after submit captcha. Saving data /// </summary> /// <param name="htmlResponse">html Response</param> /// <param name="LicensePlate">LicensePlate</param> /// <param name="ExcelDetailId">Excel Detail Id</param> /// <returns></returns> public TRUCK GetValueVR(string htmlResponse, string LicensePlate, int ExcelDetailId) { try { var doc = new HtmlDocument(); var truck = new TRUCK(); doc.LoadHtml(htmlResponse); var error = GetSpanContent("lblErrMsg", doc); if ((!error.Equals("Sai mã xác nhận!")) && (!error.Equals("Không tìm thấy thông tin phương tiện này."))) { var findConfigdata = _configService.GetById(1); if (findConfigdata != null) { var findtruck = _oraTruckService.GetByTruckNo(LicensePlate); var trucktype = GetSpanContent(findConfigdata.TruckType, doc); if (trucktype != null && trucktype.Contains("Ô tô con")) { trucktype = "T"; } else if (trucktype != null && trucktype.Contains("đầu kéo")) { trucktype = "V"; } else if (trucktype != null && trucktype.Contains("sơ mi")) { trucktype = "R"; } if (findtruck != null) { findtruck.TRK_TYPE = trucktype; findtruck.NET_WEI_LIMIT = GetSpanContent(findConfigdata.NetWeight, doc).GetNumberInString(); findtruck.KERB_MASS = GetSpanContent(findConfigdata.MaxSeat.ToString(), doc).GetNumberInString(); findtruck.TRK_AXLE = GetSpanContent(findConfigdata.AxleNo, doc).GetNumberInString(); findtruck.DATE_CHECK = GetSpanContent(findConfigdata.DateCheck, doc).f_CDate(); findtruck.GCN_STAMP = GetSpanContent(findConfigdata.GCNStamp, doc); findtruck.GCN_DATE = GetSpanContent(findConfigdata.GCNDate.ToString(), doc).f_CDate(); findtruck.WEI_LIMIT = GetSpanContent(findConfigdata.WeightLimit, doc).GetNumberInString(); findtruck.CROSS_WEI_LIMIT = GetSpanContent(findConfigdata.GrossWeight, doc).GetNumberInString(); findtruck.TOWED_WEIGHTED = GetSpanContent(findConfigdata.TowedWeight, doc).GetNumberInString(); findtruck.TRK_NO = LicensePlate; if (_oraTruckService.Update(findtruck) != null) { var excelupdate = _excelDetailService.GetById(ExcelDetailId); excelupdate.TruckStatus = TruckStatus.GetInfoAndValid; _excelDetailService.Update(excelupdate); return(findtruck); } else { return(null); } } else { truck.TRK_TYPE = trucktype; truck.NET_WEI_LIMIT = GetSpanContent(findConfigdata.NetWeight, doc).GetNumberInString(); truck.KERB_MASS = GetSpanContent(findConfigdata.MaxSeat.ToString(), doc).GetNumberInString(); truck.TRK_AXLE = GetSpanContent(findConfigdata.AxleNo, doc).GetNumberInString(); truck.DATE_CHECK = GetSpanContent(findConfigdata.DateCheck, doc).f_CDate(); truck.GCN_STAMP = GetSpanContent(findConfigdata.GCNStamp, doc); truck.GCN_DATE = GetSpanContent(findConfigdata.GCNDate.ToString(), doc).f_CDate(); truck.WEI_LIMIT = GetSpanContent(findConfigdata.WeightLimit, doc).GetNumberInString(); truck.CROSS_WEI_LIMIT = GetSpanContent(findConfigdata.GrossWeight, doc).GetNumberInString(); truck.TOWED_WEIGHTED = GetSpanContent(findConfigdata.TowedWeight, doc).GetNumberInString(); truck.TRK_NO = LicensePlate; if (_oraTruckService.Insert(truck) != null) { var excelupdate = _excelDetailService.GetById(ExcelDetailId); excelupdate.TruckStatus = TruckStatus.GetInfoAndValid; _excelDetailService.Update(excelupdate); return(truck); } else { return(null); } } } } TempData[Resource_GetTruck.errorWhenSubmit] = error; return(null); } catch (Exception ex) { Logger.Info(ex.Message); return(null); } }
public TRUCK Update(TRUCK truck) { return(_truckrepo.Update(truck)); }
public TRUCK Insert(TRUCK truck) { return(_truckrepo.Insert(truck)); }