private string RecognizeVehicleModel() { IVehicleModelRecognizer recognizer = VehicleModelRecognizerFactory. Create(VinChecker.GetManufacturer(vin)); return(recognizer.Recognize(characteristics)); }
public VehicleCharacteristics Get() { Manufacturer?manufacturer = VinChecker.GetManufacturer(vin); if (manufacturer == null) { return(null); } ManufacturerWebConnectorFactory factory = new ManufacturerWebConnectorFactory(DefaultLang); IManufacturerWebConnector connector = factory.GetConnector(manufacturer.Value); VehicleCharacteristics result; try { connector.Connect(); result = connector.Retrieve(vin); connector.Disconnect(); } catch (Exception) { // TODO : Message about xception return(null); } return(result); }
private int RecognizeProductionYear() { IVehicleProductionYearRecognizer rec = VehicleProductionYearRecognizerFactory.Create(VinChecker.GetManufacturer(vin)); return(rec.Recognize(characteristics)); }
private void RetrieveAndPersistAllLanguagesForThisVin(string vin) { List <string> requiredNativeLangCodes = new List <string>(); foreach (SupportedLanguage value in Enum.GetValues(typeof(SupportedLanguage))) { CharacteristicsLanguageMapper mapper = new CharacteristicsLanguageMapper( VinChecker.GetManufacturer(vin)); string nativeLangValue = mapper.GetSpecificCode(value); if (!requiredNativeLangCodes.Contains(nativeLangValue)) { requiredNativeLangCodes.Add(nativeLangValue); } } foreach (string code in requiredNativeLangCodes) { IVendorCharacteristicsProvider provider = VendorCharacteristicsProviderFactory.Create( VinChecker.GetManufacturer(vin)); VehicleCharacteristics chars = provider.GetByVin(vin, code); PersistVehicleCharacteristics(chars); } }
public VehicleCharacteristics GetVehicleCharacteristicsForVin( string vin, SupportedLanguage preferredLanguage) { CharacteristicsLanguageMapper mapper = new CharacteristicsLanguageMapper( VinChecker.GetManufacturer(vin)); string langCode = mapper.GetSpecificCode(preferredLanguage); // 1. check our database VehicleCharacteristics charsFromDatabase = GetExactMatchFromDatabase(vin, langCode); if (charsFromDatabase != null) { return(charsFromDatabase); } // 2. Do we have anything at all for this vin? bool haveAnything = DoWeHaveAnythingForThisVin(vin); if (haveAnything) { RetrieveAndPersistAllLangsWeDoNotHaveYetForThisVin(vin); } else { RetrieveAndPersistAllLanguagesForThisVin(vin); } // 3. Get best match return(GetBestMatchFromOurDatabase(vin, langCode)); }
public EngineRecognizerFactory( string vin, VehicleCharacteristics characteristics) { Manufacturer?man1 = VinChecker.GetManufacturer(vin); if (man1 == null) { throw new Exception("Manufacturer not recognized"); } man = man1.Value; this.characteristics = characteristics; }
private bool IsVinKnownAndValid(string vinToCheck) { if (String.IsNullOrWhiteSpace(vinToCheck) || vinToCheck.Length != 17) { return(false); } try { VinChecker.GetManufacturer(vinToCheck); } catch (NotSupportedException) { return(false); } return(true); }
private void RetrieveAndPersistAllLangsWeDoNotHaveYetForThisVin(string vin) { IList <SupportedLanguage> langsWeLackForThisVin = GetLangsWeDoNotHaveForVin(vin); foreach (SupportedLanguage language in langsWeLackForThisVin) { IVendorCharacteristicsProvider provider = VendorCharacteristicsProviderFactory.Create( VinChecker.GetManufacturer(vin)); CharacteristicsLanguageMapper mapper = new CharacteristicsLanguageMapper(VinChecker.GetManufacturer(vin)); VehicleCharacteristics chars = provider.GetByVin(vin, mapper.GetSpecificCode(language)); PersistVehicleCharacteristics(chars); } }
private List <SupportedLanguage> GetLangsWeDoNotHaveForVin(string vin) { using (VTSDatabase database = new VTSDatabase()) { List <SupportedLanguage> result = new List <SupportedLanguage>(); foreach (SupportedLanguage value in Enum.GetValues(typeof(SupportedLanguage))) { CharacteristicsLanguageMapper mapper = new CharacteristicsLanguageMapper(VinChecker.GetManufacturer(vin)); string langValue = mapper.GetSpecificCode(value); if (!database.VehicleCharacteristics.Any(vc => vc.Vin == vin && vc.Language == langValue)) { if (!result.Contains(value)) { result.Add(value); } } } return(result); } }