Beispiel #1
0
        public static CarInfoFormViewModel GetVehicleInfoFromChromeDecodeForEdit(VehicleDescription vehicleInfo)
        {
            var car = new CarInfoFormViewModel
            {
                Make              = vehicleInfo.bestMakeName,
                Trim              = vehicleInfo.bestTrimName,
                ModelYear         = vehicleInfo.modelYear,
                MechanicalList    = new List <String>(),
                ExteriorList      = new List <String>(),
                EntertainmentList = new List <String>(),
                InteriorList      = new List <String>(),
                SafetyList        = new List <String>(),
            };

            if (vehicleInfo.style != null && vehicleInfo.style.Any())
            {
                car.MSRP = vehicleInfo.style.First().basePrice.msrp.ToString("C");
                if (vehicleInfo.style.First().stockImage != null)
                {
                    car.DefaultImageUrl = vehicleInfo.style.First().stockImage.url;
                }
            }

            var chromeAutoService       = new ChromeAutoService();
            var listPackageOptions      = chromeAutoService.GetPackageOptions(vehicleInfo);
            var listNonInstalledOptions = chromeAutoService.GetNonInstalledOptions(vehicleInfo);

            car.FactoryPackageOptions      = listPackageOptions;
            car.FactoryNonInstalledOptions = listNonInstalledOptions;

            return(car);
        }
Beispiel #2
0
        public VehicleUIControl(VehicleDescription desc)
        {
            Descriptor = desc;
            QfsFile qfs = new QfsFile(@"Frontend\Art\Control\" + desc.UIImageFile);

            Bitmap = qfs.Content.Header.Bitmaps.Find(a => a.Id == "0000");
        }
Beispiel #3
0
        public bool AutoDrift;          //used for ai racers

        public DrivableVehicle(VehicleDescription desc)
            : base(desc.ModelFile)
        {
            Descriptor = desc;
            float offset = VehicleWheel.Width / 2 - 0.1f;

            Wheels    = new VehicleWheel[4];
            Wheels[0] = new VehicleWheel(this, _model.LeftFrontWheelPos, _model.FrontWheelSize, _model.WheelTexture, offset);
            Wheels[1] = new VehicleWheel(this, _model.RightFrontWheelPos, _model.FrontWheelSize, _model.WheelTexture, -offset);
            Wheels[2] = new VehicleWheel(this, _model.LeftRearWheelPos, _model.RearWheelSize, _model.WheelTexture, offset);
            Wheels[3] = new VehicleWheel(this, _model.RightRearWheelPos, _model.RearWheelSize, _model.WheelTexture, -offset);

            List <float> power  = new List <float>(new float[] { 0.2f, 0.3f, 0.4f, 0.7f, 0.8f, 1.0f, 0.8f, 0.8f, 0.8f, 0.3f });
            List <float> ratios = new List <float>(new float[] { 3.827f, 2.360f, 1.685f, 1.312f, 1.000f, 0.793f });

            BaseGearbox gearbox = BaseGearbox.Create(GameConfig.ManualGearbox, ratios, 0.2f);

            Motor = new Motor(power, Descriptor.Horsepower, Descriptor.Redline, gearbox);
            Motor.Gearbox.GearChangeStarted += new EventHandler(Gearbox_GearChanged);
            _traction = (Motor.GetPowerAtRpmForGear(Motor.RedlineRpm, 2) * 30) - 30;

            BodyPitch = new Spring(1200, 1.5f, 200, 0, 1.4f);
            BodyRoll  = new Spring(1200, 1.5f, 180, 0, 3);

            _audioProvider = new VehicleAudioProvider(this);
        }
Beispiel #4
0
        public VehicleDescription GetVehicleInformationFromVin(string mVin)
        {
            var mSifsir = new VehicleDescriptionRequest
            {
                accountInfo      = GetAccountInfo(),
                Items            = new object[] { mVin },
                ItemsElementName = new[] { ItemsChoiceType.vin },
                @switch          =
                    new[]
                {
                    Switch.DisableSafeStandards, Switch.IncludeDefinitions, Switch.IncludeRegionalVehicles,
                    Switch.ShowAvailableEquipment, Switch.ShowConsumerInformation,
                    Switch.ShowExtendedDescriptions, Switch.ShowExtendedTechnicalSpecifications
                }
            };

            VehicleDescription temp = _vinService.describeVehicle(mSifsir);

            if (temp == null)
            {
                return(null);
            }

            if (temp.responseStatus.responseCode.Equals(ResponseStatusResponseCode.Successful) && temp.modelYear > 0)
            {
                return(temp);
            }
            return(null);
        }
        public async Task <IActionResult> Edit(int id, [Bind("VehicleId,VehicleName,VehicleType,VDriver,VNumber,DriverAddress,DriverDetails,VehicleDetails,ContactPhone,Capacity,Circuit")] VehicleDescription vehicleDescription)
        {
            if (id != vehicleDescription.VehicleId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vehicleDescription);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VehicleDescriptionExists(vehicleDescription.VehicleId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicleDescription));
        }
        public async Task <IActionResult> PutVehicleDescription([FromRoute] int id, [FromBody] VehicleDescription vehDesc)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vehDesc.VehicleId)
            {
                return(BadRequest());
            }
            var vtid = vehDesc.VehicleId;

            try
            {
                var conn = _context.Database.GetDbConnection();
                if (conn.State == ConnectionState.Closed)
                {
                    await conn.OpenAsync();
                }
                using (var command = conn.CreateCommand())
                {
                    MySql = " UPDATE VehicleDescription SET ";
                    MySql = MySql + " VehicleName = '" + vehDesc.VehicleName + "',";
                    MySql = MySql + " VehicleType = '" + vehDesc.VehicleType + "',";
                    MySql = MySql + " vDriver = '" + vehDesc.VDriver + "',";
                    MySql = MySql + " vNumber = '" + vehDesc.VNumber + "',";
                    MySql = MySql + " DriverAddress = '" + vehDesc.DriverAddress + "',";
                    MySql = MySql + " DriverDetails = '" + vehDesc.DriverDetails + "',";
                    MySql = MySql + " VehicleDetails = '" + vehDesc.VehicleDetails + "',";
                    MySql = MySql + " ContactPhone = '" + vehDesc.ContactPhone + "',";
                    MySql = MySql + " Capacity = " + vehDesc.Capacity + ",";
                    MySql = MySql + " Circuit = '" + vehDesc.Circuit + "'";

                    MySql = MySql + " WHERE VehicleID = " + vehDesc.VehicleId;
                    MySql = MySql + " AND Dormant = 0";
                    MySql = MySql + " AND dBID = " + vehDesc.DBid;

                    command.CommandType = CommandType.Text;
                    command.CommandText = MySql;
                    command.ExecuteNonQuery();
                }
                //UpdateAcaSession(acaSession);
                //    await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VehicleDescriptionExists(vtid))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #7
0
 public RacingAIDriver(VehicleDescription vehicleDescriptor)
 {
     _vehicle = new DrivableVehicle(vehicleDescriptor);
     _vehicle.SteeringSpeed = 6;
     _vehicle.AutoDrift     = false;
     Vehicle = _vehicle;
     _firstLaneChangeAllowed = Engine.Instance.Random.Next(5, 40);
 }
Beispiel #8
0
        public void Create_Vehicle_Success()
        {
            var vehicle = new Vehicle(VehicleDescription.Create(VehicleType.Car, "Volvo", new DateTime(1991, 1, 12)
                                                                , "White", "1.6", "X60", "Germany"),
                                      VehicleDetails.Create(Fuel.Petrol, null, Body.Hatchback, 5, 5, false));

            Assert.NotNull(vehicle);
        }
        public List <ExtendedFactoryOptions> GetNonInstalledOptions(VehicleDescription vehicleInfo)
        {
            var listNonInstalledOptions = new List <ExtendedFactoryOptions>();
            var hash = new HashSet <string>();

            if (vehicleInfo.factoryOption != null && vehicleInfo.factoryOption.Any())
            {
                foreach (var fo in vehicleInfo.factoryOption.Where(x => x.standard == false))
                {
                    if (fo.description.Any())
                    {
                        {
                            var optionsName = fo.description.FirstOrDefault();
                            if (optionsName == null || hash.Contains(optionsName))
                            {
                                continue;
                            }

                            if (fo.price.msrpMax > 0 && !optionsName.Contains("PKG") && !optionsName.Contains("PACKAGE") && !optionsName.Contains("EDITION"))
                            {
                                var efo = new ExtendedFactoryOptions();
                                efo.setMSRP(fo.price.msrpMax.ToString("C"));
                                efo.setName(CommonHelper.UpperFirstLetterOfEachWord(optionsName.Replace(",", "")));
                                efo.setStandard(fo.standard);
                                efo.setCategoryName(fo.header != null ? fo.header.Value : string.Empty);
                                efo.Description = fo.description.FirstOrDefault();

                                listNonInstalledOptions.Add(efo);
                                hash.Add(optionsName);
                            }
                        }
                    }
                }
            }

            // Get addtional options from generic equipment
            if (vehicleInfo.genericEquipment != null && vehicleInfo.genericEquipment.Any())
            {
                foreach (var ge in vehicleInfo.genericEquipment)
                {
                    var category = ((CategoryDefinition)(ge.Item)).category.Value;
                    if (!hash.Contains(category) && ge.installed == null)
                    {
                        var efo = new ExtendedFactoryOptions();
                        efo.setMSRP("$0");
                        efo.setName(CommonHelper.UpperFirstLetterOfEachWord(category));
                        efo.setStandard(false);
                        efo.setCategoryName(category);
                        efo.Description = category;

                        listNonInstalledOptions.Add(efo);
                        hash.Add(category);
                    }
                }
            }

            return(listNonInstalledOptions);
        }
 public VehicleDescriptorsPage EnterVehicleDescription(VehicleDescription vehicleDescription)
 {
     GetLastNode().LogDataInfo(vehicleDescription);
     ParameterValidator.ValidateNotNull(vehicleDescription, "Vehicle Description");
     YearTextBox.InputText(vehicleDescription.Year);
     MakeTextBox.InputText(vehicleDescription.Make + Keys.Tab);
     ModelTextBox.InputText(vehicleDescription.Model + Keys.Tab);
     WaitForElementEnabled(_btnNext);
     return(this);
 }
Beispiel #11
0
        public static AppraisalViewFormModel GetVehicleInfoFromChromeDecodeWithStyle(VehicleDescription vehicleInfo, VehicleDescription styleInfo)
        {
            var car = GetVehicleInfoFromChromeDecode(vehicleInfo);

            if (styleInfo != null)
            {
                if (styleInfo.exteriorColor != null && styleInfo.exteriorColor.Any())
                {
                    car.ExteriorColorListForEdit = styleInfo.exteriorColor.GroupBy(x => x.colorName).Select(y => y.First()).ToList();
                }
                else
                {
                    car.ExteriorColorListForEdit = new List <Color>();
                }

                if (styleInfo.interiorColor != null && styleInfo.interiorColor.Any())
                {
                    car.InteriorColorListForEdit = styleInfo.interiorColor.GroupBy(x => x.colorName).Select(y => y.First()).ToList();
                }
                else
                {
                    car.InteriorColorListForEdit = new List <Color>();
                }

                if (SessionHandler.ChromeTrimList != null)
                {
                    car.TrimListEdit = SessionHandler.ChromeTrimList.Select(x => x.Text).Where(p => !String.IsNullOrEmpty(p)).Distinct().ToList();
                    car.TrimList     = SessionHandler.ChromeTrimList;
                    foreach (var item in car.TrimList)
                    {
                        item.Selected = item.Text.Equals(styleInfo.style[0].trim);
                    }
                }
                else
                {
                    if (vehicleInfo.bestMakeName.Equals("Mercedes-Benz") && vehicleInfo.modelYear <= 2009)
                    {
                        car.TrimListEdit = vehicleInfo.style.Select(x => x.mfrModelCode).Where(p => !String.IsNullOrEmpty(p)).Distinct().ToList();
                        bool existed;
                        car.TrimList = SelectListHelper.InitalTrimListForMercedesBenz(car, styleInfo.style[0].mfrModelCode, vehicleInfo.style, styleInfo.style[0].id, out existed);
                        SessionHandler.ChromeTrimList = car.TrimList;
                    }
                    else
                    {
                        car.TrimListEdit = vehicleInfo.style.Select(x => x.trim).Where(p => !String.IsNullOrEmpty(p)).Distinct().ToList();
                        bool existed;
                        car.TrimList = SelectListHelper.InitalTrimList(car, styleInfo.style[0].trim, vehicleInfo.style, styleInfo.style[0].id, out existed);
                        SessionHandler.ChromeTrimList = car.TrimList;
                    }
                }
            }

            return(car);
        }
 public IActionResult Create([Bind("VehicleName,VehicleType,VDriver,VNumber,DriverAddress,DriverDetails,VehicleDetails,ContactPhone,Capacity,Circuit")] VehicleDescription vehicleDescription)
 {
     if (ModelState.IsValid)
     {
         if (!VehicleDescriptionExists(vehicleDescription.VehicleName))
         {
             using (HttpClient client = new HttpClient())
             {
                 vehicleDescription.DBid      = mdBId;
                 vehicleDescription.LoginName = strLoginName;
                 vehicleDescription.ModTime   = DateTime.Now;
                 client.BaseAddress           = new Uri(iBaseURI);
                 MediaTypeWithQualityHeaderValue contentType = new MediaTypeWithQualityHeaderValue("application/json");
                 client.DefaultRequestHeaders.Accept.Add(contentType);
                 string stringData            = JsonConvert.SerializeObject(vehicleDescription);
                 var    contentData           = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json");
                 HttpResponseMessage response = client.PostAsync("/api/vehicleDescriptions", contentData).Result;
                 ViewBag.Message = response.Content.ReadAsStringAsync().Result;
                 if (response.IsSuccessStatusCode)
                 {
                     ViewBag.Remark = "Creation of Vehicle '" + vehicleDescription.VehicleName + "' Successful";
                     GetVehTypLst(_context);
                     ViewBag.dropdownVehType = new SelectList(SchVehTypLst, "Value", "Text", null);;
                     return(View());
                 }
                 else
                 {
                     ViewBag.Remark = "Creation of Vehicle '" + vehicleDescription.VehicleName + "' Failed!. Please Try Again";
                     GetVehTypLst(_context);
                     ViewBag.dropdownVehType = new SelectList(SchVehTypLst, "Value", "Text", null);;
                     return(View(vehicleDescription));
                 }
             }
         }
         else
         {
             ViewBag.Remark = "Failed Vehicle '" + vehicleDescription.VehicleName + "' Already Exists.";
             GetVehTypLst(_context);
             ViewBag.dropdownVehType = new SelectList(SchVehTypLst, "Value", "Text", null);;
             return(View(vehicleDescription));
         }
     }
     else
     {
         ViewBag.Remark = "Failed! Vehicle '" + vehicleDescription.VehicleName + "' Unable To create. PleaseTry Again.";
         GetVehTypLst(_context);
         ViewBag.dropdownVehType = new SelectList(SchVehTypLst, "Value", "Text", null);;
         return(View(vehicleDescription));
     }
 }
Beispiel #13
0
        public static VehicleDescription DecodeProcessingByVin(string vin)
        {
            var autoService = new ChromeAutoService();

            VehicleDescription vehicleInfo = autoService.GetVehicleInformationFromVin(vin);

            if (vehicleInfo != null &&
                (vehicleInfo.responseStatus.responseCode == ResponseStatusResponseCode.Successful ||
                 vehicleInfo.responseStatus.responseCode == ResponseStatusResponseCode.ConditionallySuccessful))
            {
                return(vehicleInfo);
            }

            return(null);
        }
Beispiel #14
0
        public static AppraisalViewFormModel GetVehicleInfoFromChromeDecodeWithStyle(VehicleDescription vehicleInfo,
                                                                                     VehicleDescription styleInfo)
        {
            AppraisalViewFormModel car = GetVehicleInfoFromChromeDecode(vehicleInfo);

            if (styleInfo != null && car != null)
            {
                bool existed;
                car.TrimList = SelectListHelper.InitalTrimList(car, styleInfo.style[0].trim, vehicleInfo.style,
                                                               styleInfo.style[0].id, out existed);

                var chromeAutoService = new ChromeAutoService();
                List <ExtendedFactoryOptions> listPackageOptions      = chromeAutoService.GetPackageOptions(styleInfo);
                List <ExtendedFactoryOptions> listNonInstalledOptions =
                    chromeAutoService.GetNonInstalledOptions(styleInfo);
            }

            return(car);
        }
Beispiel #15
0
        public static AppraisalViewFormModel DecodeProcessingByVin(string vin)
        {
            var viewModel = new AppraisalViewFormModel();

            var autoService = new ChromeAutoService();

            VehicleDescription vehicleInfo = autoService.GetVehicleInformationFromVin(vin);

            if (vehicleInfo != null &&
                (vehicleInfo.responseStatus.responseCode == ResponseStatusResponseCode.Successful ||
                 vehicleInfo.responseStatus.responseCode == ResponseStatusResponseCode.ConditionallySuccessful))
            {
                if (vehicleInfo.style != null && vehicleInfo.style.Any())
                {
                    Style firstStyle = vehicleInfo.style.FirstOrDefault();
                    if (firstStyle != null)
                    {
                        bool existed;
                        viewModel.TrimList = SelectListHelper.InitalTrimList(viewModel, firstStyle.trim,
                                                                             vehicleInfo.style, firstStyle.id,
                                                                             out existed);
                        //SessionHandler.ChromeTrimList = viewModel.TrimList;
                        vehicleInfo = autoService.GetVehicleInformationFromVin(vin, firstStyle.id);
                        VehicleDescription styleInfo = autoService.GetStyleInformationFromStyleId(firstStyle.id);

                        viewModel = GetVehicleInfoFromChromeDecodeWithStyle(vehicleInfo, styleInfo);
                    }
                }
            }

            if (viewModel.IsTruck)
            {
                viewModel.TruckTypeList = SelectListHelper.InitalTruckTypeList();

                //viewModel.TruckCategoryList = SelectListHelper.InitalTruckCategoryList(SQLHelper.GetListOfTruckCategoryByTruckType(viewModel.TruckTypeList.First().Value));

                viewModel.TruckClassList = SelectListHelper.InitalTruckClassList();
            }

            return(viewModel);
        }
        public async Task <IActionResult> PostVehicleDescription([FromBody] VehicleDescription vehDesc)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var conn = _context.Database.GetDbConnection();
                if (conn.State == ConnectionState.Closed)
                {
                    await conn.OpenAsync();
                }
                using (var command = conn.CreateCommand())
                {
                    MySql = " INSERT INTO VehicleDescription (  VehicleID, VehicleName, VehicleType, vDriver, vNumber,"
                            + " DriverAddress, DriverDetails, VehicleDetails, ContactPhone, Capacity, Circuit, ";
                    MySql = MySql + " Dormant, LoginName, ModTime, cTerminal, dBID) Values (0, '";
                    MySql = MySql + vehDesc.VehicleName + "','" + vehDesc.VehicleType + "','" + vehDesc.VDriver + "','";
                    MySql = MySql + vehDesc.VNumber + "','" + vehDesc.DriverAddress + "','" + vehDesc.DriverDetails + "','";
                    MySql = MySql + vehDesc.VehicleDetails + "','" + vehDesc.ContactPhone + "'," + vehDesc.Capacity + ",'";
                    MySql = MySql + vehDesc.Circuit;
                    MySql = MySql + "', 0,'" + vehDesc.LoginName + "'," + GenFunc.GloFunc.ToOADate(DateTime.Now);
                    MySql = MySql + ",'" + vehDesc.CTerminal + "'," + vehDesc.DBid + ")";

                    command.CommandType = CommandType.Text;
                    command.CommandText = MySql;
                    command.ExecuteNonQuery();
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
            //return CreatedAtAction("GetVehicleDescription", new { vhId = vehDesc.VehicleId, ndBId = vehDesc.DBid  }, vehDesc);
            return(Ok(vehDesc));
        }
        public List <ExtendedFactoryOptions> GetPackageOptions(VehicleDescription vehicleInfo)
        {
            var listPackageOptions = new List <ExtendedFactoryOptions>();
            var hash = new HashSet <string>();

            if (vehicleInfo.factoryOption != null && vehicleInfo.factoryOption.Any())
            {
                foreach (var fo in vehicleInfo.factoryOption.Where(x => x.standard == false))
                {
                    if (fo.description.Any())
                    {
                        {
                            var optionsName = fo.description.FirstOrDefault();
                            if (optionsName == null || hash.Contains(optionsName))
                            {
                                continue;
                            }

                            if (fo.price.msrpMax > 0 && (optionsName.Contains("PKG") || optionsName.Contains("PACKAGE") || optionsName.Contains("EDITION")))
                            {
                                var efo = new ExtendedFactoryOptions();
                                efo.setMSRP(fo.price.msrpMax.ToString("C"));
                                efo.setName(CommonHelper.UpperFirstLetterOfEachWord(optionsName.Replace(",", "")));
                                efo.setStandard(fo.standard);
                                efo.setCategoryName(fo.header != null ? fo.header.Value : string.Empty);
                                efo.Description = (fo.description.Count() >= 2) ? fo.description[1] : fo.description[0];

                                listPackageOptions.Add(efo);
                                hash.Add(optionsName);
                            }
                        }
                    }
                }
            }

            return(listPackageOptions);
        }
Beispiel #18
0
        public List <ExtendedFactoryOptions> GetNonInstalledOptions(VehicleDescription vehicleInfo)
        {
            var listNonInstalledOptions = new List <ExtendedFactoryOptions>();
            var hash = new HashSet <string>();

            if (vehicleInfo.factoryOption != null && vehicleInfo.factoryOption.Any())
            {
                foreach (Option fo in vehicleInfo.factoryOption)
                {
                    if (fo.description.Any())
                    {
                        {
                            string optionsName = fo.description.FirstOrDefault();
                            if (optionsName == null || hash.Contains(optionsName))
                            {
                                continue;
                            }

                            if (fo.price.msrpMax > 0 && !optionsName.Contains("PKG") && !optionsName.Contains("PACKAGE"))
                            {
                                var efo = new ExtendedFactoryOptions();
                                efo.SetMsrp(fo.price.msrpMax.ToString("C"));
                                efo.SetName(CommonHelper.UpperFirstLetterOfEachWord(optionsName.Replace(",", "")));
                                efo.SetStandard(fo.standard);
                                efo.SetCategoryName(fo.header != null ? fo.header.Value : string.Empty);
                                efo.Description = fo.description.FirstOrDefault();

                                listNonInstalledOptions.Add(efo);
                                hash.Add(optionsName);
                            }
                        }
                    }
                }
            }

            return(listNonInstalledOptions);
        }
        public ActionResult DuplicateAppraisalForTruck(int appraisalId, string location)
        {
            if (Session["Dealership"] == null)
            {
                return(RedirectToAction("LogOff", "Account"));
            }
            else
            {
                var dealer = (DealershipViewModel)Session["Dealership"];

                var row = ConvertHelper.GetAppraisalModelFromAppriaslId(appraisalId);

                var autoService = new ChromeAutoService();

                if (!String.IsNullOrEmpty(row.VinNumber))
                {
                    VehicleDescription vehicleInfo = autoService.GetVehicleInformationFromVin(row.VinNumber);

                    VehicleDescription styleInfo = null;
                    if (!String.IsNullOrEmpty(row.ChromeStyleId))
                    {
                        int styleId;
                        Int32.TryParse(row.ChromeStyleId, out styleId);

                        styleInfo = autoService.GetStyleInformationFromStyleId(styleId);
                    }
                    else
                    {
                        if (vehicleInfo.style.Any(x => x.trim == row.Trim))
                        {
                            var element = vehicleInfo.style.First(x => x.trim == row.Trim);
                            styleInfo = autoService.GetStyleInformationFromStyleId(element.id);
                        }
                        else
                        {
                            styleInfo = autoService.GetStyleInformationFromStyleId(vehicleInfo.style.First().id);
                        }
                    }

                    if (vehicleInfo != null)
                    {
                        var viewModel = ConvertHelper.GetVehicleInfoFromChromeDecodeWithStyle(vehicleInfo, styleInfo);

                        viewModel = ConvertHelper.UpdateSuccessfulAppraisalModel(viewModel, row, vehicleInfo, dealer.DealershipId, location, true);

                        viewModel.SelectedTruckType = row.TruckType;

                        viewModel.SelectedTruckClass = row.TruckClass;

                        viewModel.SelectedTruckCategory = row.TruckCategory;

                        viewModel.TruckTypeList = SelectListHelper.InitalTruckTypeList();

                        viewModel.TruckCategoryList = SelectListHelper.InitalTruckCategoryList(SQLHelper.GetListOfTruckCategoryByTruckType(viewModel.TruckTypeList.First().Value));

                        viewModel.TruckClassList = SelectListHelper.InitalTruckClassList(row.TruckClass);

                        viewModel.VehicleTypeList = SelectListHelper.InitalVehicleTypeListForTruck();

                        return(View("DuplicateAppraisalForTruck", viewModel));
                    }
                    else
                    {
                        var viewModel = new AppraisalViewFormModel();

                        viewModel = ConvertHelper.UpdateSuccessfulAppraisalModel(viewModel, row, vehicleInfo, dealer.DealershipId, location, false);

                        viewModel.SelectedTruckType = row.TruckType;

                        viewModel.SelectedTruckClass = row.TruckClass;

                        viewModel.SelectedTruckCategory = row.TruckCategory;

                        viewModel.TruckTypeList = SelectListHelper.InitalTruckTypeList();

                        viewModel.TruckCategoryList = SelectListHelper.InitalTruckCategoryList(SQLHelper.GetListOfTruckCategoryByTruckType(viewModel.TruckTypeList.First().Value));

                        viewModel.TruckClassList = SelectListHelper.InitalTruckClassList(row.TruckClass);

                        viewModel.VehicleTypeList = SelectListHelper.InitalVehicleTypeListForTruck();

                        return(View("DuplicateAppraisalForTruck", viewModel));
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(row.ChromeStyleId))
                    {
                        int chromeStyleId;
                        Int32.TryParse(row.ChromeStyleId, out chromeStyleId);

                        int chromeModelId;
                        Int32.TryParse(row.ChromeModelId, out chromeModelId);

                        var styleInfo = autoService.GetStyleInformationFromStyleId(chromeStyleId);

                        var styleArray = autoService.GetStyles(chromeModelId);

                        var appraisal = ConvertHelper.GetVehicleInfoFromChromeDecode(styleInfo);

                        appraisal = ConvertHelper.UpdateSuccessfulAppraisalModel(appraisal, row, styleInfo, dealer.DealershipId, location, false);

                        appraisal.ChromeModelId = chromeModelId.ToString();

                        appraisal.ChromeStyleId = chromeStyleId.ToString();

                        appraisal.TrimList = SelectListHelper.InitalTrimList(styleArray);

                        if (styleInfo.style != null && styleInfo.style.First().stockImage != null)
                        {
                            appraisal.DefaultImageUrl = styleInfo.style.First().stockImage.url;
                        }

                        appraisal.TruckTypeList = SelectListHelper.InitalTruckTypeList();

                        appraisal.TruckCategoryList = SelectListHelper.InitalTruckCategoryList(SQLHelper.GetListOfTruckCategoryByTruckType(appraisal.TruckTypeList.First().Value));

                        appraisal.TruckClassList = SelectListHelper.InitalTruckClassList(row.TruckClass);

                        appraisal.VehicleTypeList = SelectListHelper.InitalVehicleTypeListForTruck();

                        return(View("DuplicateAppraisalForTruck", appraisal));
                    }
                    else
                    {
                        int chromeModelId;
                        Int32.TryParse(row.ChromeModelId, out chromeModelId);

                        var styleArray = autoService.GetStyles(chromeModelId);
                        VehicleDescription styleInfo = null;

                        if (row.SelectedTrim != null && row.SelectedTrim.Equals(string.Empty))
                        {
                            styleInfo = autoService.GetStyleInformationFromStyleId(styleArray.First().id);
                        }

                        var appraisal = ConvertHelper.GetVehicleInfoFromChromeDecode(styleInfo);

                        appraisal = ConvertHelper.UpdateSuccessfulAppraisalModel(appraisal, row, styleInfo, dealer.DealershipId, location, false);

                        appraisal.ChromeModelId = chromeModelId.ToString(CultureInfo.InvariantCulture);

                        appraisal.ChromeStyleId = styleArray.First().id.ToString(CultureInfo.InvariantCulture);

                        appraisal.TrimList = SelectListHelper.InitalTrimList(styleArray);

                        if (styleInfo != null && styleInfo.style != null && styleInfo.style.First().stockImage != null)
                        {
                            appraisal.DefaultImageUrl = styleInfo.style.First().stockImage.url;
                        }

                        appraisal.TruckTypeList = SelectListHelper.InitalTruckTypeList();

                        appraisal.TruckCategoryList = SelectListHelper.InitalTruckCategoryList(SQLHelper.GetListOfTruckCategoryByTruckType(appraisal.TruckTypeList.First().Value));

                        appraisal.TruckClassList = SelectListHelper.InitalTruckClassList(row.TruckClass);

                        appraisal.VehicleTypeList = SelectListHelper.InitalVehicleTypeListForTruck();

                        return(View("DuplicateAppraisalForTruck", appraisal));
                    }
                }
            }
        }
Beispiel #20
0
 public RacingAIDriver(VehicleDescription vehicleDescriptor)
 {
     _vehicle = new DrivableVehicle(vehicleDescriptor);
     _vehicle.SteeringSpeed = 6;
     _vehicle.AutoDrift = false;
     Vehicle = _vehicle;
     _firstLaneChangeAllowed = Engine.Instance.Random.Next(5, 40);
 }
Beispiel #21
0
        public CCWData GetCCW(string regi, string plate, string vin, string userId, string guid, string directory)
        {
            // check we have the right headers.
            if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(guid) || string.IsNullOrEmpty(directory))
            {
                return(null);
            }

            var batchUser = _configuration.GetValue <string>("CCW_USER_ID");
            var logPrefix = batchUser == userId ? "[Hangfire]" : "";

            // Check for the following data:
            // 1. registration
            // 2. plate
            // 3. decal

            VehicleDescription vehicle = null;

            if (regi != null)
            {
                // format the regi.
                try
                {
                    int registration = int.Parse(regi);
                    // zero padded, 8 digits
                    regi = registration.ToString("D8");
                }
                catch (Exception)
                {
                    _logger.LogInformation($"{logPrefix} Exception occured parsing registration number {regi}.");
                }

                vehicle = _ccwService.GetBCVehicleForRegistrationNumber(regi, userId, guid, directory);
            }

            if (vehicle == null && plate != null) // check the plate.
            {
                vehicle = _ccwService.GetBCVehicleForLicensePlateNumber(plate, userId, guid, directory);
            }

            if (vehicle == null && vin != null) // check the vin.
            {
                vehicle = _ccwService.GetBCVehicleForSerialNumber(vin, userId, guid, directory);
            }

            if (vehicle == null)
            {
                return(null);
            }

            string icbcRegistrationNumber = vehicle.registrationNumber;

            CCWData ccwdata = null;

            if (_context.CCWDatas.Any(x => x.ICBCRegistrationNumber == icbcRegistrationNumber))
            {
                ccwdata = _context.CCWDatas.First(x => x.ICBCRegistrationNumber == icbcRegistrationNumber);
                _logger.LogInformation($"{logPrefix} Found CCW record for Registration # " + ccwdata.ICBCRegistrationNumber);
            }
            else
            {
                _logger.LogInformation($"{logPrefix} Creating new CCW record");
                ccwdata = new CCWData();
            }

            // update the ccw record.
            ccwdata.ICBCBody               = vehicle.bodyCode;
            ccwdata.ICBCColour             = vehicle.colour;
            ccwdata.ICBCCVIPDecal          = vehicle.inspectionDecalNumber;
            ccwdata.ICBCCVIPExpiry         = vehicle.inspectionExpiryDate;
            ccwdata.ICBCFleetUnitNo        = SanitizeInt(vehicle.fleetUnitNumber);
            ccwdata.ICBCFuel               = vehicle.fuelTypeDescription;
            ccwdata.ICBCGrossVehicleWeight = SanitizeInt(vehicle.grossVehicleWeight);
            ccwdata.ICBCMake               = vehicle.make;
            ccwdata.ICBCModel              = vehicle.model;
            ccwdata.ICBCGrossVehicleWeight = SanitizeInt(vehicle.grossVehicleWeight);
            ccwdata.ICBCModelYear          = SanitizeInt(vehicle.modelYear);
            ccwdata.ICBCNetWt              = SanitizeInt(vehicle.netWeight);
            ccwdata.ICBCNotesAndOrders     = vehicle.cvipDataFromLastInspection;
            ccwdata.ICBCOrderedOn          = vehicle.firstOpenOrderDate;
            ccwdata.ICBCRateClass          = vehicle.rateClass;
            ccwdata.ICBCRebuiltStatus      = vehicle.statusCode;
            ccwdata.ICBCRegistrationNumber = vehicle.registrationNumber;
            ccwdata.ICBCRegOwnerAddr1      = vehicle.owner.mailingAddress1;
            ccwdata.ICBCRegOwnerAddr2      = vehicle.owner.mailingAddress2;
            ccwdata.ICBCRegOwnerCity       = vehicle.owner.mailingAddress3;
            ccwdata.ICBCRegOwnerName       = vehicle.owner.name1;
            ccwdata.ICBCRegOwnerPODL       = vehicle.principalOperatorDlNum;
            ccwdata.ICBCRegOwnerPostalCode = vehicle.owner.postalCode;
            ccwdata.ICBCRegOwnerProv       = vehicle.owner.mailingAddress4;
            ccwdata.ICBCRegOwnerRODL       = vehicle.owner.driverLicenseNumber;
            ccwdata.ICBCSeatingCapacity    = SanitizeInt(vehicle.seatingCapacity);
            ccwdata.ICBCVehicleType        = vehicle.vehicleType + " - " + vehicle.vehicleTypeDescription;

            ccwdata.ICBCVehicleIdentificationNumber = vehicle.serialNumber;

            ccwdata.NSCPlateDecal          = vehicle.decalNumber;
            ccwdata.NSCPolicyEffectiveDate = vehicle.policyStartDate;
            ccwdata.NSCPolicyExpiryDate    = vehicle.policyExpiryDate;
            ccwdata.NSCPolicyStatus        = vehicle.policyStatus + " - " + vehicle.policyStatusDescription;

            // policyAquiredCurrentStatusDate is the preferred field, however it is often null.
            if (vehicle.policyAcquiredCurrentStatusDate != null)
            {
                ccwdata.NSCPolicyStatusDate = vehicle.policyAcquiredCurrentStatusDate;
            }
            else if (vehicle.policyTerminationDate != null)
            {
                ccwdata.NSCPolicyStatusDate = vehicle.policyTerminationDate;
            }
            else if (vehicle.policyReplacedOnDate != null)
            {
                ccwdata.NSCPolicyStatusDate = vehicle.policyReplacedOnDate;
            }
            else if (vehicle.policyStartDate != null)
            {
                ccwdata.NSCPolicyStatusDate = vehicle.policyStartDate;
            }

            if (vehicle.owner != null)
            {
                ccwdata.ICBCRegOwnerRODL = vehicle.owner.driverLicenseNumber;
            }

            ccwdata.ICBCLicencePlateNumber = vehicle.policyNumber;
            // these fields are the same.
            ccwdata.NSCPolicyNumber = vehicle.policyNumber;
            ccwdata.NSCClientNum    = vehicle.nscNumber;

            ccwdata.DateFetched = DateTime.UtcNow;

            // get the nsc client organization data.

            bool foundNSCData = false;

            if (!string.IsNullOrEmpty(ccwdata.NSCPolicyNumber))
            {
                string organizationNameCode = "LE";

                ClientOrganization clientOrganization = _ccwService.GetCurrentClientOrganization(ccwdata.NSCClientNum, organizationNameCode, userId, guid, directory);

                if (clientOrganization != null)
                {
                    foundNSCData = true;
                    ccwdata.NSCCarrierConditions   = clientOrganization.nscInformation.carrierStatus;
                    ccwdata.NSCCarrierName         = clientOrganization.displayName;
                    ccwdata.NSCCarrierSafetyRating = clientOrganization.nscInformation.safetyRating;
                }

                // now try the individual service if there was no match.
                if (foundNSCData == false)
                {
                    ClientIndividual clientIndividual = _ccwService.GetCurrentClientIndividual(ccwdata.NSCClientNum, organizationNameCode, userId, guid, directory);

                    if (clientIndividual != null)
                    {
                        foundNSCData = true;
                        ccwdata.NSCCarrierConditions   = clientIndividual.nscInformation.carrierStatus;
                        ccwdata.NSCCarrierName         = clientIndividual.displayName;
                        ccwdata.NSCCarrierSafetyRating = clientIndividual.nscInformation.safetyRating;
                    }
                }
            }

            if (ccwdata.Id > 0)
            {
                var bus = _context.SchoolBuss.FirstOrDefault(x => x.CCWDataId == ccwdata.Id);

                var changes = _context.GetChanges(ccwdata, "DateFetched");

                if (bus != null && changes.Count > 0)
                {
                    var ccwNotification = (new CCWNotification
                    {
                        HasBeenViewed = false,
                    });

                    bus.CCWNotifications.Add(ccwNotification);

                    foreach (var change in changes)
                    {
                        ccwNotification.CCWNotificationDetails.Add(new CCWNotificationDetail
                        {
                            ColName        = change.ColName,
                            ColDescription = change.ColDescription,
                            ValueFrom      = change.ValueFrom,
                            ValueTo        = change.ValueTo
                        });
                    }
                }
            }
            else
            {
                _context.Add(ccwdata);
            }

            _logger.LogInformation($"{logPrefix} CCW data has been added/updated.");
            _context.SaveChanges();

            return(ccwdata);
        }
Beispiel #22
0
        public static CarInfoFormViewModel GetVehicleInfoFromChromeDecodeWithStyleForEdit(VehicleDescription vehicleInfo, VehicleDescription styleInfo)
        {
            var car = GetVehicleInfoFromChromeDecodeForEdit(vehicleInfo);

            if (styleInfo != null)
            {
                car.MSRP = vehicleInfo.basePrice.msrp.high.ToString("C");

                if (styleInfo.exteriorColor != null && styleInfo.exteriorColor.Any())
                {
                    car.ExteriorColorList = styleInfo.exteriorColor.GroupBy(x => x.colorName).Select(y => y.First()).ToList();
                }
                else
                {
                    car.ExteriorColorList = new List <Color>();
                }

                if (styleInfo.interiorColor != null && styleInfo.interiorColor.Any())
                {
                    car.InteriorColorList = styleInfo.interiorColor.GroupBy(x => x.colorName).Select(y => y.First()).ToList();
                }
                else
                {
                    car.InteriorColorList = new List <Color>();
                }

                if (styleInfo.exteriorColor != null && styleInfo.exteriorColor.Any())
                {
                    car.ChromeExteriorColorList = SelectListHelper.InitalExteriorColorList(styleInfo.exteriorColor).ToList();
                }
                else
                {
                    car.ChromeExteriorColorList = new List <SelectListItem>().AsEnumerable();
                }

                if (styleInfo.interiorColor != null && styleInfo.interiorColor.Any())
                {
                    car.ChromeInteriorColorList = SelectListHelper.InitalExteriorColorList(styleInfo.interiorColor);
                }
                else
                {
                    car.ChromeInteriorColorList = new List <SelectListItem>().AsEnumerable();
                }

                car.EditTrimList = SelectListHelper.InitalTrimList(styleInfo.style);



                if (styleInfo.engine != null)
                {
                    var firstEngine = vehicleInfo.engine.FirstOrDefault();
                    if (firstEngine != null && firstEngine.fuelEconomy != null)
                    {
                        car.FuelEconomyCity    = firstEngine.fuelEconomy.city.low.ToString();
                        car.FuelEconomyHighWay = firstEngine.fuelEconomy.hwy.low.ToString();
                    }
                }

                if (styleInfo.vinDescription != null && styleInfo.vinDescription.marketClass != null)
                {
                    if (styleInfo.vinDescription.marketClass.Any(tmp => tmp.Value.Contains("Truck") || tmp.Value.Contains("Cargo Vans")))
                    {
                        car.IsTruck = true;
                    }
                }
            }

            return(car);
        }
        public IEnumerable <VehicleDescription> Get(int mdBId)
        {
            List <VehicleDescription> VehicleDescList = new List <VehicleDescription>();
            var conn = _context.Database.GetDbConnection();

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            using (var command = conn.CreateCommand())
            {
                MySql = " SELECT  VehicleID, VehicleName, VehicleType, vDriver, vNumber, DriverAddress, DriverDetails,"
                        + "VehicleDetails, ContactPhone, Capacity, Circuit FROM VehicleDescription WITH (NOLOCK)";
                MySql = MySql + " WHERE  Dormant = 0";
                MySql = MySql + " AND dBID = " + mdBId;
                MySql = MySql + " AND VehicleID > 0";
                command.CommandType = CommandType.Text;
                command.CommandText = MySql;
                DbDataReader kMyReader = command.ExecuteReader();
                if (kMyReader.HasRows)
                {
                    while (kMyReader.Read())
                    {
                        VehicleDescription vehDesc = new VehicleDescription();
                        if (!kMyReader.IsDBNull(0))
                        {
                            vehDesc.VehicleId = kMyReader.GetInt32(0);
                        }
                        if (!kMyReader.IsDBNull(1))
                        {
                            vehDesc.VehicleName = kMyReader.GetString(1);
                        }
                        if (!kMyReader.IsDBNull(2))
                        {
                            vehDesc.VehicleType = kMyReader.GetString(2);
                        }
                        if (!kMyReader.IsDBNull(3))
                        {
                            vehDesc.VDriver = kMyReader.GetString(3);
                        }
                        if (!kMyReader.IsDBNull(4))
                        {
                            vehDesc.VNumber = kMyReader.GetString(4);
                        }
                        if (!kMyReader.IsDBNull(5))
                        {
                            vehDesc.DriverAddress = kMyReader.GetString(5);
                        }
                        if (!kMyReader.IsDBNull(6))
                        {
                            vehDesc.DriverDetails = kMyReader.GetString(6);
                        }
                        if (!kMyReader.IsDBNull(7))
                        {
                            vehDesc.VehicleDetails = kMyReader.GetString(7);
                        }
                        if (!kMyReader.IsDBNull(8))
                        {
                            vehDesc.ContactPhone = kMyReader.GetString(8);
                        }
                        if (!kMyReader.IsDBNull(9))
                        {
                            vehDesc.Capacity = kMyReader.GetInt32(9);
                        }
                        if (!kMyReader.IsDBNull(10))
                        {
                            vehDesc.Circuit = kMyReader.GetString(10);
                        }
                        VehicleDescList.Add(vehDesc);
                    }
                }
            }
            return(VehicleDescList);
        }
Beispiel #24
0
        public static AppraisalViewFormModel UpdateSuccessfulAppraisalModelWithoutVin(AppraisalViewFormModel viewModel, AppraisalViewFormModel row, VehicleDescription vehicleInfo, int dealershipId, string location, bool decodeSuccessfully)
        {
            viewModel.AppraisalGenerateId = row.AppraisalID.ToString();

            if (String.IsNullOrEmpty(row.SalePrice))
            {
                viewModel.SalePrice = "NA";
            }
            else
            {
                double priceFormat;
                bool   flag = Double.TryParse(row.SalePrice, out priceFormat);
                if (flag)
                {
                    viewModel.SalePrice = priceFormat.ToString("#,##0");
                }
            }

            if (String.IsNullOrEmpty(row.DealerCost))
            {
                viewModel.DealerCost = "NA";
            }
            else
            {
                double priceFormat;
                bool   flag = Double.TryParse(row.DealerCost, out priceFormat);
                if (flag)
                {
                    viewModel.DealerCost = priceFormat.ToString("#,##0");
                }
            }

            if (String.IsNullOrEmpty(row.ACV))
            {
                viewModel.ACV = "NA";
            }
            else
            {
                double priceFormat;
                bool   flag = Double.TryParse(row.ACV, out priceFormat);
                if (flag)
                {
                    viewModel.ACV = priceFormat.ToString("#,##0");
                }
            }

            viewModel.OrginalName = viewModel.ModelYear + " " + viewModel.Make + " " + viewModel.AppraisalModel;

            if (!String.IsNullOrEmpty(viewModel.Trim) && !viewModel.Trim.Equals("NA"))
            {
                viewModel.OrginalName += " " + viewModel.Trim;
            }

            viewModel.Mileage = row.Mileage ?? "0";

            viewModel.DefaultImageUrl = row.DefaultImageUrl ?? string.Empty;

            viewModel.Descriptions = row.Descriptions ?? string.Empty;

            viewModel.VehicleTypeList = SelectListHelper.InitalVehicleTypeList();

            viewModel.DealershipId = dealershipId;

            viewModel.StockNumber = row.StockNumber ?? string.Empty;

            viewModel.VinNumber = row.VinNumber ?? string.Empty;

            viewModel.ModelYear = row.ModelYear;

            viewModel.Make = row.Make ?? string.Empty;

            viewModel.SelectedModel = row.AppraisalModel ?? string.Empty;

            viewModel.AppraisalModel = row.AppraisalModel ?? string.Empty;

            viewModel.AppraisalDate = row.AppraisalDate ?? DateTime.Now.ToString("MM/dd/yyyy");

            viewModel.Location = location;

            viewModel.Trim = row.SelectedTrim;

            viewModel.ChromeStyleId = row.ChromeStyleId;
            int styleId;

            if (viewModel.ChromeStyleId != null && Int32.TryParse(viewModel.ChromeStyleId, out styleId))
            {
                bool existed;
                viewModel.TrimList = SelectListHelper.InitalTrimList(viewModel, viewModel.Trim, vehicleInfo.style, styleId, out existed);
                if (!existed)
                {
                    viewModel.CusTrim = viewModel.Trim;
                }
            }
            else if (!String.IsNullOrEmpty(viewModel.Trim))
            {
                bool existed;
                viewModel.TrimList = SelectListHelper.InitalTrimList(viewModel, vehicleInfo.style, viewModel.Trim, out existed);
                if (!existed)
                {
                    viewModel.CusTrim = viewModel.Trim;
                }
            }
            else
            {
                viewModel.TrimList = SelectListHelper.InitalTrimList(vehicleInfo.style);
            }

            viewModel.BodyTypeList = SelectListHelper.InitialBodyTypeList(row.SelectedBodyType);

            viewModel.SelectedExteriorColorCode  = row.SelectedExteriorColorCode ?? string.Empty;
            viewModel.SelectedExteriorColorValue = row.SelectedExteriorColorValue ?? string.Empty;
            viewModel.SelectedInteriorColor      = row.SelectedInteriorColor ?? string.Empty;

            if (viewModel.ExteriorColorListForEdit != null && viewModel.ExteriorColorListForEdit.Any())
            {
                var list = viewModel.ExteriorColorListForEdit.Where(t => t.colorName.Equals(viewModel.SelectedExteriorColorValue.Trim()));
                if (!list.Any())
                {
                    viewModel.CusExteriorColor = row.ExteriorColor ?? string.Empty;
                }
                else
                {
                    viewModel.CusExteriorColor = string.Empty;
                }
            }
            else
            {
                viewModel.CusExteriorColor = row.ExteriorColor ?? string.Empty;
            }

            if (viewModel.InteriorColorListForEdit != null && viewModel.InteriorColorListForEdit.Any())
            {
                var list = viewModel.InteriorColorListForEdit.Where(t => t.colorName.Equals(viewModel.SelectedInteriorColor));
                if (!list.Any())
                {
                    viewModel.CusInteriorColor = row.InteriorColor ?? string.Empty;
                }
                else
                {
                    viewModel.CusInteriorColor = string.Empty;
                }
            }
            else
            {
                viewModel.CusInteriorColor = row.InteriorColor ?? string.Empty;
            }

            viewModel.DriveTrainList = SelectListHelper.InitalEditDriveTrainList(viewModel.WheelDrive);

            viewModel.ExistOptions = String.IsNullOrEmpty(row.SelectedFactoryOptions)
                                         ? null
                                         : (from data in CommonHelper.GetArrayFromString(row.SelectedFactoryOptions) select data).ToList();

            viewModel.ExistPackages = String.IsNullOrEmpty(row.SelectedPackageOptions)
                                          ? null
                                          : (from data in CommonHelper.GetArrayFromString(row.SelectedPackageOptions) select data).ToList();

            viewModel.VehicleType = row.VehicleType;

            viewModel.Notes = row.Notes;

            if (!String.IsNullOrEmpty(row.MSRP))
            {
                double msrpFormat;
                bool   msrpFlag = Double.TryParse(row.MSRP, out msrpFormat);
                if (msrpFlag)
                {
                    viewModel.MSRP = msrpFormat.ToString("c0");
                }
            }

            viewModel.CustomerFirstName = row.CustomerFirstName ?? string.Empty;

            viewModel.CustomerLastName = row.CustomerLastName ?? string.Empty;

            viewModel.CustomerAddress = row.CustomerAddress ?? string.Empty;

            viewModel.CustomerCity = row.CustomerCity ?? string.Empty;

            viewModel.CustomerState = row.CustomerState ?? string.Empty;

            viewModel.CustomerZipCode = row.CustomerZipCode ?? string.Empty;

            viewModel.Door = row.Door ?? string.Empty;

            viewModel.SelectedBodyType = row.SelectedBodyType ?? string.Empty;

            viewModel.SelectedCylinder = row.SelectedCylinder ?? string.Empty;

            viewModel.SelectedDriveTrain = row.SelectedDriveTrain ?? string.Empty;

            viewModel.SelectedTranmission = row.SelectedTranmission ?? string.Empty;

            viewModel.SelectedLiters = row.SelectedLiters ?? string.Empty;

            viewModel.SelectedFuel = row.SelectedFuel ?? string.Empty;

            viewModel.VinDecodeSuccess = decodeSuccessfully;

            return(viewModel);
        }
        public async Task <IActionResult> GetVehicleDescription([FromRoute] int vhId, int ndBId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var conn = _context.Database.GetDbConnection();

            if (conn.State == ConnectionState.Closed)
            {
                await conn.OpenAsync();
            }
            using (var command = conn.CreateCommand())
            {
                MySql = " SELECT VehicleName, VehicleType, vDriver, vNumber, DriverAddress, DriverDetails, VehicleDetails, "
                        + " ContactPhone, Capacity, Circuit FROM VehicleDescription WITH (NOLOCK)";
                MySql = MySql + " WHERE VehicleId = " + vhId;
                MySql = MySql + " AND Dormant = 0";
                MySql = MySql + " AND dBID = " + ndBId;

                command.CommandType = CommandType.Text;
                command.CommandText = MySql;
                DbDataReader kMyReader = await command.ExecuteReaderAsync();

                if (kMyReader.HasRows)
                {
                    kMyReader.Read();
                    VehicleDescription vehDesc = new VehicleDescription();
                    vehDesc.VehicleId = vhId;
                    if (!kMyReader.IsDBNull(0))
                    {
                        vehDesc.VehicleName = kMyReader.GetString(0);
                    }
                    if (!kMyReader.IsDBNull(1))
                    {
                        vehDesc.VehicleType = kMyReader.GetString(1);
                    }
                    if (!kMyReader.IsDBNull(2))
                    {
                        vehDesc.VDriver = kMyReader.GetString(2);
                    }
                    if (!kMyReader.IsDBNull(3))
                    {
                        vehDesc.VNumber = kMyReader.GetString(3);
                    }
                    if (!kMyReader.IsDBNull(4))
                    {
                        vehDesc.DriverAddress = kMyReader.GetString(4);
                    }
                    if (!kMyReader.IsDBNull(5))
                    {
                        vehDesc.DriverDetails = kMyReader.GetString(5);
                    }
                    if (!kMyReader.IsDBNull(6))
                    {
                        vehDesc.VehicleDetails = kMyReader.GetString(6);
                    }
                    if (!kMyReader.IsDBNull(7))
                    {
                        vehDesc.ContactPhone = kMyReader.GetString(7);
                    }
                    if (!kMyReader.IsDBNull(8))
                    {
                        vehDesc.Capacity = kMyReader.GetInt32(8);
                    }
                    if (!kMyReader.IsDBNull(9))
                    {
                        vehDesc.Circuit = kMyReader.GetString(9);
                    }
                    return(Ok(vehDesc));
                }
                else
                {
                    return(NotFound());
                }
            }
        }
Beispiel #26
0
        public virtual IActionResult GetCCW([FromQuery] string regi, [FromQuery] string plate, [FromQuery] string vin)
        {
            // check we have the right headers.
            if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(guid) || string.IsNullOrEmpty(directory))
            {
                return(new UnauthorizedResult());
            }

            // Check for the following data:
            // 1. registration
            // 2. plate
            // 3. decal

            VehicleDescription vehicle = null;

            if (regi != null)
            {
                // format the regi.
                try
                {
                    int registration = int.Parse(regi);
                    // zero padded, 8 digits
                    regi = registration.ToString("D8");
                }
                catch (Exception e)
                {
                    _logger.LogInformation("Exception occured parsing registration number " + regi);
                }

                try
                {
                    vehicle = _service.GetBCVehicleForRegistrationNumber(regi, userId, guid, directory);
                }
                catch (Exception e)
                {
                    vehicle = null;
                }
            }
            if (vehicle == null && plate != null) // check the plate.
            {
                try
                {
                    vehicle = _service.GetBCVehicleForLicensePlateNumber(plate, userId, guid, directory);
                }
                catch (Exception e)
                {
                    vehicle = null;
                }
            }
            if (vehicle == null && vin != null) // check the vin.
            {
                try
                {
                    vehicle = _service.GetBCVehicleForSerialNumber(vin, userId, guid, directory);
                }
                catch (Exception e)
                {
                    vehicle = null;
                }
            }
            if (vehicle == null)
            {
                return(new StatusCodeResult(404)); // Can't find the vehicle.
            }
            else
            {
                string  icbcRegistrationNumber = vehicle.registrationNumber;
                CCWData ccwdata  = null;
                bool    existing = false;
                if (_context.CCWDatas.Any(x => x.ICBCRegistrationNumber == icbcRegistrationNumber))
                {
                    ccwdata  = _context.CCWDatas.First(x => x.ICBCRegistrationNumber == icbcRegistrationNumber);
                    existing = true;

                    _logger.LogInformation("Found record for Registration # " + ccwdata.ICBCRegistrationNumber);
                }
                else
                {
                    _logger.LogInformation("Creating new record");
                    ccwdata = new CCWData();
                }
                // update the ccw record.

                ccwdata.ICBCBody               = vehicle.bodyCode;
                ccwdata.ICBCColour             = vehicle.colour;
                ccwdata.ICBCCVIPDecal          = vehicle.inspectionDecalNumber;
                ccwdata.ICBCCVIPExpiry         = vehicle.inspectionExpiryDate;
                ccwdata.ICBCFleetUnitNo        = SanitizeInt(vehicle.fleetUnitNumber);
                ccwdata.ICBCFuel               = vehicle.fuelTypeDescription;
                ccwdata.ICBCGrossVehicleWeight = SanitizeInt(vehicle.grossVehicleWeight);
                ccwdata.ICBCMake               = vehicle.make;
                ccwdata.ICBCModel              = vehicle.model;
                ccwdata.ICBCGrossVehicleWeight = SanitizeInt(vehicle.grossVehicleWeight);
                ccwdata.ICBCModelYear          = SanitizeInt(vehicle.modelYear);
                ccwdata.ICBCNetWt              = SanitizeInt(vehicle.netWeight);
                ccwdata.ICBCNotesAndOrders     = vehicle.cvipDataFromLastInspection;
                ccwdata.ICBCOrderedOn          = vehicle.firstOpenOrderDate;
                ccwdata.ICBCRateClass          = vehicle.rateClass;
                ccwdata.ICBCRebuiltStatus      = vehicle.statusCode;
                ccwdata.ICBCRegistrationNumber = vehicle.registrationNumber;
                ccwdata.ICBCRegOwnerAddr1      = vehicle.owner.mailingAddress1;
                ccwdata.ICBCRegOwnerAddr2      = vehicle.owner.mailingAddress2;
                ccwdata.ICBCRegOwnerCity       = vehicle.owner.mailingAddress3;
                ccwdata.ICBCRegOwnerName       = vehicle.owner.name1;
                ccwdata.ICBCRegOwnerPODL       = vehicle.principalOperatorDlNum;
                ccwdata.ICBCRegOwnerPostalCode = vehicle.owner.postalCode;
                ccwdata.ICBCRegOwnerProv       = vehicle.owner.mailingAddress4;
                ccwdata.ICBCRegOwnerRODL       = vehicle.owner.driverLicenseNumber;
                ccwdata.ICBCSeatingCapacity    = SanitizeInt(vehicle.seatingCapacity);
                ccwdata.ICBCVehicleType        = vehicle.vehicleType + " - " + vehicle.vehicleTypeDescription;

                ccwdata.ICBCVehicleIdentificationNumber = vehicle.serialNumber;

                ccwdata.NSCPlateDecal          = vehicle.decalNumber;
                ccwdata.NSCPolicyEffectiveDate = vehicle.policyStartDate;
                ccwdata.NSCPolicyExpiryDate    = vehicle.policyExpiryDate;
                ccwdata.NSCPolicyStatus        = vehicle.policyStatus + " - " + vehicle.policyStatusDescription;

                // policyAquiredCurrentStatusDate is the preferred field, however it is often null.
                if (vehicle.policyAcquiredCurrentStatusDate != null)
                {
                    ccwdata.NSCPolicyStatusDate = vehicle.policyAcquiredCurrentStatusDate;
                }
                else if (vehicle.policyTerminationDate != null)
                {
                    ccwdata.NSCPolicyStatusDate = vehicle.policyTerminationDate;
                }
                else if (vehicle.policyReplacedOnDate != null)
                {
                    ccwdata.NSCPolicyStatusDate = vehicle.policyReplacedOnDate;
                }
                else if (vehicle.policyStartDate != null)
                {
                    ccwdata.NSCPolicyStatusDate = vehicle.policyStartDate;
                }

                if (vehicle.owner != null)
                {
                    ccwdata.ICBCRegOwnerRODL = vehicle.owner.driverLicenseNumber;
                }
                ccwdata.ICBCLicencePlateNumber = vehicle.policyNumber;
                // these fields are the same.
                ccwdata.NSCPolicyNumber = vehicle.policyNumber;
                ccwdata.NSCClientNum    = vehicle.nscNumber;

                ccwdata.DateFetched = DateTime.UtcNow;

                // get the nsc client organization data.

                bool foundNSCData = false;

                if (!string.IsNullOrEmpty(ccwdata.NSCPolicyNumber))
                {
                    string organizationNameCode = "LE";
                    try
                    {
                        ClientOrganization clientOrganization = _service.GetCurrentClientOrganization(ccwdata.NSCClientNum, organizationNameCode, userId, guid, directory);
                        foundNSCData = true;
                        ccwdata.NSCCarrierConditions   = clientOrganization.nscInformation.carrierStatus;
                        ccwdata.NSCCarrierName         = clientOrganization.displayName;
                        ccwdata.NSCCarrierSafetyRating = clientOrganization.nscInformation.safetyRating;
                    }
                    catch (AggregateException ae)
                    {
                        _logger.LogInformation("Aggregate Exception occured during GetCurrentClientOrganization");
                        ae.Handle((x) =>
                        {
                            if (x is FaultException <CVSECommonException> ) // From the web service.
                            {
                                _logger.LogDebug("CVSECommonException:");
                                FaultException <CVSECommonException> fault = (FaultException <CVSECommonException>)x;
                                _logger.LogDebug("errorId: {0}", fault.Detail.errorId);
                                _logger.LogDebug("errorMessage: {0}", fault.Detail.errorMessage);
                                _logger.LogDebug("systemError: {0}", fault.Detail.systemError);
                                return(true);
                            }
                            return(true); // ignore other exceptions
                        });
                    }
                    catch (Exception e)
                    {
                        _logger.LogInformation("Unknown Error retrieving NSC data.");
                    }

                    // now try the individual service if there was no match.

                    if (foundNSCData == false)
                    {
                        try
                        {
                            ClientIndividual clientIndividual = _service.GetCurrentClientIndividual(ccwdata.NSCClientNum, organizationNameCode, userId, guid, directory);
                            foundNSCData = true;
                            ccwdata.NSCCarrierConditions   = clientIndividual.nscInformation.carrierStatus;
                            ccwdata.NSCCarrierName         = clientIndividual.displayName;
                            ccwdata.NSCCarrierSafetyRating = clientIndividual.nscInformation.safetyRating;
                        }
                        catch (AggregateException ae)
                        {
                            _logger.LogInformation("Aggregate Exception occured during GetCurrentClientIndividual");
                            ae.Handle((x) =>
                            {
                                if (x is FaultException <CVSECommonException> ) // From the web service.
                                {
                                    _logger.LogDebug("CVSECommonException:");
                                    FaultException <CVSECommonException> fault = (FaultException <CVSECommonException>)x;
                                    _logger.LogDebug("errorId: {0}", fault.Detail.errorId);
                                    _logger.LogDebug("errorMessage: {0}", fault.Detail.errorMessage);
                                    _logger.LogDebug("systemError: {0}", fault.Detail.systemError);
                                    return(true);
                                }
                                return(true); // ignore other exceptions
                            });
                        }
                        catch (Exception e)
                        {
                            _logger.LogInformation("Unknown Error retrieving Individual NSC data.");
                        }
                    }
                }

                if (ccwdata.Id > 0)
                {
                    _context.Update(ccwdata);
                }
                else
                {
                    _context.Add(ccwdata);
                }
                _context.SaveChanges();


                return(new ObjectResult(ccwdata));
            }
        }
Beispiel #27
0
        public static AppraisalViewFormModel GetVehicleInfoFromChromeDecode(VehicleDescription vehicleInfo)
        {
            if (vehicleInfo == null)
            {
                return(null);
            }

            var appraisal = new AppraisalViewFormModel
            {
                VinDecodeSuccess = true,
                AppraisalDate    = DateTime.Now.ToShortDateString(),
                VinNumber        = vehicleInfo.vinDescription != null ? vehicleInfo.vinDescription.vin : string.Empty,
                AppraisalModel   = vehicleInfo.bestModelName,
                Make             = vehicleInfo.bestMakeName,
                Trim             = vehicleInfo.bestTrimName,
                SelectedModel    = vehicleInfo.bestModelName,
                //TODO: get Chrom Model ID
                ModelYear         = vehicleInfo.modelYear.ToString(),
                ExteriorColorList = SelectListHelper.InitalExteriorColorList(vehicleInfo.exteriorColor),
                InteriorColorList = SelectListHelper.InitalInteriorColorList(vehicleInfo.interiorColor)
            };

            if (vehicleInfo.style != null && vehicleInfo.style.Any())
            {
                Style firstStyle = vehicleInfo.style.FirstOrDefault();
                if (firstStyle != null)
                {
                    appraisal.Door           = firstStyle.passDoors.ToString();
                    appraisal.MSRP           = firstStyle.basePrice.msrp.ToString("C");
                    appraisal.DriveTrainList = SelectListHelper.InitalDriveTrainList(firstStyle.drivetrain.ToString());
                    bool existed;
                    appraisal.TrimList = SelectListHelper.InitalTrimList(appraisal, firstStyle.trim, vehicleInfo.style,
                                                                         firstStyle.id, out existed);
                    if (firstStyle.stockImage != null)
                    {
                        appraisal.DefaultImageUrl = firstStyle.stockImage.url;
                    }
                }
            }

            var chromeAutoService = new ChromeAutoService();
            List <ExtendedFactoryOptions> listPackageOptions      = chromeAutoService.GetPackageOptions(vehicleInfo);
            List <ExtendedFactoryOptions> listNonInstalledOptions = chromeAutoService.GetNonInstalledOptions(vehicleInfo);

            var builder = new StringBuilder();

            if (vehicleInfo.standard != null && vehicleInfo.standard.Any())
            {
                foreach (Standard fo in vehicleInfo.standard)
                {
                    builder.Append(fo.description + ",");
                }

                if (!String.IsNullOrEmpty(builder.ToString()))
                {
                    builder.Remove(builder.Length - 1, 1);
                }

                appraisal.StandardInstalledOption = builder.ToString();
            }

            appraisal.FactoryPackageOptions      = SelectListHelper.InitalFactoryPackagesOrOption(listPackageOptions);
            appraisal.FactoryNonInstalledOptions =
                SelectListHelper.InitalFactoryPackagesOrOption(listNonInstalledOptions);

            if (vehicleInfo.vinDescription != null && !String.IsNullOrEmpty(vehicleInfo.vinDescription.bodyType))
            {
                appraisal.BodyTypeList = SelectListHelper.InitialBodyTypeList(vehicleInfo.vinDescription.bodyType);
            }
            else
            {
                StyleBodyType[] bodyType = vehicleInfo.style.Last().bodyType;
                appraisal.BodyTypeList =
                    SelectListHelper.InitialBodyTypeList(vehicleInfo.style != null
                                                             ? (bodyType != null
                                                                    ? bodyType.Last().Value
                                                                    : vehicleInfo.bestStyleName)
                                                             : vehicleInfo.bestStyleName);
                if (appraisal.CylinderList == null)
                {
                    appraisal.CylinderList = new BindingList <SelectListItem>();
                }

                if (appraisal.LitersList == null)
                {
                    appraisal.LitersList = new BindingList <SelectListItem>();
                }

                if (appraisal.FuelList == null)
                {
                    appraisal.FuelList = new BindingList <SelectListItem>();
                }
            }

            if (vehicleInfo.engine != null)
            {
                appraisal.FuelList     = SelectListHelper.InitialFuelList(vehicleInfo.engine);
                appraisal.CylinderList = SelectListHelper.InitialCylinderList(vehicleInfo.engine);
                appraisal.LitersList   = SelectListHelper.InitialLitterList(vehicleInfo.engine);

                Engine firstEngine = vehicleInfo.engine.FirstOrDefault();
                if (firstEngine != null && firstEngine.fuelEconomy != null)
                {
                    appraisal.FuelEconomyCity    = firstEngine.fuelEconomy.city.low.ToString();
                    appraisal.FuelEconomyHighWay = firstEngine.fuelEconomy.hwy.low.ToString();
                }
            }

            if (vehicleInfo.vinDescription != null && vehicleInfo.vinDescription.marketClass != null)
            {
                if (
                    vehicleInfo.vinDescription.marketClass.Any(
                        tmp => tmp.Value.Contains("Truck") || tmp.Value.Contains("Cargo Vans")))
                {
                    appraisal.IsTruck = true;
                }
            }

            return(appraisal);
        }