/// <summary> /// This Method is for inserting information in the decodevin table /// </summary> /// <param name="VIN"></param> /// <returns></returns> public bool InsertDecodeVIN(VINDecodeList objVINDecode) { 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.InsertDecodeVIN(objVINDecode)); } 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 get data using Decode Vin functionality /// </summary> /// <param name="Vin"></param> /// <returns></returns> private VINDecodeList GetDataByDecodeVIN(string Vin) { VINDecodeList lstVINDecodeList = new VINDecodeList(); VehicleDAL vehicleDAL = new VehicleDAL(); try { var lstPsVehicle = vehicleDAL.GetDecodedPortStorageVIN(Vin); if (lstPsVehicle != null) { lstVINDecodeList.VehicleYear = lstPsVehicle.VehicleYear; lstVINDecodeList.Make = lstPsVehicle.Make; lstVINDecodeList.Model = lstPsVehicle.Model; lstVINDecodeList.Bodystyle = lstPsVehicle.Bodystyle; lstVINDecodeList.VehicleLength = lstPsVehicle.VehicleLength; lstVINDecodeList.VehicleWidth = lstPsVehicle.VehicleWidth; lstVINDecodeList.VehicleHeight = lstPsVehicle.VehicleHeight; //lstVINDecodeList.VINDecodeID = (int)lstPsVehicle.VINDecodedInd; } else { var lstDecodeVin = vehicleDAL.GetDecodedVINForVINDecode(Vin); if (lstDecodeVin != null) { lstVINDecodeList.VehicleYear = lstDecodeVin.VehicleYear; lstVINDecodeList.Make = lstDecodeVin.Make; lstVINDecodeList.Model = lstDecodeVin.Model; lstVINDecodeList.Bodystyle = lstDecodeVin.Bodystyle; lstVINDecodeList.VehicleLength = lstDecodeVin.VehicleLength; lstVINDecodeList.VehicleWidth = lstDecodeVin.VehicleWidth; lstVINDecodeList.VehicleHeight = lstDecodeVin.VehicleHeight; //lstVINDecodeList.VINDecodeID = (int)lstDecodeVin.VINDecodeID; } else { string Bodystyle = null; var lstVINDataWeb = vehicleDAL.GetDecodeDataFromWeb(Vin, Bodystyle); if (lstVINDataWeb != null) { if (lstVINDataWeb.DecodeError.Length == 0) { lstVINDecodeList.VehicleYear = lstVINDataWeb.VehicleYear; lstVINDecodeList.Make = lstVINDataWeb.Make; lstVINDecodeList.Model = lstVINDataWeb.Model; lstVINDecodeList.Bodystyle = lstVINDataWeb.Bodystyle; lstVINDecodeList.VehicleLength = lstVINDataWeb.VehicleLength; lstVINDecodeList.VehicleWidth = lstVINDataWeb.VehicleWidth; lstVINDecodeList.VehicleHeight = lstVINDataWeb.VehicleHeight; //lstVINDecodeList.VINDecodeID = (int)lstVINDataWeb.VINDecodeID; } else { lstVINDecodeList = null; } } } } } 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)); } return(lstVINDecodeList); }
/// <summary> /// This method is used to get data and insert data in database for vehicle /// </summary> /// <param name="BatchId"></param> /// <param name="User"></param> /// <returns></returns> public bool VehicleImportTransactionProcess(int batchId, string user) { bool isSucceeded = false; var query = string.Empty; try { List <VehicleLocationImportTransactionProp> vehicleLocationImportTransactionProp = new List <VehicleLocationImportTransactionProp>(); using (PortStorageEntities objAppWorksEntities = new PortStorageEntities()) { VINDecodeList lstVINDecodeList = new VINDecodeList(); //If jst(lSessionHost,'U')='DAIDB' // Sta: exec DataHub.dbo.DAIYMSP_GetStorageReceiptData // Else If jst(lSessionHost,'U')='DAIDBVPC' // Sta: exec DataHUBVPC.dbo.DAIYMSP_GetStorageReceiptData // Else // Sta: exec DataHubDev.dbo.DAIYMSP_GetStorageReceiptData // End If // Get current database name string currentDatabaseName = objAppWorksEntities.Database.Connection.Database; //if (currentDatabaseName.Equals("psdb", StringComparison.OrdinalIgnoreCase)) //{ query = SqlConstants.VEHICLE_LOCATION_IMPORT_TRANSACTION; //} var result = objAppWorksEntities.Database.SqlQuery <VehicleLocationImportTransactionProp>(query).ToList(); if (result != null && result.Count > 0) { PortStorageVehiclesImport portStorageVehiclesImport = new PortStorageVehiclesImport(); foreach (var item in result) { VehicleLocationImportTransactionProp obj = new VehicleLocationImportTransactionProp(); obj.VinNumberAndVinKey = item.VinNumberAndVinKey; obj.Row = item.Row; obj.Bay = item.Bay; obj.DealerCode = item.DealerCode; obj.ColorCode = item.ColorCode; obj.DamageCode = item.DamageCode; obj.HandheldActionDate = item.HandheldActionDate; obj.UserCode = item.UserCode; vehicleLocationImportTransactionProp.Add(obj); obj = null; } if (vehicleLocationImportTransactionProp.Count > 0) { foreach (var val in vehicleLocationImportTransactionProp) { if (val.VinNumberAndVinKey.Length > 17)// check validation { if ((val.VinNumberAndVinKey.Length == 18) && (val.VinNumberAndVinKey.Substring(0, 1).Equals("I"))) { val.VinNumberAndVinKey = val.VinNumberAndVinKey.Remove(0, 1); } else { val.VinNumberAndVinKey = val.VinNumberAndVinKey.Substring(0, 17); } } lstVINDecodeList = GetDataByDecodeVIN(val.VinNumberAndVinKey); if (lstVINDecodeList != null) { portStorageVehiclesImport.VehicleYear = lstVINDecodeList.VehicleYear; portStorageVehiclesImport.Make = lstVINDecodeList.Make; portStorageVehiclesImport.Model = lstVINDecodeList.Model; portStorageVehiclesImport.Bodystyle = lstVINDecodeList.Bodystyle; portStorageVehiclesImport.VehicleLength = lstVINDecodeList.VehicleLength; portStorageVehiclesImport.VehicleWidth = lstVINDecodeList.VehicleWidth; portStorageVehiclesImport.VehicleHeight = lstVINDecodeList.VehicleHeight; } else { portStorageVehiclesImport.VehicleYear = string.Empty; portStorageVehiclesImport.Make = string.Empty; portStorageVehiclesImport.Model = string.Empty; portStorageVehiclesImport.Bodystyle = string.Empty; portStorageVehiclesImport.VehicleLength = string.Empty; portStorageVehiclesImport.VehicleWidth = string.Empty; portStorageVehiclesImport.VehicleHeight = string.Empty; } portStorageVehiclesImport.VINDecodedInd = 0; portStorageVehiclesImport.BatchID = batchId; portStorageVehiclesImport.DateIn = val.HandheldActionDate.Value.ToString("MM/dd/yyyy"); portStorageVehiclesImport.DealerCode = val.DealerCode; portStorageVehiclesImport.VIN = val.VinNumberAndVinKey; portStorageVehiclesImport.Color = val.ColorCode; //portStorageVehiclesImport.DamageCodeList = val.DealerCode; portStorageVehiclesImport.DamageCodeList = val.DamageCode; portStorageVehiclesImport.Location = (val.Row + " " + val.Bay).Trim(); portStorageVehiclesImport.ImportedInd = 0; portStorageVehiclesImport.CreationDate = DateTime.Now; portStorageVehiclesImport.CreatedBy = user; portStorageVehiclesImport.RecordStatus = "Import Pending"; objAppWorksEntities.PortStorageVehiclesImports.Add(portStorageVehiclesImport); /// Insert the Record in Respected Table. objAppWorksEntities.SaveChanges(); isSucceeded = true; } } } else { isSucceeded = true; } } } catch (Exception ex) { var message = ex.Message; 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)); } return(isSucceeded); }