Exemple #1
0
        private static void CreateDatabases(int numberOfDatabases, Raven.Client.Documents.DocumentStore store)
        {
            for (var i = 0; i < numberOfDatabases; i++)
            {
                var dbname = $"Northwind{i}";
                DbNumToDbName.Add(i, dbname);
                var doc = new DatabaseRecord(dbname);
                store.Maintenance.Server.Send(new CreateDatabaseOperation(doc));
                store.Maintenance.ForDatabase(dbname).Send(new CreateSampleDataOperation());
                Console.WriteLine($"Done creating {dbname}");
            }
            Console.WriteLine("Waiting for non stale last database");
            var statOperation = new GetStatisticsOperation();

            while (true)
            {
                var stat = store.Maintenance.ForDatabase(DbNumToDbName[numberOfDatabases - 1]).Send(statOperation);
                if (stat.StaleIndexes.Any())
                {
                    Thread.Sleep(500);
                }
                else
                {
                    Console.WriteLine("Last databse is not stale assuming all database are ready.");
                    return;
                }
            }
        }
        public string DBTest()
        {
            Device d = new Device();

            d.DeviceID   = "TestDeviceID";
            d.DeviceName = "InternBox4";
            d.UserID     = "TestUserID";
            d.VM         = false;
            string str = "Error";

            using (IDocumentStore store = new Raven.Client.Documents.DocumentStore
            {
                Urls = new[]
                {
                    "http://192.168.10.153:8080"
                },
                Database = "TestDB",
                Conventions = { }
            })
            {
                try
                {
                    store.Initialize();
                    using (IDocumentSession session = store.OpenSession())
                    {
                        session.Store(d);
                        session.SaveChanges();

                        DataBaseEntry loadedEnt = session.Load <DataBaseEntry>("DataBaseEntries/2-A");
                        str = loadedEnt.DeviceID;
                    }
                    return(str);
                }
                catch (Exception e)
                {
                    return(e.Message);
                }
            }
        }