本文整理汇总了C#中DocumentDatabase类的典型用法代码示例。如果您正苦于以下问题:C# DocumentDatabase类的具体用法?C# DocumentDatabase怎么用?C# DocumentDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentDatabase类属于命名空间,在下文中一共展示了DocumentDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DatabaseBulkOperations
public DatabaseBulkOperations(DocumentDatabase database, TransactionInformation transactionInformation, CancellationTokenSource tokenSource, CancellationTimeout timeout)
{
this.database = database;
this.transactionInformation = transactionInformation;
this.tokenSource = tokenSource;
this.timeout = timeout;
}
示例2: Execute
public static void Execute(this ICommandData self, DocumentDatabase database)
{
var deleteCommandData = self as DeleteCommandData;
if (deleteCommandData != null)
{
database.Delete(deleteCommandData.Key, deleteCommandData.Etag, deleteCommandData.TransactionInformation);
return;
}
var putCommandData = self as PutCommandData;
if (putCommandData != null)
{
var putResult = database.Put(putCommandData.Key, putCommandData.Etag, putCommandData.Document, putCommandData.Metadata, putCommandData.TransactionInformation);
putCommandData.Etag = putResult.ETag;
putCommandData.Key = putResult.Key;
return;
}
var patchCommandData = self as PatchCommandData;
if (patchCommandData != null)
{
database.ApplyPatch(patchCommandData.Key, patchCommandData.Etag, patchCommandData.Patches, patchCommandData.TransactionInformation);
var doc = database.Get(patchCommandData.Key, patchCommandData.TransactionInformation);
if (doc != null)
{
patchCommandData.Metadata = doc.Metadata;
patchCommandData.Etag = doc.Etag;
}
return;
}
}
示例3: OwinHttpServer
public OwinHttpServer(InMemoryRavenConfiguration config, DocumentDatabase db = null, bool useHttpServer = true, Action<RavenDBOptions> configure = null)
{
startup = new Startup(config, db);
if (configure != null)
configure(startup.Options);
owinEmbeddedHost = OwinEmbeddedHost.Create(app => startup.Configuration(app));
if (!useHttpServer)
{
return;
}
server = WebApp.Start("http://+:" + config.Port, app => //TODO DH: configuration.ServerUrl doesn't bind properly
{
var listener = (HttpListener) app.Properties["System.Net.HttpListener"];
if (listener != null)
{
new WindowsAuthConfigureHttpListener().Configure(listener, config);
}
startup.Configuration(app);
app.Use(async (context, _) =>
{
context.Response.StatusCode = 404;
context.Response.ReasonPhrase = "Not Found";
await context.Response.Body.WriteAsync(NotFoundBody, 0, NotFoundBody.Length);
});
});
}
示例4: Execute
public void Execute(DocumentDatabase database)
{
HashSet<Guid> resourceManagersRequiringRecovery = new HashSet<Guid>();
database.TransactionalStorage.Batch(actions =>
{
foreach (var txId in actions.Transactions.GetTransactionIds())
{
var attachment = actions.Attachments.GetAttachment("transactions/recoveryInformation/" + txId);
if (attachment == null)//Prepare was not called, there is no recovery information
{
actions.Transactions.RollbackTransaction(txId);
}
else
{
Guid resourceManagerId;
if (Guid.TryParse(attachment.Metadata.Value<string>("Resource-Manager-Id"), out resourceManagerId) == false)
{
actions.Transactions.RollbackTransaction(txId);
}
else
{
resourceManagersRequiringRecovery.Add(resourceManagerId);
TransactionManager.Reenlist(resourceManagerId, attachment.Data, new InternalEnlistment(database, txId));
}
}
}
});
foreach (var rm in resourceManagersRequiringRecovery)
{
TransactionManager.RecoveryComplete(rm);
}
}
示例5: CurrentIndexingScope
public CurrentIndexingScope(DocumentDatabase database, string index)
{
this.database = database;
this.index = index;
LoadDocumentCount = 0;
LoadDocumentDuration = new Stopwatch();
}
示例6: BackupOperation
public BackupOperation(DocumentDatabase database, string src, string to)
{
instance = database.TransactionalStorage.Instance;
this.database = database;
this.to = to;
this.src = src;
}
示例7: SmugglerExporter
public SmugglerExporter(DocumentDatabase database, ExportOptions options)
{
this.database = database;
this.options = options;
FillExportTypes();
}
示例8: BackupOperation
public BackupOperation(DocumentDatabase systemDatabase, RavenFileSystem filesystem, string backupSourceDirectory, string backupDestinationDirectory, bool incrementalBackup,
FileSystemDocument filesystemDocument)
: base(systemDatabase, filesystem, backupSourceDirectory, backupDestinationDirectory, incrementalBackup, filesystemDocument)
{
instance = ((TransactionalStorage)filesystem.Storage).Instance;
backupConfigPath = Path.Combine(backupDestinationDirectory, "RavenDB.Backup");
}
示例9: AnonymousObjectToLuceneDocumentConverter
public AnonymousObjectToLuceneDocumentConverter(DocumentDatabase database, IndexDefinition indexDefinition, AbstractViewGenerator viewGenerator, ILog log)
{
this.database = database;
this.indexDefinition = indexDefinition;
this.viewGenerator = viewGenerator;
this.log = log;
}
示例10: 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");
}
示例11: TryGetOrCreateResourceStore
protected override bool TryGetOrCreateResourceStore(string tenantId, out IResourceStore database)
{
if (ResourcesStoresCache.TryGetValue(tenantId, out database))
return true;
JsonDocument jsonDocument;
using (DocumentRetriever.DisableReadTriggers())
jsonDocument = DefaultDatabase.Get("Raven/Databases/" + tenantId, null);
if (jsonDocument == null)
return false;
var document = jsonDocument.DataAsJson.JsonDeserialization<DatabaseDocument>();
database = ResourcesStoresCache.GetOrAdd(tenantId, s =>
{
var config = new InMemoryRavenConfiguration
{
Settings = DefaultConfiguration.Settings,
};
config.Settings["Raven/VirtualDir"] = config.Settings["Raven/VirtualDir"] + "/" + tenantId;
foreach (var setting in document.Settings)
{
config.Settings[setting.Key] = setting.Value;
}
config.Initialize();
var documentDatabase = new DocumentDatabase(config);
documentDatabase.SpinBackgroundWorkers();
return documentDatabase;
});
return true;
}
示例12: Execute
public void Execute(DocumentDatabase database)
{
if (database.Configuration.IsSystemDatabase() == false)
return;
if (ValidateLicense.CurrentLicense.IsCommercial && ValidateLicense.CurrentLicense.Error == false)
{
SetValidCommercialLicenseMarker(database);
ValidateLicense.CurrentLicense.ValidCommercialLicenseSeen = true;
}
else
{
var marker = GetLastSeenValidCommercialLicenseMarker(database);
if (marker != null)
{
ValidateLicense.CurrentLicense.ValidCommercialLicenseSeen = true;
}
}
if (Authentication.IsEnabled == false && database.Configuration.AnonymousUserAccessMode != AnonymousUserAccessMode.Admin)
{
throw new InvalidOperationException("Cannot set Raven/AnonymousAccess to '" + database.Configuration.AnonymousUserAccessMode+"' without a valid license.\r\n" +
"This RavenDB instance doesn't have a license, and the only valid Raven/AnonymousAccess setting is: Admin\r\n" +
"Please change to Raven/AnonymousAccess to Admin, or install a valid license.");
}
}
示例13: IndexReplicationTask
public IndexReplicationTask(DocumentDatabase database, HttpRavenRequestFactory httpRavenRequestFactory, ReplicationTask replication)
: base(database, httpRavenRequestFactory, replication)
{
replicationFrequency = TimeSpan.FromSeconds(database.Configuration.IndexAndTransformerReplicationLatencyInSec); //by default 10 min
lastQueriedFrequency = TimeSpan.FromSeconds(database.Configuration.TimeToWaitBeforeRunningIdleIndexes.TotalSeconds / 2);
TimeToWaitBeforeSendingDeletesOfIndexesToSiblings = TimeSpan.FromMinutes(1);
}
示例14: OnTransformerChange
private void OnTransformerChange(DocumentDatabase documentDatabase, TransformerChangeNotification notification)
{
var transformerName = notification.Name;
switch (notification.Type)
{
case TransformerChangeTypes.TransformerAdded:
//if created transformer with the same name as deleted one, we should prevent its deletion replication
Database.TransactionalStorage.Batch(accessor =>
accessor.Lists.Remove(Constants.RavenReplicationTransformerTombstones, transformerName));
break;
case TransformerChangeTypes.TransformerRemoved:
//If we don't have any destination to replicate to (we are probably slave node)
//we shouldn't keep a tombstone since we are not going to remove it anytime
//and keeping it prevents us from getting that transformer created again.
if (GetReplicationDestinations().Count == 0)
return;
var metadata = new RavenJObject
{
{Constants.RavenTransformerDeleteMarker, true},
{Constants.RavenReplicationSource, Database.TransactionalStorage.Id.ToString()},
{Constants.RavenReplicationVersion, ReplicationHiLo.NextId(Database)},
{"TransformerVersion", notification.Version }
};
Database.TransactionalStorage.Batch(accessor =>
accessor.Lists.Set(Constants.RavenReplicationTransformerTombstones, transformerName, metadata, UuidType.Transformers));
break;
}
}
示例15: IndexReplacer
public IndexReplacer(DocumentDatabase database)
{
Database = database;
database.Notifications.OnDocumentChange += (db, notification, metadata) =>
{
if (notification.Id == null)
return;
if (notification.Id.StartsWith(Constants.IndexReplacePrefix, StringComparison.OrdinalIgnoreCase) == false)
return;
var replaceIndexName = notification.Id.Substring(Constants.IndexReplacePrefix.Length);
if (notification.Type == DocumentChangeTypes.Delete)
{
HandleIndexReplaceDocumentDelete(replaceIndexName);
return;
}
var document = db.Documents.Get(notification.Id, null);
var replaceIndexId = HandleIndexReplaceDocument(document);
if (replaceIndexId != null)
ReplaceIndexes(new []{ replaceIndexId.Value });
};
Initialize();
}