public void Create(string adminName, string identification, string token)
{
if (Context.ReadOnly())
throw new DatabaseSystemException("Cannot create database in read-only mode.");
if (String.IsNullOrEmpty(adminName))
throw new ArgumentNullException("adminName");
if (String.IsNullOrEmpty(token))
throw new ArgumentNullException("token");
if (String.IsNullOrEmpty(identification))
throw new ArgumentNullException("identification");
try {
// Create the conglomerate
TableComposite.Create();
using (var session = this.CreateInitialSystemSession()) {
using (var query = session.CreateQuery()) {
try {
session.CurrentSchema(SystemSchema.Name);
OnDatabaseCreate(query);
query.CreateAdminUser(adminName, identification, token);
OnDatabaseCreated(query);
try {
// Close and commit this transaction.
session.Commit();
} catch (TransactionException e) {
throw new DatabaseSystemException("Could not commit the initial information", e);
}
} catch (DatabaseSystemException) {
throw;
} catch (Exception ex) {
throw new DatabaseSystemException("An error occurred while creating the database.", ex);
}
}
}
// Close the conglomerate.
TableComposite.Close();
} catch (DatabaseSystemException) {
throw;
} catch (Exception e) {
throw new DatabaseSystemException("An error occurred while creating the database.", e);
}
}