public override Engine Recognize(VehicleCharacteristics characteristics) { Engine result = new Engine(); result.FuelType = FuelType.Diesel; result.InjectionType = InjectionType.Indirect; result.Family = Family; string engineModelValue = characteristics.GetEngineModelString(); string generalInfoValue = characteristics.GeneralVehicleInfo; if (engineModelValue.Contains("XUD7")) { RecognizeXud7(engineModelValue, result); } else if (engineModelValue.Contains("XUD9")) { RecognizeXud9(engineModelValue, generalInfoValue, result); } else if (engineModelValue.Contains("XUD11")) { RecognizeXud11(engineModelValue, result); } else { throw new NotSupportedException(engineModelValue); } return(result); }
public override Engine Recognize(VehicleCharacteristics characteristics) { Engine result = new Engine(); result.Family = Family; string engineModelValue = characteristics.GetEngineModelString(); //string generalInfoValue = characteristics.GeneralVehicleInfo; if (engineModelValue.ToUpper().Contains("M")) { result.Type = EngineType.EB2M; result.DisplayName = "EB2 M"; result.FuelType = FuelType.Petrol; result.InjectionType = InjectionType.Injector; } else if (engineModelValue.Contains("0")) { result.Type = EngineType.EB0; result.DisplayName = "EB0"; result.FuelType = FuelType.Petrol; result.InjectionType = InjectionType.Injector; } else { throw new NotSupportedException(engineModelValue); } return(result); }
public override Engine Recognize(VehicleCharacteristics characteristics) { Engine result = new Engine(); result.FuelType = FuelType.Petrol; result.InjectionType = InjectionType.Injector; result.Family = Family; string engineModelValue = characteristics.GetEngineModelString(); //string generalInfoValue = characteristics.GeneralVehicleInfo; if (engineModelValue.Contains("J4S")) { result.DisplayName = "ES9 J4S"; result.Type = EngineType.ES9J4S; } else if (engineModelValue.Contains("J4") || engineModelValue.Contains("L7X")) { result.DisplayName = "ES9 J4/L7X"; result.Type = EngineType.ES9J4L7X; } else if (engineModelValue.Contains("A")) { result.DisplayName = "ES9 IA"; result.Type = EngineType.ES9IA; } else { throw new NotSupportedException(engineModelValue); } return(result); }
ParseDocumentAndGetCharacteristics(HtmlDocument doc) { HtmlElementCollection tables = doc.GetElementsByTagName("table"); if (tables.Count < 4) { throw new OldVehicleNotSupportedException(vin); } HtmlElement table4 = tables[4]; HtmlElement table6 = tables[6]; VehicleCharacteristicsItemsGroup basicCharacteristicsGroup = ParseBasicCharacteristics(table4); VehicleCharacteristicsItemsGroup extendedCharacteristicsGroup = ParseExtendedCharacteristicsGroup(table6); if (basicCharacteristicsGroup.Items.Count == 1 || extendedCharacteristicsGroup.Items.Count == 1) { throw new VinDecodeException("No data for this vin"); } VehicleCharacteristics chars = new VehicleCharacteristics(vin); chars.Language = "ru_RU"; chars.GeneralVehicleInfo = String.Format("OPEL {0}, Engine {1}", basicCharacteristicsGroup.Items[0].Value, basicCharacteristicsGroup.Items[3].Value); chars.ItemsGroups.Add(basicCharacteristicsGroup); chars.ItemsGroups.Add(extendedCharacteristicsGroup); return(chars); }
public override Engine Recognize(VehicleCharacteristics characteristics) { Engine result = new Engine(); result.Family = Family; result.FuelType = FuelType.Diesel; result.InjectionType = InjectionType.Injector; string engineModelValue = characteristics.GetEngineModelString(); //string generalInfoValue = characteristics.GeneralVehicleInfo; if (engineModelValue.Contains("ATE")) { result.Type = EngineType.DK5ATE; result.DisplayName = "DK5 ATE"; } else if (engineModelValue.Contains("5")) { result.Type = EngineType.DK5; result.DisplayName = "DK5"; } else { throw new NotSupportedException(engineModelValue); } return(result); }
private void GetCharacteristicsInBackground(object sender, DoWorkEventArgs doWorkEventArgs) { Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = info; string vin = (string)doWorkEventArgs.Argument; VehicleCharacteristics chars = VehicleCharacteristicsCache.Get(vin); doWorkEventArgs.Result = chars; }
public PsaEngineFamilyRecognizer( VehicleCharacteristics characteristics) { if (characteristics == null) { throw new ArgumentNullException("characteristics"); } this.characteristics = characteristics; }
public PsaEngineRecognizer( VehicleCharacteristics vehicleCharacteristics) { if (vehicleCharacteristics == null) { throw new ArgumentNullException("vehicleCharacteristics"); } this.vehicleCharacteristics = vehicleCharacteristics; }
private VehicleInformation GetVehicleInformation(string vin) { VehicleCharacteristicsManager manager = new VehicleCharacteristicsManager(); VehicleCharacteristics chars = manager. GetVehicleCharacteristicsForVin(vin, SupportedLanguage.English); VehicleInfoRecognizer recognizer = new VehicleInfoRecognizer(vin, chars); VehicleInformation vehicleInformation = recognizer.Recognize(); return(vehicleInformation); }
public static VehicleCharacteristics Assemble(VehicleCharacteristicsDto dto) { VehicleCharacteristics result = new VehicleCharacteristics(); result.GeneralVehicleInfo = dto.GeneralVehicleInfo; result.Language = dto.Language; foreach (VehicleCharacteristicsItemsGroupDto group in dto.ItemGroups) { result.ItemsGroups.Add(VehicleItemsGroupDtoAssembler.Assemble(group)); } return(result); }
public VehicleCharacteristics Parse() { VehicleCharacteristics result = new VehicleCharacteristics(vin); result.Language = lang; HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(rawPage); result.GeneralVehicleInfo = GetGeneralVehicleInfo(doc); ProcessInfoZone(doc.DocumentNode. SelectSingleNode(InfoZonePath), result); return(result); }
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; }
public VehicleCharacteristicsViewModel( VehicleCharacteristics model) { if (model == null) { throw new ArgumentNullException("model"); } this.model = model; foreach (VehicleCharacteristicsItemsGroup group in model.ItemsGroups) { groups.Add(new VehicleCharacteristicsItemsGroupViewModel(group)); } }
public static string GetVehicleModelString( this VehicleCharacteristics chars) { string key = LocalizedCharacteristicsStrings. ResolveVehicleModelKey(chars); /*string groupKey = LocalizedCharacteristicsStrings. * ResolveVehicleModelGroupKey(chars.Language);*/ string groupKey = chars.GeneralVehicleInfo; VehicleCharacteristicsItemsGroup characteristicsGroup = chars. ItemsGroups.FirstOrDefault(g => g.Name.ToUpper().Contains(groupKey.ToUpper())); return(characteristicsGroup.GetValueByKey(key)); }
private void ParseGeneralInfoTable(HtmlNode tableNode, VehicleCharacteristics result) { //HtmlNode tbody = tableNode.SelectSingleNode("./tbody"); VehicleCharacteristicsItemsGroup itemsGroup = new VehicleCharacteristicsItemsGroup(); itemsGroup.Name = result.GeneralVehicleInfo; // TODO : Get translation for "general info" foreach (HtmlNode node in tableNode.SelectNodes("./tr")) { ParseGeneralInfoItemItemNode(node, itemsGroup); } result.ItemsGroups.Add(itemsGroup); }
public static VehicleCharacteristics FromDtoToDomainObject(VehicleCharacteristicsDto source) { VehicleCharacteristics target = new VehicleCharacteristics(); target.Id = source.Id; target.GeneralVehicleInfo = source.GeneralVehicleInfo; target.Vin = source.Vin; target.Language = source.Language; foreach (VehicleCharacteristicsItemsGroupDto group in source.ItemGroups) { target.ItemsGroups.Add(VehicleCharacteristicsItemsGroupAssembler. FromDtoToDomainObject(group)); } return(target); }
public static VehicleCharacteristicsEntity FromDomainObjectToEntity( VehicleCharacteristics source) { VehicleCharacteristicsEntity target = new VehicleCharacteristicsEntity(); target.Id = source.Id; target.GeneralVehicleInfo = source.GeneralVehicleInfo; target.Vin = source.Vin; target.Language = source.Language; foreach (VehicleCharacteristicsItemsGroup group in source.ItemsGroups) { target.VehicleCharacteristicsItemGroup.Add( VehicleItemsGroupAssembler.FromDomainObjectToEntity(group)); } return(target); }
public static string ResolveVehicleModelKey(VehicleCharacteristics c) { if (c.Language == "en_GB") { return(VehicleModelEn); } else if (c.Language == "ru_RU") { throw new NotSupportedException(); /*return VehicleModelRuCitroen; * return VehicleModelRuPeugeot;*/ } else { throw new NotSupportedException(); } }
private void ParseUsualTable(HtmlNode tableNode, VehicleCharacteristics result) { VehicleCharacteristicsItemsGroup group = new VehicleCharacteristicsItemsGroup(); HtmlNodeCollection trNodes = tableNode.SelectNodes("./tr"); HtmlNodeCollection tds = trNodes[0].SelectNodes("./td"); group.Name = Strip(tds[0].InnerText); HtmlNode subTable = trNodes[1].SelectSingleNode("./td/table"); HtmlNodeCollection itemTrNodes = subTable.SelectNodes("./tr"); for (int i = 1; i < itemTrNodes.Count; i++) { ParseUsualItemNode(itemTrNodes[i], group); } result.ItemsGroups.Add(group); }
public int Recognize(VehicleCharacteristics characteristics) { string itemName = LocalizedCharacteristicsStrings.ResolveProductionDateKey(characteristics.Language); VehicleCharacteristicsItemsGroup group = characteristics.ItemsGroups.FirstOrDefault(ig => ig.Name.Equals(characteristics.GeneralVehicleInfo, StringComparison.InvariantCultureIgnoreCase)); VehicleCharacteristicsItem item = group.Items.FirstOrDefault(i => i.Name.Equals(itemName, StringComparison.InvariantCultureIgnoreCase)); string date = DateTime.Today.ToShortDateString(); if (item != null) { date = item.Value; } string[] split = date.Split('/'); return(Int32.Parse(split[2])); }
private void ProcessInfoZone(HtmlNode infoZone, VehicleCharacteristics result) { if (infoZone == null) { return; // most likely incorrect vin! // let's check it! /*if (rawPage.Contains(@"<p class=""alert"">")) * { * return; * }*/ } HtmlNodeCollection tables = infoZone.SelectNodes("./table"); foreach (HtmlNode tableNode in tables) { ParseTable(tableNode, result); } }
public static string GetEngineFamilyString( this VehicleCharacteristics chars) { string generalInformationGroupName = LocalizedCharacteristicsStrings. ResolveGeneralInformationGroupName(chars.Language); VehicleCharacteristicsItemsGroup generalInformationGroup = chars.ItemsGroups.FirstOrDefault( g => g.Name.Contains(generalInformationGroupName)); if (generalInformationGroup == null) { throw new NoInfoForVinException("Insufficient characteristics data"); } string engineFamilyString = generalInformationGroup.GetValueByKey( LocalizedCharacteristicsStrings. ResolveEngineFamilyKey(chars.Language)); return(engineFamilyString); }
private void ParseTable(HtmlNode tableNode, VehicleCharacteristics result) { if (tableNode.Attributes.Contains("class") && tableNode.Attributes["class"].Value.Contains("table_lst_doc")) { ParseGeneralInfoTable(tableNode, result); } else { try { ParseUsualTable(tableNode, result); } catch (NullReferenceException) { // Table could not be parsed // TODO : log it? } } }
public override Engine Recognize(VehicleCharacteristics characteristics) { Engine result = new Engine(); result.Family = Family; result.FuelType = FuelType.Unknown; result.InjectionType = InjectionType.Injector; string engineModelValue = characteristics.GetEngineModelString(); //string generalInfoValue = characteristics.GeneralVehicleInfo; if (engineModelValue.ToUpper().Contains("MMC") && engineModelValue.ToUpper().Contains("2.4L")) { result.Type = EngineType.MMC24; result.DisplayName = "Mitsubishi 2.4L"; } else { throw new NotSupportedException(engineModelValue); } return(result); }
public VehicleCharacteristicsViewModel( Vehicle vehicle, VehicleCharacteristics characteristics) { if (vehicle == null) { throw new ArgumentNullException("vehicle"); } if (characteristics == null) { throw new ArgumentNullException("characteristics"); } this.vehicle = vehicle; this.characteristics = characteristics; // fill direct items collection foreach (VehicleCharacteristicsItemsGroup group in characteristics.ItemsGroups) { foreach (VehicleCharacteristicsItem item in group.Items) { baseCollection.Add( new VehicleCharacteristicsItemViewModel(item)); } } items = new PagedCollectionView(baseCollection); items.GroupDescriptions.Clear(); items.GroupDescriptions.Add( new PropertyGroupDescription("Group")); // fill groups collection foreach (VehicleCharacteristicsItemsGroup group in characteristics.ItemsGroups) { groups.Add( new VehicleCharacteristicsItemsGroupViewModel(group)); } }
private void OnCharacteristicsRetrieved(object sender, RunWorkerCompletedEventArgs e) { characteristicsGetterWorker.DoWork -= GetCharacteristicsInBackground; characteristicsGetterWorker.RunWorkerCompleted -= OnCharacteristicsRetrieved; if (e.Cancelled) { contentControlVehicleCharacteristics.Content = null; return; } VehicleCharacteristics chars = e.Result as VehicleCharacteristics; if (chars == null) { contentControlVehicleCharacteristics.Content = CodeBehindStringResolver.Resolve("CanNotGetVehicleCharacteristics"); return; } VehicleCharacteristicsViewModel vm = new VehicleCharacteristicsViewModel(chars); VehicleCharacteristicsControl control = new VehicleCharacteristicsControl(vm); contentControlVehicleCharacteristics.Content = control; }
public override Engine Recognize( VehicleCharacteristics characteristics) { Engine result = new Engine(); result.Family = Family; result.FuelType = FuelType.Petrol; result.InjectionType = InjectionType.Injector; string engineModelValue = characteristics.GetEngineModelString(); string generalInfoValue = characteristics.GeneralVehicleInfo; if (engineModelValue.Contains("XU5")) { RecognizeXu5(engineModelValue, result); } else if (engineModelValue.Contains("XU7")) { RecognizeXu7(engineModelValue, result); } else if (engineModelValue.Contains("XU8")) { RecognizeXu8(engineModelValue, result); } else if (engineModelValue.Contains("XU9")) { RecognizeXu9(engineModelValue, generalInfoValue, result); } else if (engineModelValue.Contains("XU10")) { RecognizeXu10(engineModelValue, generalInfoValue, result); } else { throw new NotSupportedException(engineModelValue); } return(result); }
void OnDocumentCompleted2(object sender, WebBrowserDocumentCompletedEventArgs e) { WebBrowser br = sender as WebBrowser; document = br.Document; try { VehicleCharacteristics characteristics = ParseDocumentAndGetCharacteristics(document); if (characteristics != null) { result = characteristics; } else { error = new Exception("No chars retrieved."); } } catch (Exception ex) { error = ex; } Application.ExitThread(); }
public static VehicleCharacteristics Get(string vin) { SupportedLanguage currentLang = TranslationManager.Instance.CurrentLanguageEnum; string vinU = vin.ToUpper(); if (cache.ContainsKey(vinU) && cache[vinU].ContainsKey(currentLang)) { return cache[vinU][currentLang]; } else { VtsWebServiceClient client = new VtsWebServiceClient(); try { VehicleCharacteristicsDto resultDto = client.GetVehicleCharacteristics(vinU, (int)TranslationManager.Instance.CurrentLanguageEnum); VehicleCharacteristics result = VehicleCharacteristicsAssembler.FromDtoToDomainObject(resultDto); if (result == null) { return null; } if (!cache.ContainsKey(vinU)) { cache[vinU] = new Dictionary<SupportedLanguage, VehicleCharacteristics>(); } cache[vinU][currentLang] = result; return cache[vinU][currentLang]; } catch (Exception e) { Log.Error(e, CodeBehindStringResolver.Resolve("CouldNotGetVehicleCharacteristicsMessage")); return null; } } }
public override Engine Recognize(VehicleCharacteristics characteristics) { Engine result = new Engine(); result.Family = Family; string engineModelValue = characteristics.GetEngineModelString(); string generalInfoValue = characteristics.GeneralVehicleInfo; if (Ew7J4(engineModelValue)) { result.Type = EngineType.EW7J4; } else if (engineModelValue.ToUpper().Contains("EW") && engineModelValue.ToUpper().Contains("7A")) { result.Type = EngineType.EW7A; } else if (Ew10D(engineModelValue)) { result.Type = EngineType.EW10D; } else if (Ew10J4Rfn(engineModelValue, generalInfoValue)) { result.Type = EngineType.EW10J4RFN; } else if (Ew10J4Rfr(engineModelValue, generalInfoValue)) { result.Type = EngineType.EW10J4RFR; } else if (Ew10J4S(engineModelValue)) { result.Type = EngineType.EW10J4S; } else if (Ew10A(engineModelValue)) { result.Type = EngineType.EW10A; } else if (Ew12J4(engineModelValue)) { result.Type = EngineType.EW12J4; } else if (Dw8B(engineModelValue)) { result.Type = EngineType.DW8B; } else if (Dw8(engineModelValue)) { result.Type = EngineType.DW8; } else if (Dw10Ated4(engineModelValue)) { // FIRST BEFORE ATED!! result.Type = EngineType.DW10ATED4; } else if (Dw10Ated(engineModelValue)) { result.Type = EngineType.DW10ATED; } else if (Dw10Td(engineModelValue)) { result.Type = EngineType.DW10TD; } else if (Dw10Bted4(engineModelValue)) { result.Type = EngineType.DW10BTED4; } else if (engineModelValue.ToUpper().Contains("BTED")) { result.Type = EngineType.DW10BTED; result.DisplayName = "DW10 BTED"; result.InjectionType = InjectionType.CommonRail; result.FuelType = FuelType.Diesel; } else if (engineModelValue.Contains("CTED4")) { result.Type = EngineType.DW10CTED4; result.DisplayName = "DW10 CTED4"; } else if (Dw12Uted(engineModelValue)) { result.Type = EngineType.DW12UTED; } else if (Dw12Mted4(engineModelValue)) { result.Type = EngineType.DW12MTED4; } else if (Dw12Ted4(engineModelValue)) { result.Type = EngineType.DW12TED4; } else if (engineModelValue.Contains("DW12C")) { result.Type = EngineType.DW12C; result.FuelType = FuelType.Diesel; result.InjectionType = InjectionType.CommonRail; } else { throw new NotSupportedException(engineModelValue); } UpdateEngineDetails(result); return(result); }