本文整理汇总了C#中Raven.Abstractions.Data.DatabaseDocument类的典型用法代码示例。如果您正苦于以下问题:C# DatabaseDocument类的具体用法?C# DatabaseDocument怎么用?C# DatabaseDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseDocument类属于Raven.Abstractions.Data命名空间,在下文中一共展示了DatabaseDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BackupOperation
public BackupOperation(DocumentDatabase database, string backupSourceDirectory, string backupDestinationDirectory, bool incrementalBackup,
DatabaseDocument databaseDocument)
: base(database, backupSourceDirectory, backupDestinationDirectory, incrementalBackup, databaseDocument)
{
instance = ((TransactionalStorage) database.TransactionalStorage).Instance;
backupConfigPath = Path.Combine(backupDestinationDirectory, "RavenDB.Backup");
}
示例2: ReadSettingAsInt
private static int ReadSettingAsInt(DatabaseDocument document, string settingName)
{
var value = 0;
if (document.Settings.ContainsKey(settingName))
int.TryParse(document.Settings[settingName], out value);
return value;
}
示例3: Execute
public async Task Execute(string[] args)
{
var documentStore = new DocumentStore
{
Url = uri.ToString(),
}
.Initialize();
var client = new RavenFileSystemClient(uri.ToString(), filesystem);
Console.WriteLine("=== Available File Systems ===");
bool doesFileSystemExists = false;
foreach (string name in await client.Admin.GetFileSystemsNames())
{
Console.WriteLine(name);
doesFileSystemExists |= name.ToLower() == filesystem;
}
if (!doesFileSystemExists)
{
var filesystemDocument = new DatabaseDocument() { Id = "Raven/FileSystems/" + filesystem };
filesystemDocument.Settings["Raven/FileSystem/DataDir"] = Path.Combine(filesystemLocation, filesystem);
await client.Admin.CreateFileSystemAsync(filesystemDocument, filesystem);
}
Console.WriteLine();
foreach ( var file in directory.GetFiles())
{
await client.UploadAsync(file.Name, file.OpenRead());
}
}
示例4: LoadFor
public override void LoadFor(DatabaseDocument document)
{
var session = ApplicationModel.Current.Server.Value.DocumentStore
.OpenAsyncSession(ApplicationModel.Current.Server.Value.SelectedDatabase.Value.Name);
if (document.Settings.ContainsKey("Raven/AWSAccessKey") && document.SecuredSettings.ContainsKey("Raven/AWSSecretKey"))
{
AwsAccessKey = document.Settings["Raven/AWSAccessKey"];
AwsSecretKey = document.SecuredSettings["Raven/AWSSecretKey"];
}
if (document.Settings.ContainsKey("Raven/AzureStorageAccount") && document.SecuredSettings.ContainsKey("Raven/AzureStorageKey"))
{
AzureStorageAccount = document.Settings["Raven/AzureStorageAccount"];
AzureStorageKey = document.SecuredSettings["Raven/AzureStorageKey"];
}
session.LoadAsync<PeriodicBackupSetup>(PeriodicBackupSetup.RavenDocumentKey).ContinueWith(task =>
{
PeriodicBackupSetup = task.Result;
if (PeriodicBackupSetup == null)
return;
HasDocument = true;
if (string.IsNullOrWhiteSpace(PeriodicBackupSetup.LocalFolderName) == false)
SelectedOption.Value = 0;
else if (string.IsNullOrWhiteSpace(PeriodicBackupSetup.GlacierVaultName) == false)
SelectedOption.Value = 1;
else if (string.IsNullOrWhiteSpace(PeriodicBackupSetup.S3BucketName) == false)
SelectedOption.Value = 2;
else if (string.IsNullOrWhiteSpace(PeriodicBackupSetup.AzureStorageContainer) == false)
SelectedOption.Value = 3;
OnPropertyChanged(() => HasDocument);
OnPropertyChanged(() => PeriodicBackupSetup);
});
}
示例5: CreateDatabaseAsync
public Task CreateDatabaseAsync(DatabaseDocument databaseDocument)
{
RavenJObject doc;
var req = adminRequest.CreateDatabase(databaseDocument, out doc);
return req.WriteAsync(doc.ToString(Formatting.Indented));
}
示例6: DatabasesGet
public HttpResponseMessage DatabasesGet(string id)
{
if (IsSystemDatabase(id))
{
//fetch fake (empty) system database document
var systemDatabaseDocument = new DatabaseDocument { Id = Constants.SystemDatabase };
return GetMessageWithObject(systemDatabaseDocument);
}
var docKey = "Raven/Databases/" + id;
var document = Database.Documents.Get(docKey, null);
if (document == null)
return GetMessageWithString("Database " + id + " not found", HttpStatusCode.NotFound);
var dbDoc = document.DataAsJson.JsonDeserialization<DatabaseDocument>();
dbDoc.Id = id;
DatabasesLandlord.Unprotect(dbDoc);
string activeBundles;
if (dbDoc.Settings.TryGetValue(Constants.ActiveBundles, out activeBundles))
dbDoc.Settings[Constants.ActiveBundles] = BundlesHelper.ProcessActiveBundles(activeBundles);
return GetMessageWithObject(dbDoc, HttpStatusCode.OK, document.Etag);
}
示例7: CanRestoreAnEncryptedDatabase
public async Task CanRestoreAnEncryptedDatabase(string storageEngineTypeName)
{
IOExtensions.DeleteDirectory(@"~\Databases\Db1".ToFullPath());
IOExtensions.DeleteDirectory(@"~\Databases\Db2".ToFullPath());
using (var store = NewRemoteDocumentStore(requestedStorage: storageEngineTypeName, runInMemory: false))
{
var db1 = new DatabaseDocument
{
Id = "Db1",
Settings = new Dictionary<string, string> {{"Raven/DataDir", @"~\Databases\Db1"}},
SecuredSettings = new Dictionary<string, string>
{
{"Raven/Encryption/Key", "arHd5ENxwieUCAGkf4Rns8oPWx3f6npDgAowtIAPox0="},
{"Raven/Encryption/Algorithm", "System.Security.Cryptography.DESCryptoServiceProvider, mscorlib"},
{"Raven/Encryption/EncryptIndexes", "True"}
},
};
await store.AsyncDatabaseCommands.GlobalAdmin.CreateDatabaseAsync(db1);
using (var session = store.OpenAsyncSession("Db1"))
{
await session.StoreAsync(new User
{
Id = "users/1",
Username = "fitzchak"
});
await session.SaveChangesAsync();
}
var backupFolderDb1 = NewDataPath("BackupFolderDb1");
await store.AsyncDatabaseCommands.ForDatabase("Db1").GlobalAdmin.StartBackupAsync(backupFolderDb1, db1,false ,"Db1");
WaitForBackup(store.DatabaseCommands.ForDatabase("Db1"), true);
await store.AsyncDatabaseCommands.GlobalAdmin.StartRestoreAsync(new DatabaseRestoreRequest
{
BackupLocation = backupFolderDb1,
DatabaseLocation = @"~\Databases\Db2",
DatabaseName = "Db2"
});
WaitForRestore(store.DatabaseCommands.ForSystemDatabase());
WaitForDocument(store.DatabaseCommands.ForSystemDatabase(), "Raven/Databases/Db2");
using (var session = store.OpenAsyncSession(Constants.SystemDatabase))
{
var db2Settings = await session.LoadAsync<DatabaseDocument>("Raven/Databases/Db2");
Assert.NotEqual(db1.SecuredSettings["Raven/Encryption/Key"], db2Settings.SecuredSettings["Raven/Encryption/Key"]);
Assert.NotEqual(db1.SecuredSettings["Raven/Encryption/Algorithm"], db2Settings.SecuredSettings["Raven/Encryption/Algorithm"]);
Assert.NotEqual(db1.SecuredSettings["Raven/Encryption/EncryptIndexes"], db2Settings.SecuredSettings["Raven/Encryption/EncryptIndexes"]);
}
using (var session = store.OpenAsyncSession("Db2"))
{
var user = await session.LoadAsync<User>("users/1");
Assert.NotNull(user);
Assert.Equal("fitzchak", user.Username);
}
}
}
示例8: CreateDatabaseAsync
public async Task CreateDatabaseAsync(DatabaseDocument databaseDocument)
{
RavenJObject doc;
using (var req = adminRequest.CreateDatabase(databaseDocument, out doc))
{
await req.WriteAsync(doc.ToString(Formatting.Indented)).ConfigureAwait(false);
}
}
示例9: BackupOperation
public BackupOperation(DocumentDatabase database, IPersistentSource persistentSource, string src, string to, DatabaseDocument databaseDocument)
{
this.database = database;
this.persistentSource = persistentSource;
this.src = src;
this.to = to;
this.databaseDocument = databaseDocument;
}
示例10: Serialize
private string Serialize(DatabaseDocument document)
{
using (var streamWriter = new StringWriter())
{
serializer.Serialize(streamWriter, document);
return streamWriter.ToString();
}
}
示例11: CreateDatabaseAsync
public async Task CreateDatabaseAsync(DatabaseDocument databaseDocument, CancellationToken token = default (CancellationToken))
{
RavenJObject doc;
using (var req = adminRequest.CreateDatabase(databaseDocument, out doc))
{
await req.WriteAsync(doc.ToString(Formatting.Indented)).WithCancellation(token).ConfigureAwait(false);
}
}
示例12: BackupOperation
public BackupOperation(DocumentDatabase database, string src, string to, bool incrementalBackup, DatabaseDocument databaseDocument)
{
instance = ((TransactionalStorage)database.TransactionalStorage).Instance;
this.src = src;
this.to = to;
this.incrementalBackup = incrementalBackup;
this.databaseDocument = databaseDocument;
this.database = database;
}
示例13: BackupOperation
public BackupOperation(DocumentDatabase database, string backupSourceDirectory,
string backupDestinationDirectory, StorageEnvironment env, bool incrementalBackup,
DatabaseDocument databaseDocument)
: base(database, backupSourceDirectory, backupDestinationDirectory, incrementalBackup, databaseDocument)
{
if (env == null) throw new ArgumentNullException("env");
this.env = env;
}
示例14: StartBackup
public HttpJsonRequest StartBackup(string backupLocation, DatabaseDocument databaseDocument, string databaseName, bool incremental)
{
if (databaseName == Constants.SystemDatabase)
{
return createRequestForSystemDatabase("/admin/backup", "POST");
}
return createRequestForSystemDatabase("/databases/" + databaseName + "/admin/backup?incremental=" + incremental, "POST");
}
示例15: LoadFor
public override void LoadFor(DatabaseDocument document)
{
MaxSize = ReadSettingAsInt(document, Constants.SizeHardLimitInKB) / 1024;
WarnSize = ReadSettingAsInt(document, Constants.SizeSoftLimitInKB) / 1024;
MaxDocs = ReadSettingAsInt(document, Constants.DocsHardLimit);
WarnDocs = ReadSettingAsInt(document, Constants.DocsSoftLimit);
OnEverythingChanged();
}