public static PsaTrace Convert(LexiaGraphSessionRawData data)
        {
            if (data == null)
            {
                Log.Warn("Got null data into converter");
                return(null);
            }
            PsaTrace result = new PsaTrace();

            result.Manufacturer = Manufacturer.Citroen;
            if (data.SessionInformation != null)
            {
                result.Vin = data.SessionInformation.Summary.Split(' ')[0];
                string datetime = String.Format("{0} {1}",
                                                data.SessionInformation.Date,
                                                data.SessionInformation.Time);
                result.Date = DateTime.ParseExact(datetime,
                                                  dateTimeFormat, CultureInfo.InvariantCulture);
                if (data.SessionInformation.Vehicle.Contains("@"))
                {
                    result.VehicleModelName =
                        KnownVehicleNames.Get(data.SessionInformation.Vehicle);
                }
                else
                {
                    result.VehicleModelName = data.SessionInformation.Vehicle;
                }
            }
            result.Mileage = data.Mileage;
            PsaParametersSet set = GenerateParametersSet(data.Channels);

            set.EcuName  = data.DataHeader.EcuName;
            set.EcuLabel = data.DataHeader.EcuLabel;
            result.ParametersSets.Add(set);
            return(result);
        }
        public string Get()
        {
            // Plan A: search the xml
            using (FileStream stream = new FileStream(
                       traceFile.FullName, FileMode.Open))
            {
                XDocument xDoc = XDocument.Load(stream);
                IEnumerable <XElement> chapter1s = xDoc.Root.Elements(chapitre)
                                                   .Where(e => e.Attribute(code).Value == oo2);
                foreach (XElement ch1 in chapter1s)
                {
                    XElement veh = ch1.Element(vehicule);
                    if (veh != null)
                    {
                        XElement phr = veh.Element(phrase);
                        if (phr != null)
                        {
                            //XElement pra = phr.Element(phrasethesau);
                            string res = phr.Element(phrasethesau).Value;
                            if (!String.IsNullOrEmpty(res))
                            {
                                if (KnownVehicleNames.Knows(res))
                                {
                                    return(KnownVehicleNames.Get(res));
                                }
                            }
                        }
                    }
                }
            }

            // Plan B: no data in xml, let's search the txt
            DirectoryInfo dir      = traceFile.Directory;
            string        fileMask = traceFile.Name.
                                     Remove(traceFile.Name.Length - 4);
            string fileMask2 = String.Format("{0}*{1}", fileMask, txt);

            foreach (FileInfo file in dir.EnumerateFiles(fileMask2))
            {
                string s = String.Empty;
                using (StreamReader rdr = new StreamReader(file.FullName))
                {
                    while (s != null &&
                           !s.Contains(vehicleModel) &&
                           !(s.Contains(famille) && s.Contains(hicule)) &&
                           !rdr.EndOfStream)
                    {
                        s = rdr.ReadLine();
                    }
                    string vehLine = rdr.ReadLine();
                    if (!String.IsNullOrEmpty(vehLine))
                    {
                        string[] arr = vehLine.Trim(' ').Split(' ');
                        if (arr != null && arr.Length == 2)
                        {
                            if (!String.IsNullOrEmpty(arr[1]))
                            {
                                return(arr[1]);
                            }
                        }
                    }
                }
            }
            return(String.Empty);
        }