Example #1
0
        public int Load()
        {
            int returnValue = 0;

            try
            {
                Console.WriteLine("Loading database ...");
                if (!File.Exists(dbPath))
                {
                    Console.WriteLine("Database file is missing, using an empty database.");
                    return(returnValue);
                }
                faceprintsArray = DatabaseSerializer.Deserialize(dbPath, out dbVersion);

                if (faceprintsArray.Count > 0)
                {
                    // check if version mismatch.
                    if (dbVersion != (faceprintsArray[0].Item1.version))
                    {
                        // will be handled respectively in MainWindow.xaml.cs.
                        returnValue = -1;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Failed loading database at path = {dbPath}. error = {e.Message}");
                Console.WriteLine("This may be due to change in DB Faceprints version, or some other error.");
                // will be handled respectively in MainWindow.xaml.cs.
                returnValue = -1;
            }

            return(returnValue);
        }
Example #2
0
 public void Save()
 {
     try
     {
         DatabaseSerializer.Serialize(FaceprintsArray, DbVersion, DbPath);
     }
     catch (Exception e)
     {
         Console.WriteLine($"Failed saving database at path = {DbPath}. error = {e.Message}");
     }
 }