本文整理汇总了C#中Raven.Database.Config.RavenConfiguration.CustomizeValuesForFileSystemTenant方法的典型用法代码示例。如果您正苦于以下问题:C# RavenConfiguration.CustomizeValuesForFileSystemTenant方法的具体用法?C# RavenConfiguration.CustomizeValuesForFileSystemTenant怎么用?C# RavenConfiguration.CustomizeValuesForFileSystemTenant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Database.Config.RavenConfiguration
的用法示例。
在下文中一共展示了RavenConfiguration.CustomizeValuesForFileSystemTenant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Restore
public async Task<HttpResponseMessage> Restore()
{
HttpResponseMessage message = null;
if (EnsureSystemDatabase() == false)
return GetMessageWithString("Restore is only possible from the system database", HttpStatusCode.BadRequest);
var restoreStatus = new RestoreStatus { State = RestoreStatusState.Running, Messages = new List<string>() };
var restoreRequest = await ReadJsonObjectAsync<FilesystemRestoreRequest>();
if (!HasPermissions(restoreRequest.BackupLocation, out message))
return message;
var fileSystemDocumentPath = FindFilesystemDocument(restoreRequest.BackupLocation);
if (!File.Exists(fileSystemDocumentPath))
{
throw new InvalidOperationException("Cannot restore when the Filesystem.Document file is missing in the backup folder: " + restoreRequest.BackupLocation);
}
var filesystemDocumentText = File.ReadAllText(fileSystemDocumentPath);
var filesystemDocument = RavenJObject.Parse(filesystemDocumentText).JsonDeserialization<FileSystemDocument>();
var filesystemName = !string.IsNullOrWhiteSpace(restoreRequest.FilesystemName) ? restoreRequest.FilesystemName
: filesystemDocument == null ? null : filesystemDocument.Id;
if (string.IsNullOrWhiteSpace(filesystemName))
{
var errorMessage = (filesystemDocument == null || String.IsNullOrWhiteSpace(filesystemDocument.Id))
? Constants.FilesystemDocumentFilename + " file is invalid - filesystem name was not found and not supplied in the request (Id property is missing or null). This is probably a bug - should never happen."
: "A filesystem name must be supplied if the restore location does not contain a valid " + Constants.FilesystemDocumentFilename + " file";
restoreStatus.Messages.Add(errorMessage);
DatabasesLandlord.SystemDatabase.Documents.Put(RestoreStatus.RavenFilesystemRestoreStatusDocumentKey(filesystemName), null, RavenJObject.FromObject(new { restoreStatus }), new RavenJObject(), null);
return GetMessageWithString(errorMessage, HttpStatusCode.BadRequest);
}
var ravenConfiguration = new RavenConfiguration
{
FileSystemName = filesystemName,
};
if (restoreRequest.IndexesLocation != null &&
!IsValidPath(restoreRequest.IndexesLocation, out message))
return message;
if (restoreRequest.JournalsLocation != null &&
!IsValidPath(restoreRequest.JournalsLocation, out message))
return message;
if (filesystemDocument != null)
{
//no need to check for existence of specified data and index folders here,
//since those would be simply created after restore
//we need to check only that the drive letter exists, so the folder can actually be created
string dataLocation;
if (filesystemDocument.Settings.TryGetValue(Constants.FileSystem.DataDirectory, out dataLocation))
{
dataLocation = filesystemDocument.Settings[Constants.FileSystem.DataDirectory];
if (!IsOnValidDrive(dataLocation, out message))
return message;
if (!HasPermissions(dataLocation, out message))
return message;
}
string indexesLocation;
if (filesystemDocument.Settings.TryGetValue(Constants.FileSystem.IndexStorageDirectory, out indexesLocation))
{
indexesLocation = filesystemDocument.Settings[Constants.FileSystem.IndexStorageDirectory];
if (!IsOnValidDrive(indexesLocation, out message))
return message;
if (!HasPermissions(indexesLocation, out message))
return message;
}
foreach (var setting in filesystemDocument.Settings)
{
ravenConfiguration.Settings[setting.Key] = setting.Value;
}
}
ravenConfiguration.FileSystem.DefaultStorageTypeName = Directory.Exists(Path.Combine(restoreRequest.BackupLocation, "new")) ?
InMemoryRavenConfiguration.EsentTypeName : InMemoryRavenConfiguration.VoronTypeName;
ravenConfiguration.CustomizeValuesForFileSystemTenant(filesystemName);
ravenConfiguration.Initialize();
string documentDataDir;
ravenConfiguration.FileSystem.DataDirectory = ResolveTenantDataDirectory(restoreRequest.FilesystemLocation, filesystemName, out documentDataDir);
restoreRequest.FilesystemLocation = ravenConfiguration.FileSystem.DataDirectory;
string anotherRestoreResourceName;
if (IsAnotherRestoreInProgress(out anotherRestoreResourceName))
{
if (restoreRequest.RestoreStartTimeout.HasValue)
{
try
{
//.........这里部分代码省略.........