本文整理汇总了C#中Raven.Database.DocumentDatabase.Get方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentDatabase.Get方法的具体用法?C# DocumentDatabase.Get怎么用?C# DocumentDatabase.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Database.DocumentDatabase
的用法示例。
在下文中一共展示了DocumentDatabase.Get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AfterIncrementalBackupRestoreCanReadDocument
public void AfterIncrementalBackupRestoreCanReadDocument()
{
db.Put("ayende", null, RavenJObject.Parse("{'email':'[email protected]'}"), new RavenJObject(), null);
db.StartBackup(BackupDir, false, new DatabaseDocument());
WaitForBackup(db, true);
db.Put("itamar", null, RavenJObject.Parse("{'email':'[email protected]'}"), new RavenJObject(), null);
db.StartBackup(BackupDir, true, new DatabaseDocument());
WaitForBackup(db, true);
db.Dispose();
IOExtensions.DeleteDirectory(DataDir);
DocumentDatabase.Restore(new RavenConfiguration
{
Settings =
{
{"Raven/Esent/CircularLog", "false"}
}
}, BackupDir, DataDir, s => { });
db = new DocumentDatabase(new RavenConfiguration { DataDirectory = DataDir });
var jObject = db.Get("ayende", null).ToJson();
Assert.Equal("[email protected]", jObject.Value<string>("email"));
jObject = db.Get("itamar", null).ToJson();
Assert.Equal("[email protected]", jObject.Value<string>("email"));
}
示例2: Execute
public void Execute(DocumentDatabase database)
{
_database = database;
var configDoc = _database.Get(ClocksConfig.Id, null);
if (configDoc == null)
return;
var config = configDoc.DataAsJson.JsonDeserialization<ClocksConfig>();
Configure(config);
}
示例3: AfterBackupRestoreCanReadDocument
public void AfterBackupRestoreCanReadDocument()
{
db.Put("ayende", null, RavenJObject.Parse("{'email':'[email protected]'}"), new RavenJObject(), null);
db.StartBackup(BackupDir, false, new DatabaseDocument());
WaitForBackup(db, true);
db.Dispose();
IOExtensions.DeleteDirectory(DataDir);
DocumentDatabase.Restore(new RavenConfiguration(), BackupDir, DataDir, s => { }, defrag: true);
db = new DocumentDatabase(new RavenConfiguration {DataDirectory = DataDir});
var jObject = db.Get("ayende", null).ToJson();
Assert.Equal("[email protected]", jObject.Value<string>("email"));
}
示例4: AfterBackupRestoreCanReadDocument
public void AfterBackupRestoreCanReadDocument()
{
db.Put("ayende", null, JObject.Parse("{'email':'[email protected]'}"), new JObject(), null);
db.StartBackup("raven.db.test.backup");
WaitForBackup();
db.Dispose();
DeleteIfExists("raven.db.test.esent");
DocumentDatabase.Restore(new RavenConfiguration(), "raven.db.test.backup", "raven.db.test.esent");
db = new DocumentDatabase(new RavenConfiguration { DataDirectory = "raven.db.test.esent"});
var jObject = db.Get("ayende", null).ToJson();
Assert.Equal("[email protected]", jObject.Value<string>("email"));
}
示例5: Authenticate
public bool Authenticate(DocumentDatabase currentStore, string username, string password, out AccessTokenBody.DatabaseAccess[] allowedDatabases)
{
allowedDatabases = new AccessTokenBody.DatabaseAccess[0];
var jsonDocument = currentStore.Get("Raven/Users/" + username, null);
if (jsonDocument == null)
{
return false;
}
var user = jsonDocument.DataAsJson.JsonDeserialization<AuthenticationUser>();
var validatePassword = user.ValidatePassword(password);
if (!validatePassword)
return false;
var dbs = Enumerable.Empty<AccessTokenBody.DatabaseAccess>();
if (user.AllowedDatabases != null)
{
var accesses = user.AllowedDatabases.Select(tenantId => new AccessTokenBody.DatabaseAccess
{
TenantId = tenantId,
Admin = user.Admin,
ReadOnly = false
});
dbs = dbs.Concat(accesses);
}
if (user.Databases != null)
{
var accesses = user.Databases.Select(x => new AccessTokenBody.DatabaseAccess
{
Admin = user.Admin | x.Admin,
ReadOnly = x.ReadOnly,
TenantId = x.Name
});
dbs = dbs.Concat(accesses);
}
allowedDatabases = dbs.ToArray();
return true;
}
示例6: WaitForBackup
protected void WaitForBackup(DocumentDatabase db, bool checkError)
{
while (true)
{
var jsonDocument = db.Get(BackupStatus.RavenBackupStatusDocumentKey, null);
if (jsonDocument == null)
break;
var backupStatus = jsonDocument.DataAsJson.JsonDeserialization<BackupStatus>();
if (backupStatus.IsRunning == false)
{
if (checkError)
{
var firstOrDefault = backupStatus.Messages.FirstOrDefault(x => x.Severity == BackupStatus.BackupMessageSeverity.Error);
if (firstOrDefault != null)
Assert.False(true, firstOrDefault.Message);
}
return;
}
Thread.Sleep(50);
}
}
示例7: VerifyEncryptionKey
/// <summary>
/// Uses an encrypted document to verify that the encryption key is correct and decodes it to the right value.
/// </summary>
public static void VerifyEncryptionKey(DocumentDatabase database, EncryptionSettings settings)
{
JsonDocument doc;
try
{
doc = database.Get(Constants.InDatabaseKeyVerificationDocumentName, null);
}
catch (CryptographicException e)
{
throw new ConfigurationErrorsException("The database is encrypted with a different key and/or algorithm than the ones "
+ "currently in the configuration file.", e);
}
if (doc != null)
{
var ravenJTokenEqualityComparer = new RavenJTokenEqualityComparer();
if (!ravenJTokenEqualityComparer.Equals(doc.DataAsJson,Constants.InDatabaseKeyVerificationDocumentContents))
throw new ConfigurationErrorsException("The database is encrypted with a different key and/or algorithm than the ones "
+ "currently in the configuration file.");
}
else
{
// This is the first time the database is loaded.
if (EncryptedDocumentsExist(database))
throw new InvalidOperationException("The database already has existing documents, you cannot start using encryption now.");
database.Put(Constants.InDatabaseKeyVerificationDocumentName, null, Constants.InDatabaseKeyVerificationDocumentContents, new RavenJObject(), null);
}
}
示例8: WaitForBackup
protected void WaitForBackup(DocumentDatabase db, bool checkError)
{
WaitForBackup(key => db.Get(key, null), checkError);
}
示例9: AfterIncrementalBackupRestoreCanReadDocument
public void AfterIncrementalBackupRestoreCanReadDocument()
{
DeleteIfExists("raven.db.test.backup"); // for full backups, we can't have anything in the target dir
db.Put("ayende", null, RavenJObject.Parse("{'email':'[email protected]'}"), new RavenJObject(), null);
db.StartBackup("raven.db.test.backup", false);
WaitForBackup(true);
db.Put("itamar", null, RavenJObject.Parse("{'email':'[email protected]'}"), new RavenJObject(), null);
db.StartBackup("raven.db.test.backup", true);
WaitForBackup(true);
db.Dispose();
DeleteIfExists("raven.db.test.esent");
DocumentDatabase.Restore(new RavenConfiguration
{
Settings =
{
{"Raven/Esent/CircularLog", "false"}
}
}, "raven.db.test.backup", "raven.db.test.esent");
db = new DocumentDatabase(new RavenConfiguration { DataDirectory = "raven.db.test.esent" });
var jObject = db.Get("ayende", null).ToJson();
Assert.Equal("[email protected]", jObject.Value<string>("email"));
jObject = db.Get("itamar", null).ToJson();
Assert.Equal("[email protected]", jObject.Value<string>("email"));
}
示例10: WaitForBackup
protected void WaitForBackup(DocumentDatabase db, bool checkError)
{
var done = SpinWait.SpinUntil(() =>
{
var jsonDocument = db.Get(BackupStatus.RavenBackupStatusDocumentKey, null);
if (jsonDocument == null)
return true;
var backupStatus = jsonDocument.DataAsJson.JsonDeserialization<BackupStatus>();
if (backupStatus.IsRunning == false)
{
if (checkError)
{
var firstOrDefault =
backupStatus.Messages.FirstOrDefault(x => x.Severity == BackupStatus.BackupMessageSeverity.Error);
if (firstOrDefault != null)
Assert.False(true, firstOrDefault.Message);
}
return true;
}
return false;
}, TimeSpan.FromMinutes(15));
Assert.True(done);
}