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


C# Util.Etag类代码示例

本文整理汇总了C#中Raven.Abstractions.Util.Etag的典型用法代码示例。如果您正苦于以下问题:C# Etag类的具体用法?C# Etag怎么用?C# Etag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Read

		public IEnumerable<ListItem> Read(string name, Etag start, Etag end, int take)
		{
			Api.JetSetCurrentIndex(session, Lists, "by_name_and_etag");
			Api.MakeKey(session, Lists, name, Encoding.Unicode, MakeKeyGrbit.NewKey);
			Api.MakeKey(session, Lists, start.TransformToValueForEsentSorting(), MakeKeyGrbit.None);
			if (Api.TrySeek(session, Lists, SeekGrbit.SeekGT) == false)
				yield break;
		
			int count = 0;
			do
			{
				var nameFromDb = Api.RetrieveColumnAsString(session, Lists, tableColumnsCache.ListsColumns["name"], Encoding.Unicode);
				if (string.Equals(name, nameFromDb, StringComparison.InvariantCultureIgnoreCase) == false)
					yield break;


				var etag = Etag.Parse(Api.RetrieveColumn(session, Lists, tableColumnsCache.ListsColumns["etag"]));
				if (end != null && end.CompareTo(etag) <= 0)
					yield break;

				count++;
				
				using (Stream stream = new BufferedStream(new ColumnStream(session, Lists, tableColumnsCache.ListsColumns["data"])))
				{
					yield return new ListItem
					{
						Etag = etag,
						Data = stream.ToJObject(),
						Key = Api.RetrieveColumnAsString(session, Lists, tableColumnsCache.ListsColumns["key"], Encoding.Unicode)
					};
				}
			} while (Api.TryMoveNext(session, Lists) && count < take);

		}
开发者ID:cocytus,项目名称:ravendb,代码行数:34,代码来源:Lists.cs

示例2: FinishSynchronization

		public void FinishSynchronization(string fileName, SynchronizationReport report, FileSystemInfo sourceFileSystem, Etag sourceFileETag)
		{
			try
			{
				// we want to execute those operation in a single batch but we also have to ensure that
				// Raven/Synchronization/Sources/sourceServerId config is modified only by one finishing synchronization at the same time
				synchronizationFinishLocks.GetOrAdd(sourceFileSystem.Id, new ReaderWriterLockSlim()).EnterWriteLock();

				Storage.Batch(accessor =>
				{
					SaveSynchronizationReport(fileName, accessor, report);
					FileLockManager.UnlockByDeletingSyncConfiguration(fileName, accessor);

					if (report.Exception == null)
						SaveSynchronizationSourceInformation(sourceFileSystem, sourceFileETag);
				});
			}
			catch (Exception ex)
			{
				Log.ErrorException(string.Format("Failed to finish synchronization of a file '{0}' from {1}", fileName, sourceFileSystem), ex);
			}
			finally
			{
				synchronizationFinishLocks.GetOrAdd(sourceFileSystem.Id, new ReaderWriterLockSlim()).ExitWriteLock();
			}
		}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:26,代码来源:SynchronizationActions.cs

示例3: AddAttachment

		public Etag AddAttachment(string key, Etag etag, Stream data, RavenJObject headers)
		{
			Api.JetSetCurrentIndex(session, Files, "by_name");
			Api.MakeKey(session, Files, key, Encoding.Unicode, MakeKeyGrbit.NewKey);
			var isUpdate = Api.TrySeek(session, Files, SeekGrbit.SeekEQ);
			if (isUpdate)
			{
				var existingEtag = Etag.Parse(Api.RetrieveColumn(session, Files, tableColumnsCache.FilesColumns["etag"]));
				if (existingEtag != etag && etag != null)
				{
					throw new ConcurrencyException("PUT attempted on attachment '" + key +
						"' using a non current etag")
					{
						ActualETag = existingEtag,
						ExpectedETag = etag
					};
				}
			}
			else
			{
				if (data == null)
					throw new InvalidOperationException("When adding new attachment, the attachment data must be specified");

				if (Api.TryMoveFirst(session, Details))
					Api.EscrowUpdate(session, Details, tableColumnsCache.DetailsColumns["attachment_count"], 1);
			}

			Etag newETag = uuidGenerator.CreateSequentialUuid(UuidType.Attachments);
			using (var update = new Update(session, Files, isUpdate ? JET_prep.Replace : JET_prep.Insert))
			{
				Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["name"], key, Encoding.Unicode);
				if (data != null)
				{
					long written;
					using (var columnStream = new ColumnStream(session, Files, tableColumnsCache.FilesColumns["data"]))
					{
						if (isUpdate)
							columnStream.SetLength(0);
						using (var stream = new BufferedStream(columnStream))
						{
							data.CopyTo(stream);
							written = stream.Position;
							stream.Flush();
						}
					}
					if (written == 0) // empty attachment
					{
						Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["data"], new byte[0]);
					}
				}

				Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["etag"], newETag.TransformToValueForEsentSorting());
				Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["metadata"], headers.ToString(Formatting.None), Encoding.Unicode);

				update.Save();
			}
			logger.Debug("Adding attachment {0}", key);

			return newETag;
		}
开发者ID:925coder,项目名称:ravendb,代码行数:60,代码来源:DocumentStorageActions.cs

示例4: DeleteAttachment

		public void DeleteAttachment(string key, Etag etag)
		{
			Api.JetSetCurrentIndex(session, Files, "by_name");
			Api.MakeKey(session, Files, key, Encoding.Unicode, MakeKeyGrbit.NewKey);
			if (Api.TrySeek(session, Files, SeekGrbit.SeekEQ) == false)
			{
				logger.Debug("Attachment with key '{0}' was not found, and considered deleted", key);
				return;
			}

			var fileEtag = Etag.Parse(Api.RetrieveColumn(session, Files, tableColumnsCache.FilesColumns["etag"]));
			if (fileEtag != etag && etag != null)
			{
				throw new ConcurrencyException("DELETE attempted on attachment '" + key +
					"' using a non current etag")
				{
					ActualETag = fileEtag,
					ExpectedETag = etag
				};
			}

			Api.JetDelete(session, Files);

			if (Api.TryMoveFirst(session, Details))
				Api.EscrowUpdate(session, Details, tableColumnsCache.DetailsColumns["attachment_count"], -1);
			logger.Debug("Attachment with key '{0}' was deleted", key);
		}
开发者ID:925coder,项目名称:ravendb,代码行数:27,代码来源:DocumentStorageActions.cs

示例5: AfterDelete

		public void AfterDelete(string key, Etag deletedEtag)
		{
			foreach (var behavior in prefetchingBehaviors)
			{
				behavior.AfterDelete(key, deletedEtag);
			}
		}
开发者ID:GorelH,项目名称:ravendb,代码行数:7,代码来源:Prefetcher.cs

示例6: IndexingBatch

		public IndexingBatch(Etag highestEtagBeforeFiltering)
		{
			HighestEtagBeforeFiltering = highestEtagBeforeFiltering;
			Ids = new List<string>();
			Docs = new List<dynamic>();
			SkipDeleteFromIndex = new List<bool>();
		}
开发者ID:Nakro,项目名称:ravendb,代码行数:7,代码来源:IndexingBatch.cs

示例7: CalculateSynchronizationEtag

		public Etag CalculateSynchronizationEtag(Etag etag, Etag lastProcessedEtag)
		{
			if (etag == null)
			{
				if (lastProcessedEtag != null)
				{
					lock (locker)
					{
						if (currentEtag == null && lastProcessedEtag.CompareTo(synchronizationEtag) != 0)
						{
							synchronizationEtag = lastProcessedEtag;
							PersistSynchronizationState();
						}
					}

					return lastProcessedEtag;
				}

				return Etag.Empty;
			}

			if (lastProcessedEtag == null)
				return Etag.Empty;

			if (etag.CompareTo(lastProcessedEtag) < 0)
				return EtagUtil.Increment(etag, -1);

			return lastProcessedEtag;
		}
开发者ID:robashton,项目名称:ravendb,代码行数:29,代码来源:EtagSynchronizer.cs

示例8: AfterUpdate

		public void AfterUpdate(string key, Etag etagBeforeUpdate)
		{
			foreach (var behavior in prefetchingBehaviors)
			{
				behavior.AfterUpdate(key, etagBeforeUpdate);
			}
		}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:7,代码来源:Prefetcher.cs

示例9: ExportAttachments

		protected override async Task<Etag> ExportAttachments(JsonTextWriter jsonWriter, Etag lastEtag)
		{
			var totalCount = 0;
			while (true)
			{
				var array = GetAttachments(totalCount, lastEtag);
				if (array.Length == 0)
				{
					var databaseStatistics = await GetStats();
					if (lastEtag == null) lastEtag = Etag.Empty;
					if (lastEtag.CompareTo(databaseStatistics.LastAttachmentEtag) < 0)
					{
						lastEtag = EtagUtil.Increment(lastEtag, SmugglerOptions.BatchSize);
						ShowProgress("Got no results but didn't get to the last attachment etag, trying from: {0}", lastEtag);
						continue;
					}
					ShowProgress("Done with reading attachments, total: {0}", totalCount);
					return lastEtag;
				}
				totalCount += array.Length;
				ShowProgress("Reading batch of {0,3} attachments, read so far: {1,10:#,#;;0}", array.Length, totalCount);
				foreach (var item in array)
				{
					item.WriteTo(jsonWriter);
				}
				lastEtag = Etag.Parse(array.Last().Value<string>("Etag"));
			}
		}
开发者ID:robashton,项目名称:ravendb,代码行数:28,代码来源:DataDumper.cs

示例10: UpdateSynchronizationState

		public void UpdateSynchronizationState(Etag lowestEtag)
		{
			lock (locker)
			{
				if (UpdateSynchronizationStateInternal(lowestEtag))
					PersistSynchronizationState();
			}
		}
开发者ID:robashton,项目名称:ravendb,代码行数:8,代码来源:EtagSynchronizer.cs

示例11: UpdateSynchronizationStateInternal

		private bool UpdateSynchronizationStateInternal(Etag lowestEtag)
		{
			if (currentEtag == null || lowestEtag.CompareTo(currentEtag) < 0)
			{
				currentEtag = lowestEtag;
			}

			return lowestEtag.CompareTo(synchronizationEtag) < 0;
		}
开发者ID:robashton,项目名称:ravendb,代码行数:9,代码来源:EtagSynchronizer.cs

示例12: GetDocuments

        public Task<IAsyncEnumerator<RavenJObject>> GetDocuments(RavenConnectionStringOptions src, Etag lastEtag, int take)
        {
            const int dummy = 0;
            var enumerator = database.Documents.GetDocumentsAsJson(dummy, Math.Min(Options.BatchSize, take), lastEtag, CancellationToken.None)
                .ToList()
                .Cast<RavenJObject>()
                .GetEnumerator();

            return new CompletedTask<IAsyncEnumerator<RavenJObject>>(new AsyncEnumeratorBridge<RavenJObject>(enumerator));
        }
开发者ID:ricardobrandao,项目名称:ravendb,代码行数:10,代码来源:SmugglerEmbeddedDatabaseOperations.cs

示例13: GetDocuments

		protected override Task<IAsyncEnumerator<RavenJObject>> GetDocuments(Etag lastEtag)
		{
			const int dummy = 0;

			var enumerator = _database.GetDocuments(dummy, SmugglerOptions.BatchSize, lastEtag)
				.ToList()
				.Cast<RavenJObject>()
				.GetEnumerator();

			return new CompletedTask<IAsyncEnumerator<RavenJObject>>(new AsyncEnumeratorBridge<RavenJObject>(enumerator));
		}
开发者ID:robashton,项目名称:ravendb,代码行数:11,代码来源:DataDumper.cs

示例14: StorageExporter

 public StorageExporter(string databaseBaseDirectory, string databaseOutputFile,int batchSize,Etag documentsStartEtag)
 {
     baseDirectory = databaseBaseDirectory;
     outputDirectory = databaseOutputFile;
     var ravenConfiguration = new RavenConfiguration();
     ravenConfiguration.DataDirectory = databaseBaseDirectory;
     ravenConfiguration.Storage.PreventSchemaUpdate = true;
     ravenConfiguration.Storage.SkipConsistencyCheck = true;
     CreateTransactionalStorage(ravenConfiguration);
     BatchSize = batchSize;
     DocumentsStartEtag = documentsStartEtag;
 }
开发者ID:j2jensen,项目名称:ravendb,代码行数:12,代码来源:StorageExporter.cs

示例15: GetFiles

        public Task<IAsyncEnumerator<FileHeader>> GetFiles(Etag lastEtag, int take)
        {
            ShowProgress("Streaming documents from {0}, batch size {1}", lastEtag, take);

            IEnumerable<FileHeader> enumerable = null;

            filesystem.Storage.Batch(accessor =>
            {
                enumerable = accessor.GetFilesAfter(lastEtag, take);
            });

            return new CompletedTask<IAsyncEnumerator<FileHeader>>(new AsyncEnumeratorBridge<FileHeader>(enumerable.GetEnumerator()));
        }
开发者ID:heinnge,项目名称:ravendb,代码行数:13,代码来源:SmugglerEmbeddedFilesOperations.cs


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