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


C# SmugglerApi.WaitForIndexing方法代码示例

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


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

示例1: Parse

		private void Parse(string[] args)
		{
			// Do these arguments the traditional way to maintain compatibility
			if (args.Length < 3)
				PrintUsageAndExit(-1);

			SmugglerAction action = SmugglerAction.Export;
			if (string.Equals(args[0], "in", StringComparison.OrdinalIgnoreCase))
				action = SmugglerAction.Import;
			else if (string.Equals(args[0], "out", StringComparison.OrdinalIgnoreCase))
				action = SmugglerAction.Export;
			else
				PrintUsageAndExit(-1);

			var url = args[1];
			if (url == null)
			{
				PrintUsageAndExit(-1);
				return;
			}
			connectionStringOptions.Url = url;

			options.BackupPath = args[2];
			if (options.BackupPath == null)
				PrintUsageAndExit(-1);

			try
			{
				optionSet.Parse(args);
			}
			catch (Exception e)
			{
				PrintUsageAndExit(e);
			}

			if (options.BackupPath != null && Directory.Exists(options.BackupPath))
			{
				incremental = true;
			}

			var smugglerApi = new SmugglerApi(options, connectionStringOptions);

			try
			{
				switch (action)
				{
					case SmugglerAction.Import:
						smugglerApi.ImportData(options, incremental).Wait();
						if (waitForIndexing)
							smugglerApi.WaitForIndexing(options).Wait();
						break;
					case SmugglerAction.Export:
						smugglerApi.ExportData(null, options, incremental).Wait();
						break;
				}
			}
			catch (AggregateException ex)
			{
				var exception = ex.ExtractSingleInnerException();
				var e = exception as WebException;
				if (e != null)
				{

					if (e.Status == WebExceptionStatus.ConnectFailure)
					{
						Console.WriteLine("Error: {0} {1}", e.Message, connectionStringOptions.Url);
						var socketException = e.InnerException as SocketException;
						if (socketException != null)
						{
							Console.WriteLine("Details: {0}", socketException.Message);
							Console.WriteLine("Socket Error Code: {0}", socketException.SocketErrorCode);
						}

						Environment.Exit((int)e.Status);
					}

					var httpWebResponse = e.Response as HttpWebResponse;
					if (httpWebResponse == null)
						throw;
					Console.WriteLine("Error: " + e.Message);
					Console.WriteLine("Http Status Code: " + httpWebResponse.StatusCode + " " + httpWebResponse.StatusDescription);

					using (var reader = new StreamReader(httpWebResponse.GetResponseStream()))
					{
						string line;
						while ((line = reader.ReadLine()) != null)
						{
							Console.WriteLine(line);
						}
					}

					Environment.Exit((int)httpWebResponse.StatusCode);
				}
				else
				{
					Console.WriteLine(ex);
					Environment.Exit(-1);
				}
			}
		}
开发者ID:robashton,项目名称:ravendb,代码行数:100,代码来源:Program.cs


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