| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 
 | FileManager file = new FileManager(filename);
            if (file.exist())
                try
                {
                    XElement document = file.getXmlContent();
                    TrackerInterface tracker = ((Main)this.MdiParent).globalConfig.getDriver(document.Element("model").Value,
                                                                                             document.Element("version").Value);
                    string checksum = document.Element("checksum").Value;
                    string date = document.Element("date").Value;
                    foreach (XElement family in document.Elements("family"))
                        foreach (XElement param in family.Elements("param"))
                            if (param.Attribute("id").Value.Equals("DEVICE_ID"))
                            {
                                string result = param.Value + date + "www.fr";
                                MD5 md5 = MD5.Create();
                                byte[] inputresult = System.Text.Encoding.ASCII.GetBytes(result);
                                byte[] hash = md5.ComputeHash(inputresult);
 
                                StringBuilder sb = new StringBuilder();
                                for (int i = 0; i < hash.Length; i++)
                                {
                                    sb.Append(hash[i].ToString());
                                }
                                if (checksum == sb.ToString())
                                {
                                    Perspective filePerspective = new Perspective();
                                    filePerspective.tracker = tracker;
                                    filePerspective.File = file;
                                    return filePerspective;
                                }
                                else
                               {
                                    throw new Exception(Lang.NotCompatibleFile);
                                }
                            }            
                }
                catch (Exception)
                {
                    MessageBox.Show(Lang.NotCompatibleFile);
                }
            return null; | 
Partager