Raven.Backup.BackupOperation.WaitForBackup C# (CSharp) Method

WaitForBackup() public method

public WaitForBackup ( ) : void
return void
		public void WaitForBackup()
		{
			JObject doc = null;

			while (doc == null)
			{
				Thread.Sleep(100); // Allow the server to process the request

				doc = GetStatusDoc();
			}

			if (NoWait)
			{
				Console.WriteLine("Backup operation has started, status is logged at Raven/Backup/Status");
				return;
			}

			while (doc.Value<bool>("IsRunning"))
			{
				Thread.Sleep(1000);

				doc = GetStatusDoc();
			}

			var res = from msg in doc["Messages"]
					  select new
								{
									Message = msg.Value<string>("Message"),
									Timestamp = msg.Value<DateTime>("Timestamp"),
									Severity = msg.Value<string>("Severity")
								};

			foreach (var msg in res)
			{
				Console.WriteLine(string.Format("[{0}] {1}", msg.Timestamp, msg.Message));
			}
		}

Usage Example

Esempio n. 1
0
        static void Main(string[] args)
        {
            var op = new BackupOperation {
                NoWait = false
            };

            var optionSet = new OptionSet
            {
                { "url=", "RavenDB server {0:url}", url => op.ServerUrl = url },
                { "dest=", "Full {0:path} to backup folder", path => op.BackupPath = path },
                { "nowait", "Return immedialtey without waiting for a response from the server", key => op.NoWait = true },
            };

            try
            {
                if (args.Length == 0)
                {
                    PrintUsage(optionSet);
                }

                optionSet.Parse(args);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                PrintUsage(optionSet);
                return;
            }

            if (string.IsNullOrWhiteSpace(op.ServerUrl))
            {
                Console.WriteLine("Enter RavenDB server URL:");
                op.ServerUrl = Console.ReadLine();
            }

            if (string.IsNullOrWhiteSpace(op.BackupPath))
            {
                Console.WriteLine("Enter backup destination:");
                op.BackupPath = Console.ReadLine();
            }

            if (string.IsNullOrWhiteSpace(op.BackupPath) || string.IsNullOrWhiteSpace(op.ServerUrl))
            {
                return;
            }

            try
            {
                if (op.InitBackup())
                {
                    op.WaitForBackup();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadKey();
        }
All Usage Examples Of Raven.Backup.BackupOperation::WaitForBackup