/// <summary> /// Function GetVecheleDetailByVIN to get the vehicle details /// </summary> /// <param name="obj"></param> /// <returns>NA</returns> /// <createdBy></createdBy> /// <createdOn>May-7,2016</createdOn> private VehicleProp GetVecheleDetailByVIN(string VIN, int?vehicleId) { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); VehicleProp result = new VehicleProp(); // create object to call vehicle property try { result = _serviceInstance.GetVecheleDetailByVIN(VIN, vehicleId); } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } return(result); }
/// <summary> /// Function UpdatePortStorageDateOut to update the vehicle details to database /// </summary> /// <param name="obj"></param> /// <returns>NA</returns> /// <createdBy></createdBy> /// <createdOn>May-11,2016</createdOn> public void UpdatePortStorageDateOutBatchProcess(object obj) { try { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); VehicleProp objVehicleProp = new VehicleProp(); foreach (var item in RequestProcessingList) { objVehicleProp.Vin = item.Vin; objVehicleProp.DateOut = item.DateOut; objVehicleProp.VehiclesID = item.VehiclesID; objVehicleProp.UpdatedBy = Application.Current.Properties["LoggedInUserName"].ToString(); string message = _serviceInstance.DateOutBatchProcess(objVehicleProp); if (!string.IsNullOrEmpty(message)) { var data = _serviceInstance.GetPortStorageDateOutProcessignDetails(objVehicleProp.Vin).Select(d => new VehicleModel { Vin = d.Vin, Name = d.Name, DateIn = d.DateIn, DateOut = d.DateOut, MakeModel = d.MakeModel, BayLocation = d.BayLocation, VehicleStatus = message, }); VehicleModel objVehicleModel = new VehicleModel(); objVehicleModel = data.FirstOrDefault(); RequestProcessingList.Add(objVehicleModel); } } } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// This Method to Update Vehical Details Information. /// </summary> /// <param name="VIN"></param> /// <returns></returns> public bool UpdateVehicalSearchDetails(VehicleProp objVehicleProp) { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); VehicleDAL objVehicleDAL = new VehicleDAL(); return(objVehicleDAL.UpdateVehicalSearchDetails(objVehicleProp)); } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Method Cancel to refresh the page details /// </summary> /// <param name="obj"></param> /// <returns>NA</returns> /// <createdBy></createdBy> /// <createdOn>May-11,2016</createdOn> void Cancel(object obj) { try { VehicleProp objVehicleProp = new VehicleProp(); } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } }
/// <summary> /// Function To find the vehicle search details. /// </summary> /// <param name="objVehicleProp"></param> /// <returns>List</returns> /// <createdBy></createdBy> /// <createdOn>May-4,2016</createdOn> public int InsertVehicleDetails(VehicleProp objVehicleProp) { VehicleDAL objVehicleDAL = new VehicleDAL(); CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { //Calling and binding the existing user Role. return(objVehicleDAL.InsertVehicleDetails(objVehicleProp)); } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// This method is used to update Port Storage for processing date out /// </summary> /// <param name="objVehicleProp"></param> /// <returns>Int</returns> /// <createdBy></createdBy> /// <createdOn>May-10,2016</createdOn> public string DateOutBatchProcess(VehicleProp objVehicleProp) { VehicleDAL objVehicleDAL = new VehicleDAL(); CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { //Calling Insert PortStorage Processign Details Method. return(objVehicleDAL.DateOutBatchProcess(objVehicleProp)); } catch (Exception) { throw; } finally { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Function UpdatePortStorageRequestDateForBatchProcess to update the vehicle details /// </summary> /// <param name="obj"></param> /// <returns>NA</returns> /// <createdBy></createdBy> /// <createdOn>May-11,2016</createdOn> public void UpdatePortStorageRequestDateForBatchProcess(object obj) { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { MyReportSource = null; var report = new PrintRequestRPT(); //var report = new VehicleRequestRPT(); VehicleProp objVehicleProp = new VehicleProp(); List <PrintRequestReport> lstRequestProcessingPrintModel = new List <PrintRequestReport>(); if (RequestProcessingList != null) { RequestProcessingListTemp.Clear(); foreach (var item in RequestProcessingList) { objVehicleProp.Vin = item.Vin; objVehicleProp.DateRequested = item.DateRequested; objVehicleProp.VehiclesID = item.VehiclesID; objVehicleProp.DealerPrintDate = item.DealerPrintDate; objVehicleProp.EstimatedPickupDate = item.EstimatedPickupDate; objVehicleProp.UpdatedBy = Application.Current.Properties["LoggedInUserName"].ToString(); string message = _serviceInstance.RequestBatchProcess(objVehicleProp); if (!string.IsNullOrEmpty(message)) { //var data = _serviceInstance.GetPortStorageProcessignDetails(objVehicleProp.Vin).Select(d => new VehicleModel//instead of passing vin we will pass vehicleId var data = _serviceInstance.GetPortStorageProcessignDetails(objVehicleProp.VehiclesID.ToString()).Select(d => new VehicleModel { VehiclesID = d.VehiclesID, Vin = d.Vin, Name = d.Name, DateIn = d.DateIn, DateRequested = d.DateRequested, MakeModel = d.MakeModel, Year = d.Year, Make = d.Make, BayLocation = d.BayLocation, VehicleStatus = message, Color = d.Color, EstimatedPickupDate = d.EstimatedPickupDate, DealerPrintDate = d.DealerPrintDate, AdddressLine1 = d.AdddressLine1, City = d.City, State = d.State, Zip = d.Zip, IsProcessedRequestedOut = message.Equals(RequestedVehicleStatus.Updated) }); VehicleModel objVehicleModel = new VehicleModel(); objVehicleModel = data.FirstOrDefault(); RequestProcessingListTemp.Add(objVehicleModel); if ((bool)objVehicleModel.IsProcessedRequestedOut) { lstRequestProcessingPrintModel.Add(new PrintRequestReport() { Vin = objVehicleModel.Vin, ShortVIN = objVehicleModel.Vin != "" && objVehicleModel.Vin != null ? "*" + objVehicleModel.Vin.Substring(objVehicleModel.Vin.Length - Math.Min(8, objVehicleModel.Vin.Length)) + "*" : "", BayLocation = objVehicleModel.BayLocation, DateRequested = objVehicleModel.DateRequested, Color = objVehicleModel.Color, PickeupDate = objVehicleModel.EstimatedPickupDate, MakeModel = objVehicleModel.Year + " " + objVehicleModel.Make + " " + objVehicleModel.MakeModel, DealerPrintDate = objVehicleModel.DealerPrintDate, CompanyName = CompanyName, CompanyAddressLine1 = CompanyAddressLine1, CompanyCity = CompanyCity, Phone = Phone, AdddressLine1 = objVehicleModel.AdddressLine1, Name = objVehicleModel.Name, FullAddress = (!string.IsNullOrEmpty(objVehicleModel.City) ? objVehicleModel.City + ", " : "") + objVehicleModel.State + " " + objVehicleModel.Zip, DayName = objVehicleModel.DateRequested != null ? objVehicleModel.DateRequested.Value.DayOfWeek.ToString() : "", ReturnToInventory = objVehicleModel.DateRequested != null ? objVehicleModel.DateRequested.Value.AddDays(5) : objVehicleModel.DateRequested, DayNamePickUp = objVehicleModel.EstimatedPickupDate != null ? objVehicleModel.EstimatedPickupDate.Value.DayOfWeek.ToString() : "" }); } } } RequestProcessingList = new ObservableCollection <VehicleModel>(RequestProcessingListTemp); } var dk = lstRequestProcessingPrintModel.ToList(); report.DataSource = dk; MyReportSource = report; } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Function UpdatePortStorageProcessignDetails to update the vehicle details with bind the grid /// </summary> /// <param name="obj"></param> /// <returns>NA</returns> /// <createdBy></createdBy> /// <createdOn>May-11,2016</createdOn> public void UpdateAndGetPortStorageProcessignDetails(object obj) { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { if (!string.IsNullOrEmpty(Vin)) { VehicleProp objVehicleProp = new VehicleProp(); objVehicleProp.Vin = Vin; var item = RequestProcessingListTemp.Find(it => it.Vin.Contains(Vin)); int?vehicleId = item != null ? item.VehiclesID : (int?)null; if (item != null) { MessageBox.Show(Resources.msgVehicleListAlready, Resources.msgTitleMessageBoxVehicleList); ClearFiled(); return; } else { List <VehicleProp> lstvechileProp = new List <VehicleProp>(); lstvechileProp = CheckMultipleVecheleDetailByVIN(objVehicleProp.Vin); if (lstvechileProp.Count == 0) { MessageBox.Show(Resources.msgProcessingVINFound, Resources.msgTitleMessageBoxVehicleNotFound); return; } var pendingVehicles = lstvechileProp.Where(x => x.DateOut == null).ToList(); if (pendingVehicles.Count > 1) { MessageBox.Show(Resources.msgMultipleVINProcessing, Resources.msgTitleMessageBoxMultipleVIN); return; } else if (pendingVehicles.Count == 0) { VehicleProp vechileProp = GetVecheleDetailByVIN(objVehicleProp.Vin, vehicleId); if (vechileProp != null) { MessageBox.Show(Resources.msgDateoutProcess + vechileProp.Name + " IN: " + vechileProp.DateIn + " REQ: " + vechileProp.DateRequested + " OUT:" + vechileProp.DateOut + "", Resources.msgTitleMessageBoxVehicleNotFound); ClearFiled(); return; } } else { objVehicleProp.UpdatedBy = Application.Current.Properties["LoggedInUserName"].ToString(); objVehicleProp.UpdatedDate = DateTime.Now; objVehicleProp.DateRequested = dtRequestDate; objVehicleProp.Note = note; var vehicle = pendingVehicles.FirstOrDefault(); if (vehicle != null) { objVehicleProp.VehiclesID = vehicle.VehiclesID; } if (IsReturnedToInventory) { objVehicleProp.EstimatedPickupDate = objVehicleProp.DealerPrintDate = null; objVehicleProp.RequestedBy = null; } int value = _serviceInstance.UpdatePortStorageProcessignDetails(objVehicleProp); if (value > 0) { var data = _serviceInstance.GetPortStorageProcessignDetails(objVehicleProp.VehiclesID.ToString()).Select(d => new VehicleModel { Vin = d.Vin, Name = d.Name, DateIn = d.DateIn, DateRequested = objVehicleProp.DateRequested, MakeModel = d.MakeModel, BayLocation = d.BayLocation, VehicleStatus = d.VehicleStatus, VehiclesID = d.VehiclesID }); VehicleModel objVehicleModel = new VehicleModel(); objVehicleModel = data.FirstOrDefault(x => x.VehiclesID == objVehicleProp.VehiclesID); RequestProcessingListTemp.Add(objVehicleModel); RequestProcessingList = new ObservableCollection <VehicleModel>(RequestProcessingListTemp); } } } } else { MessageBox.Show(Resources.msgVINReq, Resources.msgTitleMessageBox); } Count = RequestProcessingList.Count; ClearFiled(); } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Function UpdatePortStorageDateOutProcessignDetails to get the vehicle details /// </summary> /// <param name="obj"></param> /// <returns>NA</returns> /// <createdBy></createdBy> /// <createdOn>May-11,2016</createdOn> public void UpdateAndGetPortStorageDateOutProcessignDetails(object obj) { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { if (string.IsNullOrEmpty(Vin)) { MessageBox.Show(Resources.msgVINReq, Resources.msgTitleMessageBox); return; } // Cannot allow multiples. if (RequestProcessingList.Any(it => it.Vin.Contains(Vin))) { MessageBox.Show(Resources.msgVehicleListAlready, Resources.msgTitleMessageBoxVehicleList); ClearFiled(); return; } // If there are no vehicles matching VIN, alert, and end. List <VehicleProp> vehiclesMatchingVIN = CheckMultipleVecheleDetailByVIN(Vin.ToUpper()); if (vehiclesMatchingVIN.Any() == false) { MessageBox.Show(Resources.msgProcessingVINFound, Resources.msgTitleMessageBoxVehicleNotFound); return; } // Create LINQ statement grabbing first two vehicles matching VIN that do not have date out. string shortVin = Vin.Substring(0, 8); IEnumerable <VehicleProp> firstTwoVehiclesWithoutDateOut = vehiclesMatchingVIN.Where(x => x.DateOut == null).Take(2); // If there are no vehicles that have no date out, alert with information on vehicle that does, and end. if (firstTwoVehiclesWithoutDateOut.Any() == false) { VehicleProp vehicleFound = GetVecheleDetailByVIN(shortVin); MessageBox.Show($"{Resources.msgDateoutProcess + vehicleFound.Name} IN: {vehicleFound.DateIn} REQ: {vehicleFound.DateRequested} OUT: {vehicleFound.DateOut}", "Vehicle Not Found"); ClearFiled(); return; } // If there are multiple vehicles matching VIN with no date out, alert, and end. if (firstTwoVehiclesWithoutDateOut.Count() == 2) { MessageBox.Show(Resources.msgMultipleVINProcessing, Resources.msgTitleMessageBoxMultipleVIN); return; } // Update vehicle details to make date out now. var updateVehicle = new VehicleProp { VehiclesID = firstTwoVehiclesWithoutDateOut.First().VehiclesID, Vin = Vin.Substring(0, 8), DateOut = DtDateOut, Note = Note, }; int value = _serviceInstance.UpdatePortStorageDateOutProcessignDetails(updateVehicle); // If update was successful, add vehicle to list for display on grid. if (value > 0) { VehicleProp foundVehicle = _serviceInstance.GetPortStorageDateOutProcessignDetails(shortVin).First(); VehicleModel vehicleModel = new VehicleModel { Vin = foundVehicle.Vin, Name = foundVehicle.Name, DateIn = foundVehicle.DateIn, DateOut = DtDateOut, MakeModel = foundVehicle.MakeModel, VehiclesID = foundVehicle.VehiclesID, BayLocation = foundVehicle.BayLocation, VehicleStatus = foundVehicle.VehicleStatus, }; RequestProcessingList.Add(vehicleModel); } ClearFiled(); Scrolled = "NOTSCROLLED"; } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }