当前位置: 首页>>代码示例>>C#>>正文


C# DocumentDatabase.Get方法代码示例

本文整理汇总了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"));
		}
开发者ID:Trebornide,项目名称:ravendb,代码行数:30,代码来源:IncrementalBackupRestore.cs

示例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);
        }
开发者ID:khalidabuhakmeh,项目名称:ravendb.contrib,代码行数:11,代码来源:ClockDocsMaintainer.cs

示例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"));
		}
开发者ID:925coder,项目名称:ravendb,代码行数:17,代码来源:BackupRestore.cs

示例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"));
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:18,代码来源:BackupRestore.cs

示例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;
		}
开发者ID:neiz,项目名称:ravendb,代码行数:42,代码来源:AuthorizeClient.cs

示例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);
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:22,代码来源:AbstractDocumentStorageTest.cs

示例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);
			}
		}
开发者ID:arelee,项目名称:ravendb,代码行数:32,代码来源:EncryptionSettingsManager.cs

示例8: WaitForBackup

		protected void WaitForBackup(DocumentDatabase db, bool checkError)
		{
			WaitForBackup(key => db.Get(key, null), checkError);
		}
开发者ID:nzaugg,项目名称:ravendb,代码行数:4,代码来源:RavenTestBase.cs

示例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"));
		}
开发者ID:runesoerensen,项目名称:ravendb,代码行数:33,代码来源:IncrementalBackupRestore.cs

示例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);
		}
开发者ID:samueldjack,项目名称:ravendb,代码行数:25,代码来源:RavenTestBase.cs


注:本文中的Raven.Database.DocumentDatabase.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。