コード例 #1
0
        public static void Initialise(SqliteConnection connection, SqliteConnection _conn)
        {
            bool shouldClose;

            (_conn, shouldClose) = SqliteManager.OpenConnection(connection);

            byte[] encryptedPassword = { };
            bool?  isInit            = null;

            using (var command = connection.CreateCommand())
            {
                // Create new command
                command.CommandText = "SELECT * FROM [System]";

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read() && isInit == null)
                    {
                        // Pull values back into class
                        encryptedPassword = (byte[])reader[1];
                        isInit            = (bool)reader[2];
                    }
                }
            }

            var password = EncryptionTool.Decrypt(encryptedPassword);

            if (isInit == true)
            {
                CheckPassword(connection, _conn, password);
            }
            else
            {
                NewPassword(connection, _conn);
            }

            _conn = SqliteManager.CloseConnection(shouldClose, connection);
        }
コード例 #2
0
        public RecordTableDataSource(SqliteConnection connection)
        {
            Records = new List <Record>();
            bool shouldClose;

            (_conn, shouldClose) = SqliteManager.OpenConnection(connection);

            // Execute query
            using (var command = connection.CreateCommand())
            {
                // Create new command
                command.CommandText = "SELECT * FROM [Data]";

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        // Pull values back into class
                        var ID       = (string)reader[0];
                        var website  = EncryptionTool.Decrypt((byte[])reader[1]);
                        var account  = EncryptionTool.Decrypt((byte[])reader[2]);
                        var password = EncryptionTool.Decrypt((byte[])reader[3]);
                        if (Records.Any(x => x.ID.ToString() == ID))
                        {
                            break;
                        }
                        else
                        {
                            Records.Add(new Record(website, account, password, connection, new Guid(ID), false));
                        }
                    }
                }
            }

            _conn = SqliteManager.CloseConnection(shouldClose, connection);
        }