public void EnsureWellFormedConnectionStrings_ParsingWithEndingSemicolons_Successful() { var documentStore = new DocumentStore(); documentStore.ParseConnectionString("Url=http://localhost:10301;"); Assert.DoesNotContain(";", documentStore.Url); documentStore.ParseConnectionString("Url=http://localhost:10301/;"); Assert.DoesNotContain(";", documentStore.Url); }
public RavenDataProvider(string connectionString) : base(connectionString) { _store = new DocumentStore(); _store.ParseConnectionString(connectionString); _store.Initialize(); }
private async Task InitializeDocumentsCursor(CancellationToken cancellation) { using (var store = new DocumentStore()) { store.ParseConnectionString(configuration.ConnectionString); store.Initialize(false); using (var session = store.OpenAsyncSession()) { if (String.IsNullOrEmpty(configuration.Query)) { documentsCursor = await session.Advanced.StreamAsync<RavenJObject>(Etag.Empty, 0, int.MaxValue, null, cancellation); } else { var query = String.IsNullOrEmpty(configuration.Index) ? session.Advanced.AsyncDocumentQuery<RavenJObject>() : session.Advanced.AsyncDocumentQuery<RavenJObject>(configuration.Index); // Streaming query API does not create a dynamic index, so user have to specify one if query is provided: http://issues.hibernatingrhinos.com/issue/RavenDB-1410 documentsCursor = await session.Advanced.StreamAsync<RavenJObject>( query.Where(configuration.Query).NoCaching().NoTracking(), cancellation); } } } }
private static DocumentStore CreateStore(string connectionString, bool createDatabase) { var store = new DocumentStore(); store.ParseConnectionString(connectionString); store.Initialize(createDatabase); return store; }
public void check_illegal_connstrings() { using (var store = new DocumentStore()) { Assert.Throws<System.ArgumentException>(() => store.ParseConnectionString(string.Empty)); } }
public RavenDataProvider(string connectionString) : base(connectionString) { _store = new DocumentStore(); _store.ParseConnectionString(connectionString); _store.Initialize(); _aggressiveCacheFor = TimeSpan.FromSeconds(60); }
public void Can_get_api_key() { using (var store = new DocumentStore()) { store.ParseConnectionString("Url=http://localhost:8079/;ApiKey=d5723e19-92ad-4531-adad-8611e6e05c8a;"); Assert.Equal("d5723e19-92ad-4531-adad-8611e6e05c8a", store.ApiKey); } }
public IDocumentStore Create() { if (IsEmpty()) { var defaultDataDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase.ParentDirectory().AppendPath("data"); return new RavenDbSettings {DataDirectory = defaultDataDirectory}.Create(); } if (Url.IsNotEmpty()) { var store = new DocumentStore { Url = Url }; if (ConnectionString.IsNotEmpty()) { store.ParseConnectionString(ConnectionString); } return store; } if (DataDirectory.IsNotEmpty()) { return new EmbeddableDocumentStore { DataDirectory = DataDirectory, UseEmbeddedHttpServer = UseEmbeddedHttpServer }; } if (RunInMemory) { var store = new EmbeddableDocumentStore { RunInMemory = true, UseEmbeddedHttpServer = UseEmbeddedHttpServer }; if (Url.IsNotEmpty()) { store.Url = Url; } if (Port > 0) { store.Configuration.Port = Port; } return store; } throw new ArgumentOutOfRangeException("settings"); }
public void RunActivitiesImport() { var store = new DocumentStore(); store.ParseConnectionString("Url=http://localhost:8888/"); store.Initialize(); using (IDocumentSession db = store.OpenSession()) { var importer = Importer.CreateImporter(db, new ActivitiesMapping()); importer.Import(@"C:\Work\pressures-data\Human_Activities_Metadata_Catalogue.csv"); } }
/// <summary> /// Tests the RavenDB connection. /// </summary> /// <param name="connectionString">RavenDB connection string to use to connect.</param> public async Task TestConnectionAsync(string connectionString) { if (String.IsNullOrEmpty(connectionString)) throw Errors.ConnectionStringMissing(); using (var store = new DocumentStore()) { store.ParseConnectionString(connectionString); store.Initialize(false); await store.AsyncDatabaseCommands.GetStatisticsAsync(); } }
public void can_work_with_default_db() { using (var store = new DocumentStore()) { store.ParseConnectionString("Url=http://localhost:8079/;DefaultDatabase=DevMachine;ResourceManagerId=d5723e19-92ad-4531-adad-8611e6e05c8a;"); Assert.Equal("http://localhost:8079", store.Url); Assert.Equal("http://localhost:8079 (DB: DevMachine)", store.Identifier); Assert.NotNull(store.Credentials); Assert.Equal("DevMachine", store.DefaultDatabase); Assert.True(store.EnlistInDistributedTransactions); } }
public void check_url_and_rmid() { using (var store = new DocumentStore()) { store.ParseConnectionString("Url=http://localhost:8079/;ResourceManagerId=d5723e19-92ad-4531-adad-8611e6e05c8a;"); Assert.Equal("http://localhost:8079", store.Url); Assert.Equal("http://localhost:8079", store.Identifier); Assert.NotNull(store.Credentials); Assert.Null(store.DefaultDatabase); Assert.True(store.EnlistInDistributedTransactions); } }
public override void Load() { var connStr = ConfigurationManager.AppSettings["RAVENHQ_CONNECTION_STRING"]; var store = new DocumentStore(); store.ParseConnectionString(connStr); store.Initialize(); Kernel.Bind<IDocumentSession>() .ToMethod(ctx => store.OpenSession()) .InRequestScope(); this.BindFilter<RavenFilter>(FilterScope.Controller, 0); }
public void WillNotAffectResourceManagerId() { var resourceManagerId = Guid.NewGuid(); using (var store = new DocumentStore { ResourceManagerId = resourceManagerId }) { store.ParseConnectionString("Url=http://localhost:8079/;"); Assert.Equal(resourceManagerId, store.ResourceManagerId); } }
public void check_url_and_defaultdb() { using (var store = new DocumentStore()) { store.ParseConnectionString("Url=http://localhost:8079/;DefaultDatabase=DevMachine;"); Assert.Equal("http://localhost:8079", store.Url); Assert.Equal("http://localhost:8079 (DB: DevMachine)", store.Identifier); Assert.NotNull(store.ResourceManagerId); Assert.NotNull(store.Credentials); Assert.Equal("DevMachine", store.DefaultDatabase); Assert.True(store.EnlistInDistributedTransactions); } }
public void check_url() { using (var store = new DocumentStore()) { store.ParseConnectionString("Url=http://localhost:8080/;"); Assert.Equal("http://localhost:8080/", store.Url); Assert.Equal("http://localhost:8080/", store.Identifier); Assert.NotNull(store.ResourceManagerId); Assert.NotNull(store.Credentials); Assert.Null(store.DefaultDatabase); Assert.True(store.EnlistInDistributedTransactions); } }
public void check_with_rmid() { using (var store = new DocumentStore()) { store.ParseConnectionString("ResourceManagerId=d5723e19-92ad-4531-adad-8611e6e05c8a;"); Assert.Null(store.Url); Assert.Null(store.Identifier); Assert.Equal("d5723e19-92ad-4531-adad-8611e6e05c8a", store.ResourceManagerId.ToString()); Assert.NotNull(store.Credentials); Assert.Null(store.DefaultDatabase); Assert.True(store.EnlistInDistributedTransactions); } }
public void Can_get_failover_servers() { using (var store = new DocumentStore()) { store.ParseConnectionString("Url=http://localhost:8079/;Failover={Url:'http://localhost:8078/'};Failover={Url:'http://localhost:8077', Database:'test'};Failover=Northwind|{Url:'http://localhost:8076/'};Failover={Url:'http://localhost:8075', Username:'******', Password:'******'};Failover={Url:'http://localhost:8074', ApiKey:'d5723e19-92ad-4531-adad-8611e6e05c8a'}"); Assert.Equal("http://localhost:8079", store.Url); Assert.Equal(4, store.FailoverServers.ForDefaultDatabase.Length); Assert.Equal("http://localhost:8078", store.FailoverServers.ForDefaultDatabase[0].Url); Assert.Equal("http://localhost:8077", store.FailoverServers.ForDefaultDatabase[1].Url); Assert.Equal("test", store.FailoverServers.ForDefaultDatabase[1].Database); Assert.Equal(1, store.FailoverServers.GetForDatabase("Northwind").Length); Assert.Equal("http://localhost:8076", store.FailoverServers.GetForDatabase("Northwind")[0].Url); Assert.Equal("http://localhost:8075", store.FailoverServers.ForDefaultDatabase[2].Url); Assert.Equal("user", store.FailoverServers.ForDefaultDatabase[2].Username); Assert.Equal("secret", store.FailoverServers.ForDefaultDatabase[2].Password); Assert.Equal("http://localhost:8074", store.FailoverServers.ForDefaultDatabase[3].Url); Assert.Equal("d5723e19-92ad-4531-adad-8611e6e05c8a", store.FailoverServers.ForDefaultDatabase[3].ApiKey); } }
protected virtual IDocumentStore GetStore() { var store = new DocumentStore(); if (!string.IsNullOrEmpty(this.config.ConnectionName)) store.ConnectionStringName = this.config.ConnectionName; if (!string.IsNullOrEmpty(this.config.ConnectionString)) store.ParseConnectionString(config.ConnectionString); if (this.config.Url != null) store.Url = this.config.Url.ToString(); if (!string.IsNullOrEmpty(this.config.DefaultDatabase)) store.DefaultDatabase = this.config.DefaultDatabase; store.Initialize(); return store; }
//private static DocumentStore MasterStore; static void Main(string[] args) { var ds = new DocumentStore(); ds.ParseConnectionString(ConfigurationManager.AppSettings["RavenMaster"]); //done this way to allow environment variable overwrite on appharbor for backgroundworker ds.Conventions = new DocumentConvention { DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites }; var database=IlluminateDatabase.Create(ds); var messageBroker = MessageBroker.Create(); messageBroker.Initialise(ConfigurationManager.AppSettings["CLOUDAMQP_URL"]); TaskManager.Initialize(new NotificationsRegistry(database.MasterStore,messageBroker,database.Stores.Values)); }
private KernelBase SetupNinject() { var store = new DocumentStore(); var connectionString = ConfigurationManager.AppSettings["RavenDB"]; store.ParseConnectionString(connectionString); store.Initialize(); var kernel = new StandardKernel(new[] {new FactoryModule(),}); kernel.Bind<IDocumentStore>() .ToConstant(store).InSingletonScope(); kernel.Bind<ICryptoService>() .To<CryptoService>(); kernel.Bind<IKeyProvider>() .To<SettingsKeyProvider>(); kernel.Bind<IMembershipService>() .To<MembershipService>(); kernel.Bind<IUserAuthenticator>() .To<UserAuthenticator>(); kernel.Bind<ICookieAuthenticationProvider>() .To<EmailRFormsAuthenticationProvider>(); return kernel; }
//public static void UpdateEmails() //Used Patching interface instead //{ // var store = new DocumentStore { ConnectionStringName = "RemoteHalethorpe" }; // store.Initialize(); // var x = 0; // var KeepGoing = true; // do // { // List<EmailComms> emails; // using (var session = store.OpenSession()) // { // emails = session.Query<EmailComms>().Skip(x*1024).Take(1024).ToList(); // } // using (var session = store.OpenSession()) // { // foreach (var email in emails) // { // session.Store(email); // } // session.SaveChanges(); // } // KeepGoing = emails.Count > 0; // x++; // } while (KeepGoing); //} public static void TestRavenSave() { var connectionString = ConfigurationManager.AppSettings["RavenMaster"]; var ds = new DocumentStore(); ds.ParseConnectionString(connectionString); //done this way to allow environment variable overwrite on appharbor for backgroundworker ds.Conventions = new DocumentConvention { DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites }; ds.Initialize(); var dog = new Animal { Id = Guid.NewGuid(), Name = "Rover" }; }
public static void BankDataBases() { var connectionString = ConfigurationManager.AppSettings["RavenMaster"]; var ds = new DocumentStore(); ds.ParseConnectionString(connectionString); //done this way to allow environment variable overwrite on appharbor for backgroundworker ds.Conventions = new DocumentConvention { DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites }; ds.Initialize(); using (var session = ds.OpenSession()) { var bankedDB1 = new BankedDatabase { Url = @"http://localhost:8080/raven/studio.html#/databases?database=Trial1" }; session.Store(bankedDB1); } }
static Configure RavenPersistenceWithConnectionString(Configure config, string connectionStringValue, string database) { var store = new DocumentStore { ResourceManagerId = RavenPersistenceConstants.DefaultResourceManagerId }; store.ParseConnectionString(connectionStringValue); if (!string.IsNullOrEmpty(database)) store.DefaultDatabase = database; else if (!connectionStringValue.Contains("DefaultDatabase")) store.DefaultDatabase = databaseNamingConvention(); return RavenPersistence(config, store); }
static Configure RavenPersistenceWithConnectionString(Configure config, string connectionStringValue, string database) { var store = new DocumentStore(); if (connectionStringValue != null) { store.ParseConnectionString(connectionStringValue); var connectionStringParser = ConnectionStringParser<RavenConnectionStringOptions>.FromConnectionString(connectionStringValue); connectionStringParser.Parse(); if (connectionStringParser.ConnectionStringOptions.ResourceManagerId == Guid.Empty) store.ResourceManagerId = RavenPersistenceConstants.DefaultResourceManagerId; } else { store.Url = RavenPersistenceConstants.DefaultUrl; store.ResourceManagerId = RavenPersistenceConstants.DefaultResourceManagerId; } if (database == null) { database = Configure.EndpointName; } else { store.DefaultDatabase = database; } if (store.DefaultDatabase == null) { store.DefaultDatabase = database; } return InternalRavenPersistence(config, store); }
static Configure RavenPersistenceWithConnectionString(Configure config, string connectionStringValue, string database) { var store = new DocumentStore(); if (connectionStringValue != null) { try { store.ParseConnectionString(connectionStringValue); } catch (ArgumentException) { throw new ConfigurationErrorsException(String.Format("Raven connectionstring ({0}) could not be parsed. Please ensure the connectionstring is valid, see http://ravendb.net/docs/client-api/connecting-to-a-ravendb-datastore#using-a-connection-string", connectionStringValue)); } var connectionStringParser = ConnectionStringParser<RavenConnectionStringOptions>.FromConnectionString(connectionStringValue); connectionStringParser.Parse(); if (connectionStringParser.ConnectionStringOptions.ResourceManagerId == Guid.Empty) { store.ResourceManagerId = RavenPersistenceConstants.DefaultResourceManagerId; } } else { store.Url = RavenPersistenceConstants.DefaultUrl; store.ResourceManagerId = RavenPersistenceConstants.DefaultResourceManagerId; } if (database == null) { database = Configure.EndpointName; } else { store.DefaultDatabase = database; } if (store.DefaultDatabase == null) { store.DefaultDatabase = database; } return InternalRavenPersistence(config, store); }
public static void CreateTrial() { var connectionString = ConfigurationManager.AppSettings["RavenMaster"]; var ds = new DocumentStore(); ds.ParseConnectionString(connectionString); //done this way to allow environment variable overwrite on appharbor for backgroundworker ds.Conventions = new DocumentConvention { DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites }; ds.Initialize(); using (var session = ds.OpenSession()) { var trial = new Trial { DateRequested = DateTime.UtcNow, Id = IlluminateDatabase.GenerateId<Trial>(), OrgName = "Amber Taxis", OwnerEmail = "*****@*****.**", OwnerName = "Andy Evans" }; session.Store(trial); session.SaveChanges(); } }
public static void GenerateTrial() { var connectionString = ConfigurationManager.AppSettings["RavenMaster"]; var ds = new DocumentStore(); ds.ParseConnectionString(connectionString); //done this way to allow environment variable overwrite on appharbor for backgroundworker ds.Conventions = new DocumentConvention { DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites }; var database = IlluminateDatabase.Create(ds); //var trialProcessor = new TrialProcessor(database,new LogImpl()); //trialProcessor.Process(); }