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


C# DocumentStore.Changes方法代码示例

本文整理汇总了C#中Raven.Client.Document.DocumentStore.Changes方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentStore.Changes方法的具体用法?C# DocumentStore.Changes怎么用?C# DocumentStore.Changes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Raven.Client.Document.DocumentStore的用法示例。


在下文中一共展示了DocumentStore.Changes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HowToSubscribeToDataSubscriptionChanges

		public HowToSubscribeToDataSubscriptionChanges()
		{
			using (var store = new DocumentStore())
			{
				{
					#region data_subscription_changes_2

					IDisposable subscription = store
						.Changes()
						.ForAllDataSubscriptions()
						.Subscribe(
							change =>
							{
								var subscriptionId = change.Id;

								switch (change.Type)
								{
									case DataSubscriptionChangeTypes.SubscriptionOpened:
										// do something
										break;
									case DataSubscriptionChangeTypes.SubscriptionReleased:
										// do something
										break;
								}
							});

					#endregion
				}
				{
					#region data_subscription_changes_4

					var subscriptionId = 3;

					IDisposable subscription = store
						.Changes()
						.ForDataSubscription(subscriptionId)
						.Subscribe(
							change =>
							{
								switch (change.Type)
								{
									case DataSubscriptionChangeTypes.SubscriptionOpened:
										// do something
										break;
									case DataSubscriptionChangeTypes.SubscriptionReleased:
										// do something
										break;
								}
							});

					#endregion
				}
			}
		}
开发者ID:modulexcite,项目名称:docs-8,代码行数:54,代码来源:HowToSubscribeToDataSubscriptionChanges.cs

示例2: Main

        static void Main(string[] args)
        {
            using(var store = new DocumentStore
                {
                    Url = "http://localhost:8080",
                    DefaultDatabase = "Wow",
                    Conventions =
                        {
                            FailoverBehavior = FailoverBehavior.ReadFromAllServers
                        }
                }.Initialize())
            {
                store.Changes().ForAllDocuments()
                    .Subscribe(notification =>
                        {
                            Console.WriteLine(notification.Name + " " + notification.Type + " " + notification.Etag);
                        });

                while (true)
                {
                    var spo = Stopwatch.StartNew();
                    using(var s = store.OpenSession())
                    {
                        var load = s.Load<RavenJObject>("books/1");
                        Console.WriteLine(load.Value<string>("Name"));
                    }
                    Console.WriteLine(spo.ElapsedMilliseconds);
                    Console.ReadKey();
                }

            }
        }
开发者ID:ayende,项目名称:courses-stockholm-oct-2012,代码行数:32,代码来源:Program.cs

示例3: CanGetNotificationAboutIndexUpdate

		public void CanGetNotificationAboutIndexUpdate()
		{
			using (GetNewServer())
			using (var store = new DocumentStore
			{
				Url = "http://localhost:8079"
			}.Initialize())
			{
				var list = new BlockingCollection<IndexChangeNotification>();
				var taskObservable = store.Changes();
				taskObservable.Task.Wait();
				taskObservable
					.ForIndex("Raven/DocumentsByEntityName")
					.Subscribe(list.Add);

				using (var session = store.OpenSession())
				{
					session.Store(new ClientServer.Item(), "items/1");
					session.SaveChanges();
				}

				IndexChangeNotification changeNotification;
				Assert.True(list.TryTake(out changeNotification, TimeSpan.FromSeconds(2)));

				Assert.Equal("Raven/DocumentsByEntityName", changeNotification.Name);
				Assert.Equal(changeNotification.Type, IndexChangeTypes.MapCompleted);
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:28,代码来源:Filtered.cs

示例4: WithWindowsAuth

		public void WithWindowsAuth()
		{
			using (GetNewServer())
			using (var store = new DocumentStore
			{
				Url = "http://localhost:8079",
			}.Initialize())
			{
				var list = new BlockingCollection<DocumentChangeNotification>();
				var taskObservable = store.Changes();
				taskObservable.Task.Wait();
				var documentSubscription = taskObservable.ForDocument("items/1");
				documentSubscription.Task.Wait();
				documentSubscription
					.Subscribe(list.Add);

				using (var session = store.OpenSession())
				{
					session.Store(new ClientServer.Item(), "items/1");
					session.SaveChanges();
				}

				DocumentChangeNotification changeNotification;
				Assert.True(list.TryTake(out changeNotification, TimeSpan.FromSeconds(2)));

				Assert.Equal("items/1", changeNotification.Id);
				Assert.Equal(changeNotification.Type, DocumentChangeTypes.Put);
			}
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:29,代码来源:Security_Windows.cs

示例5: CanGetNotificationsFromTenant_ExplicitDatabase

		public void CanGetNotificationsFromTenant_ExplicitDatabase()
		{
			using (GetNewServer())
			using (var store = new DocumentStore
			{
				Url = "http://localhost:8079",
			}.Initialize())
			{
				store.DatabaseCommands.EnsureDatabaseExists("test");
				var list = new BlockingCollection<DocumentChangeNotification>();
				var taskObservable = store.Changes("test");
				taskObservable.Task.Wait();
				taskObservable
					.ForDocument("items/1")
					.Subscribe(list.Add);

				using (var session = store.OpenSession("test"))
				{
					session.Store(new ClientServer.Item(), "items/1");
					session.SaveChanges();
				}

				DocumentChangeNotification DocumentChangeNotification;
				Assert.True(list.TryTake(out DocumentChangeNotification, TimeSpan.FromSeconds(15)));

				Assert.Equal("items/1", DocumentChangeNotification.Id);
				Assert.Equal(DocumentChangeNotification.Type, DocumentChangeTypes.Put);
			}

		}
开发者ID:yuyoozhao,项目名称:ravendb,代码行数:30,代码来源:MultiTenant.cs

示例6: CanGetNotificationAboutDocumentPut

		public void CanGetNotificationAboutDocumentPut()
		{
			using(GetNewServer())
			{using (var store = new DocumentStore
			{
				Url = "http://localhost:8079",
				Conventions =
					{
						FailoverBehavior = FailoverBehavior.FailImmediately
					}
			}.Initialize())
			{
				var list = new BlockingCollection<DocumentChangeNotification>();
				var taskObservable = store.Changes();
				taskObservable.Task.Wait();
				var observableWithTask = taskObservable.ForDocument("items/1");
				observableWithTask.Task.Wait();
				observableWithTask.Subscribe(list.Add);

				using (var session = store.OpenSession())
				{
					session.Store(new Item(), "items/1");
					session.SaveChanges();
				}

				DocumentChangeNotification documentChangeNotification;
				Assert.True(list.TryTake(out documentChangeNotification, TimeSpan.FromSeconds(3)));

				Assert.Equal("items/1", documentChangeNotification.Id);
				Assert.Equal(documentChangeNotification.Type, DocumentChangeTypes.Put);
				Assert.NotNull(documentChangeNotification.Etag);
			}
				Thread.Sleep(1000);
			}
		}
开发者ID:randacc,项目名称:ravendb,代码行数:35,代码来源:ClientServer.cs

示例7: CanGetNotificationAboutDocumentDelete

        public void CanGetNotificationAboutDocumentDelete()
        {
            using (GetNewServer())
            using (var store = new DocumentStore
            {
                Url = "http://localhost:8079"
            }.Initialize())
            {
                var list = new BlockingCollection<DocumentChangeNotification>();
                var taskObservable = store.Changes();
                taskObservable.Task.Wait();
                var observableWithTask = taskObservable.ForDocument("items/1");
                observableWithTask.Task.Wait();
                observableWithTask
                    .Where(x => x.Type == DocumentChangeTypes.Delete)
                    .Subscribe(list.Add);

                using (var session = store.OpenSession())
                {
                    session.Store(new Item(), "items/1");
                    session.SaveChanges();
                }

                store.DatabaseCommands.Delete("items/1", null);

                DocumentChangeNotification DocumentChangeNotification;
                Assert.True(list.TryTake(out DocumentChangeNotification, TimeSpan.FromSeconds(2)));

                Assert.Equal("items/1", DocumentChangeNotification.Id);
                Assert.Equal(DocumentChangeNotification.Type, DocumentChangeTypes.Delete);

                ((RemoteDatabaseChanges) taskObservable).DisposeAsync().Wait();
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:34,代码来源:ClientServer.cs

示例8: HowToSubscribeToIndexChanges

		public HowToSubscribeToIndexChanges()
		{
			using (var store = new DocumentStore())
			{
				#region index_changes_2
				IDisposable subscription = store
					.Changes()
					.ForIndex("Orders/All")
					.Subscribe(
						change =>
						{
							switch (change.Type)
							{
								case IndexChangeTypes.IndexAdded:
									// do something
									break;
								case IndexChangeTypes.IndexDemotedToAbandoned:
									// do something
									break;
								case IndexChangeTypes.IndexDemotedToDisabled:
									// do something
									break;
								case IndexChangeTypes.IndexDemotedToIdle:
									// do something
									break;
								case IndexChangeTypes.IndexMarkedAsErrored:
									// do something
									break;
								case IndexChangeTypes.IndexPromotedFromIdle:
									// do something
									break;
								case IndexChangeTypes.IndexRemoved:
									// do something
									break;
								case IndexChangeTypes.MapCompleted:
									// do something
									break;
								case IndexChangeTypes.ReduceCompleted:
									// do something
									break;
								case IndexChangeTypes.RemoveFromIndex:
									// do something
									break;
							}
						});
				#endregion
			}

			using (var store = new DocumentStore())
			{
				#region index_changes_4
				IDisposable subscription = store
					.Changes()
					.ForAllIndexes()
					.Subscribe(change => Console.WriteLine("{0} on index {1}", change.Type, change.Name));
				#endregion
			}
		}
开发者ID:modulexcite,项目名称:docs-8,代码行数:58,代码来源:HowToSubscribeToIndexChanges.cs

示例9: WithOAuthOnSpecificDatabase

        public void WithOAuthOnSpecificDatabase()
        {
            using (var server = GetNewServer(enableAuthentication:true))
            {
                server.SystemDatabase.Documents.Put("Raven/Databases/OAuthTest", null, RavenJObject.FromObject(new DatabaseDocument
                {
                    Disabled = false,
                    Id = "Raven/Databases/OAuthTest",
                    Settings = new IdentityDictionary<string, string>
                    {
                        {"Raven/DataDir", "~\\Databases\\OAuthTest"}
                    }
                }), new RavenJObject(), null);

                server.SystemDatabase.Documents.Put("Raven/ApiKeys/test", null, RavenJObject.FromObject(new ApiKeyDefinition
                {
                    Name = "test",
                    Secret = "test",
                    Enabled = true,
                    Databases = new List<ResourceAccess>
                    {
                        new ResourceAccess {TenantId = "OAuthTest"},
                    }
                }), new RavenJObject(), null);

                using (var store = new DocumentStore
                {
                    ApiKey = "test/test",
                    DefaultDatabase = "OAuthTest",
                    Url = "http://localhost:8079",
                    Conventions = { FailoverBehavior = FailoverBehavior.FailImmediately }
                }.Initialize())
                {
                    var list = new BlockingCollection<DocumentChangeNotification>();
                    var taskObservable = store.Changes();
                    taskObservable.Task.Wait();
                    var documentSubscription = taskObservable.ForDocument("items/1");
                    documentSubscription.Task.Wait();
                    documentSubscription
                        .Subscribe(list.Add);

                    using (var session = store.OpenSession())
                    {
                        session.Store(new ClientServer.Item(), "items/1");
                        session.SaveChanges();
                    }

                    DocumentChangeNotification changeNotification;
                    Assert.True(list.TryTake(out changeNotification, TimeSpan.FromSeconds(2)));

                    Assert.Equal("items/1", changeNotification.Id);
                    Assert.Equal(changeNotification.Type, DocumentChangeTypes.Put);
                }
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:55,代码来源:SecurityOAuth.cs

示例10: LoadResultShoudBeUpToDateEvenIfAggresiveCacheIsEnabled

		public void LoadResultShoudBeUpToDateEvenIfAggresiveCacheIsEnabled()
		{
			using (GetNewServer())
			using (var store = new DocumentStore { Url = "http://localhost:8079" }.Initialize())
			{
				store.Conventions.ShouldSaveChangesForceAggresiveCacheCheck = false;
				using (var session = store.OpenSession())
				{
					session.Store(new User()
					{
						Id = "users/1",
						Name = "John"
					});
					session.SaveChanges();
				}

				using (store.AggressivelyCacheFor(TimeSpan.FromMinutes(5)))
				{

					// make sure that object is cached
					using (var session = store.OpenSession())
					{
						store.Changes().Task.Result.WaitForAllPendingSubscriptions();

						var users = session.Load<User>(new[] {"users/1"});

						Assert.Equal("John", users[0].Name);
					}
					((DocumentStore)store).GetObserveChangesAndEvictItemsFromCacheTask().Wait();

					// change object
					using (var session = store.OpenSession())
					{
						session.Store(new User()
						{
							Id = "users/1",
							Name = "Adam"
						});
						session.SaveChanges();
					}


					Assert.True(SpinWait.SpinUntil(() =>store.JsonRequestFactory.NumberOfCacheResets > 0, 10000));

					using (var session = store.OpenSession())
					{
						var users = session.Load<User>(new[] { "users/1" });

						Assert.Equal("Adam", users[0].Name);
					}
				}
			}
		}
开发者ID:nzaugg,项目名称:ravendb,代码行数:53,代码来源:RavenDB_406.cs

示例11: CheckForAlbumChanges

        /// <summary>
        /// Write to the console if an Album document changes.
        /// </summary>
        /// <param name="documentStore"></param>
        private static void CheckForAlbumChanges(DocumentStore documentStore)
        {
            documentStore.Changes().ForDocumentsStartingWith("Albums/")
                .Subscribe(change =>
                    {
                        if (change.Type == DocumentChangeTypes.Put)
                        {
                            Console.WriteLine("An Album has changed on the server!!");
                        }
                    });

            Console.WriteLine("Running :)");
            Console.Read();
        }
开发者ID:dotnetcurry,项目名称:new-in-ravendb2-dncmag05,代码行数:18,代码来源:Program.cs

示例12: HowToSubscribeToBulkInsertChanges

		public HowToSubscribeToBulkInsertChanges()
		{
			using (var store = new DocumentStore())
			{
				#region bulk_insert_changes_2
				using (BulkInsertOperation bulkInsert = store.BulkInsert())
				{
					IDisposable subscribtion = store
						.Changes()
						.ForBulkInsert(bulkInsert.OperationId)
						.Subscribe(change =>
						{
							switch (change.Type)
							{
								case DocumentChangeTypes.BulkInsertStarted:
									// do something
									break;
								case DocumentChangeTypes.BulkInsertEnded:
									// do something
									break;
								case DocumentChangeTypes.BulkInsertError:
									// do something
									break;
							}
						});

					try
					{
						for (int i = 0; i < 1000 * 1000; i++)
						{
							bulkInsert.Store(new Employee
							{
								FirstName = "FirstName #" + i,
								LastName = "LastName #" + i
							});
						}
					}
					finally
					{
						if (subscribtion != null)
							subscribtion.Dispose();
					}
				}
				#endregion
			}
		}
开发者ID:modulexcite,项目名称:docs-8,代码行数:46,代码来源:HowToSubscribeToBulkInsertChanges.cs

示例13: WithOAuth

		public void WithOAuth()
		{
			using (var server = GetNewServer())
			{
				server.Database.Put("Raven/ApiKeys/test", null, RavenJObject.FromObject(new ApiKeyDefinition
				{
					Name = "test",
					Secret = "test",
					Enabled = true,
					Databases = new List<DatabaseAccess>
					{
						new DatabaseAccess {TenantId = "*"},
					}
				}), new RavenJObject(), null);

				using (var store = new DocumentStore
				{
					ApiKey = "test/test",
					Url = "http://localhost:8079",
					Conventions = { FailoverBehavior = FailoverBehavior.FailImmediately }
				}.Initialize())
				{
					var list = new BlockingCollection<DocumentChangeNotification>();
					var taskObservable = store.Changes();
					taskObservable.Task.Wait();
					var documentSubscription = taskObservable.ForDocument("items/1");
					documentSubscription.Task.Wait();
					documentSubscription
						.Subscribe(list.Add);

					using (var session = store.OpenSession())
					{
						session.Store(new ClientServer.Item(), "items/1");
						session.SaveChanges();
					}

					DocumentChangeNotification changeNotification;
					Assert.True(list.TryTake(out changeNotification, TimeSpan.FromSeconds(2)));

					Assert.Equal("items/1", changeNotification.Id);
					Assert.Equal(changeNotification.Type, DocumentChangeTypes.Put);
				}
			}
		}
开发者ID:Trebornide,项目名称:ravendb,代码行数:44,代码来源:SecurityOAuth.cs

示例14: ShouldNotCrashServer

		public void ShouldNotCrashServer()
		{
			using (GetNewServer())
			using (var store = new DocumentStore
			{
				Url = "http://localhost:8079",
				Conventions =
					{
						FailoverBehavior = FailoverBehavior.FailImmediately
					}
			})
			{
				store.Initialize();
				var taskObservable = store.Changes("does-not-exists");
				Assert.Throws<AggregateException>(() => taskObservable.Task.Wait(TimeSpan.FromSeconds(5)));
				// ensure the db still works
				store.DatabaseCommands.GetStatistics();
			}
		}
开发者ID:Trebornide,项目名称:ravendb,代码行数:19,代码来源:NotificationOnWrongDatabase.cs

示例15: StartsWithChangesThrowsWithBulkInsert

        public void StartsWithChangesThrowsWithBulkInsert()
        {
            using (GetNewServer())
            using (var store = new DocumentStore
            {
                Url = "http://localhost:8079"
            }.Initialize())
            {
                Exception e = null;
                store.Changes().ForDocumentsStartingWith("something").Subscribe(notification => { }, exception => e = exception);

                using (var session = store.BulkInsert())
                {
                    session.Store(new Company(), "else/1");
                }

                Assert.Null(e);
            }
        } 
开发者ID:j2jensen,项目名称:ravendb,代码行数:19,代码来源:BulkInsertWithChanges.cs


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