/// <summary> /// To get the vehicle inventory details coressponding to vin number and customer id. /// </summary> /// <param name="vinNUmber"></param> /// <param name="customerID"></param> /// <param name="?"></param> /// <returns></returns> public List <PortStorageVehicleProp> GetPortStorageInventoryDetails(PortStorageVehicleProp objPortStorageProp) { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); return(objWebPortalDAL.GetPortStorageInventoryDetails(objPortStorageProp)); } 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 to update request checked vehicles /// </summary> /// <param name="locationID"></param> /// <returns></returns> public bool UpdateVehiclesStatus(PortStorageVehicleProp portStorageVehicle, string userName) { using (var transaction = new TransactionScope()) { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); bool result = false; using (PortStorageEntities portalEntities = new PortStorageEntities()) { var portStorageVehicleData = portalEntities.PortStorageVehicles.Where(x => x.PortStorageVehiclesID == portStorageVehicle.PortStorageVehiclesID).FirstOrDefault(); if (portStorageVehicleData != null) { portStorageVehicleData.VehicleStatus = "Requested"; portStorageVehicleData.DateRequested = DateTime.Now; portStorageVehicleData.RequestedBy = userName; portalEntities.SaveChanges(); } result = true; transaction.Complete(); return(result); } } 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> /// To get the vehicle inventory details coressponding to vin number and customer id. /// </summary> /// <param name="vinNUmber"></param> /// <param name="customerID"></param> /// <param name="?"></param> /// <returns></returns> public List <PortStorageVehicleProp> GetPortStorageInventoryDetails(PortStorageVehicleProp objPortStorageProp) { try { CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); using (PortStorageEntities portalEntities = new PortStorageEntities()) { var lstInventory = (from portstoragevehicles in portalEntities.PortStorageVehicles where portstoragevehicles.CustomerID == objPortStorageProp.CustomerID orderby portstoragevehicles.VIN select new PortStorageVehicleProp { PortStorageVehiclesID = portstoragevehicles.PortStorageVehiclesID, CustomerID = portstoragevehicles.CustomerID, VIN = portstoragevehicles.VIN, VehicleYear = portstoragevehicles.VehicleYear, Make = portstoragevehicles.Make, Model = portstoragevehicles.Model, Color = portstoragevehicles.Color, BayLocation = portstoragevehicles.BayLocation, DateIn = portstoragevehicles.DateIn, DateRequested = portstoragevehicles.DateRequested, VehicleStatus = portstoragevehicles.VehicleStatus, RequestedBy = portstoragevehicles.RequestedBy, DateOut = portstoragevehicles.DateOut, IsSelected = false, Days = 0 }).AsQueryable(); if (!string.IsNullOrEmpty(objPortStorageProp.VIN)) { lstInventory = lstInventory.Where(x => x.VIN.Contains(objPortStorageProp.VIN)); } var pageCount = lstInventory.ToList().Count; if (objPortStorageProp.CurrentPageIndex == 0 && objPortStorageProp.PageSize > 0) { var queryResult = lstInventory.ToList().Skip(objPortStorageProp.CurrentPageIndex * objPortStorageProp.PageSize).Take(objPortStorageProp.PageSize).ToList(); //var queryResult = query.ToList().Skip(objFindUserProp.CurrentPageIndex * objFindUserProp.PageSize).Take(objFindUserProp.PageSize).ToList(); if (queryResult != null && queryResult.Count > 0) { queryResult.FirstOrDefault().TotalPageCount = pageCount; } return(queryResult); } else if (objPortStorageProp.PageSize > 0) { var queryResult = lstInventory.ToList().Skip((objPortStorageProp.CurrentPageIndex * objPortStorageProp.PageSize) + (objPortStorageProp.DefaultPageSize - objPortStorageProp.PageSize)).Take(objPortStorageProp.PageSize).ToList(); //var queryResult = query.ToList().Skip(objFindUserProp.CurrentPageIndex * objFindUserProp.PageSize).Take(objFindUserProp.PageSize).ToList(); if (queryResult != null && queryResult.Count > 0) { queryResult.FirstOrDefault().TotalPageCount = pageCount; } return(queryResult); } else { return(lstInventory.ToList()); } } } 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 CreateCSVFile to return the exported csv file /// </summary> /// <param name="Na"></param> /// <param name="Na"></param> /// <returns>csv file</returns> public void CreateCSVFile() { try { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); PortStorageVehicleProp objVehicleProp = new PortStorageVehicleProp(); objVehicleProp.CustomerID = CustomerID; objVehicleProp.VIN = VINNumber; objVehicleProp.CurrentPageIndex = 0; objVehicleProp.PageSize = 0; objVehicleProp.DefaultPageSize = 0; var lstInventory = _serviceInstance.GetPortStorageInventoryDetails(objVehicleProp).Select(x => new PortStorageVehicleProp { VIN = x.VIN, VehicleYear = x.VehicleYear, Make = x.Make, Model = x.Model, Color = x.Color, BayLocation = x.BayLocation, DateIn = x.DateIn, DateRequested = x.DateRequested, VehicleStatus = x.VehicleStatus, RequestedBy = x.RequestedBy, DateOut = x.DateOut, PortStorageVehiclesID = x.PortStorageVehiclesID, IsSelected = x.IsSelected, Days = x.DateOut.Value != null ? (int)x.DateOut.Value.Subtract((DateTime)x.DateIn).TotalDays : (int)DateTime.Now.Subtract((DateTime)x.DateIn).TotalDays }); ListExport = new ObservableCollection <PortStorageVehicleProp>(lstInventory); if (ListExport != null) { if (ListExport.Count > 0) { string[] ExportValue = new string[] { "VIN", "Year", "Make", "Model", "Color", "Location", "Arrived", "Days", "Requested", "Status", "Requested By", "Date Out" }; if (!Directory.Exists(ConfigurationManager.AppSettings["CSVFilePath"].ToString())) { Directory.CreateDirectory(ConfigurationManager.AppSettings["CSVFilePath"].ToString()); } StreamWriter sw = new StreamWriter(ConfigurationManager.AppSettings["CSVFilePath"].ToString() + "VehicleInventory.csv", false); foreach (string objVal in ExportValue) { sw.Write(objVal); sw.Write(","); } sw.Write(sw.NewLine); // Row creation foreach (PortStorageVehicleProp prop in ListExport) { if (prop.VIN != null) { sw.Write(prop.VIN); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.VehicleYear != null) { sw.Write(prop.VehicleYear); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.Make != null) { sw.Write(prop.Make); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.Model != null) { sw.Write(prop.Model); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.Color != null) { sw.Write(prop.Color); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.BayLocation != null) { sw.Write(prop.BayLocation); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.DateIn != null) { sw.Write(prop.DateIn.Value.Date.ToString("MM/dd/yyy")); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.Days > 0) { sw.Write(prop.Days); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.DateRequested != null) { sw.Write(prop.DateRequested.Value.Date.ToString("MM/dd/yyy")); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.VehicleStatus != null) { sw.Write(prop.VehicleStatus); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.RequestedBy != null) { sw.Write(prop.RequestedBy); sw.Write(","); } else { sw.Write(""); sw.Write(","); } if (prop.DateOut != null) { sw.Write(prop.DateOut.Value.Date.ToString("MM/dd/yyy")); sw.Write(","); } else { sw.Write(""); sw.Write(","); } // Do something with propValue sw.Write(sw.NewLine); } sw.Close(); System.Diagnostics.Process.Start(System.Configuration.ConfigurationManager.AppSettings["CSVFilePath"].ToString() + "PortStorageVehicles.csv"); } } } catch (Exception ex) { CommonSettings.logger.LogError(this.GetType(), ex); } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// Function to get inventory details for a vin number/customerid /// </summary> /// <param name="obj"></param> /// <returns>NA</returns> /// <createdBy></createdBy> /// <createdOn>June-28,2016</createdOn> public void Search_Click(object obj) { try { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); Count = 0; if (CustomerID > 0) { if (obj == null) { CurrentPageIndex = 0; } if (CurrentPageIndex == 0) { Application.Current.Properties["FindUserGridLastScrollOffset"] = 0; Application.Current.Properties["FindUserGridCurrentPageIndex"] = 0; } PortStorageVehicleProp objVehicleProp = new PortStorageVehicleProp(); objVehicleProp.CustomerID = CustomerID; objVehicleProp.VIN = VINNumber; objVehicleProp.CurrentPageIndex = CurrentPageIndex; objVehicleProp.PageSize = CurrentPageIndex > 0 ? _GridPageSizeOnScroll : _GridPageSize;; objVehicleProp.DefaultPageSize = _GridPageSize; var lstInventory = _serviceInstance.GetPortStorageInventoryDetails(objVehicleProp).Select(x => new PortStorageVehicleProp { VIN = x.VIN != null ? x.VIN : string.Empty, VehicleYear = x.VehicleYear != null ? x.VehicleYear : string.Empty, Make = x.Make != null ? x.Make : string.Empty, Model = x.Model != null ? x.Model : string.Empty, Color = x.Color != null ? x.Color : string.Empty, BayLocation = x.BayLocation != null ? x.BayLocation : string.Empty, DateIn = x.DateIn, DateRequested = x.DateRequested, VehicleStatus = x.VehicleStatus != null ? x.VehicleStatus : string.Empty, RequestedBy = x.RequestedBy != null ? x.RequestedBy : string.Empty, DateOut = x.DateOut, PortStorageVehiclesID = x.PortStorageVehiclesID, IsSelected = x.IsSelected, Days = x.DateOut != null ? Convert.ToInt32(Convert.ToDateTime(x.DateOut).Subtract((DateTime)x.DateIn).TotalDays) : (x.DateIn != null ? Convert.ToInt32(DateTime.Now.Subtract((DateTime)x.DateIn).TotalDays) : 0), //(int)x.DateOut.Value.Subtract((DateTime)x.DateIn).TotalDays : 0//(Convert.ToDateTime(x.DateIn) != null ? (int)DateTime.Now.Subtract((DateTime)x.DateIn).TotalDays : 0) TotalPageCount = x.TotalPageCount }); foreach (var item in lstInventory) { IsSelected = item.IsSelected; } if (CurrentPageIndex == 0) { ListInventory = null; ListInventory = new ObservableCollection <PortStorageVehicleProp>(lstInventory); } else { if (ListInventory != null && ListInventory.Count > 0) { foreach (PortStorageVehicleProp ud in new ObservableCollection <PortStorageVehicleProp>(lstInventory)) { ListInventory.Add(ud); } } } VehicleSummary = "Vehicles currently in storage: " + ListInventory.Where(x => x.VehicleStatus != Enums.VehicleStatusType.OutGated.ToString()).Count().ToString() + "(Requested: " + ListInventory.Where(x => x.VehicleStatus == Enums.VehicleStatusType.Requested.ToString()).Count().ToString() + ")"; } else { MessageBox.Show(Resources.MsgSelectUser); } Count = ListInventory.ToList().Where(x => x.TotalPageCount > 0).FirstOrDefault().TotalPageCount; } catch (Exception ex) { CommonSettings.logger.LogError(this.GetType(), ex); } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }