Example #1
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
#if !SILVERLIGHT
            databaseCommandsGenerator = () =>
            {
                string databaseUrl = Url;
                if (string.IsNullOrEmpty(DefaultDatabase) == false)
                {
                    databaseUrl = MultiDatabase.GetRootDatabaseUrl(Url);
                    databaseUrl = databaseUrl + "/databases/" + DefaultDatabase;
                }
                return(new ServerClient(databaseUrl, Conventions, credentials, GetReplicationInformerForDatabase, null, jsonRequestFactory, currentSessionId));
            };
#endif
#if !NET_3_5
#if SILVERLIGHT
            // required to ensure just a single auth dialog
            var task = jsonRequestFactory.CreateHttpJsonRequest(this, (Url + "/docs?pageSize=0").NoCache(), "GET", credentials, Conventions)
                       .ExecuteRequest();
#endif
            asyncDatabaseCommandsGenerator = () =>
            {
#if SILVERLIGHT
                var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId, task);
#else
                var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId);
#endif
                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };
#endif
        }
Example #2
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
            var rootDatabaseUrl = MultiDatabase.GetRootDatabaseUrl(Url);

            rootServicePoint = ServicePointManager.FindServicePoint(new Uri(rootDatabaseUrl));
            rootServicePoint.UseNagleAlgorithm = false;
            rootServicePoint.Expect100Continue = false;
            rootServicePoint.ConnectionLimit   = 256;
            rootServicePoint.MaxIdleTime       = Timeout.Infinite;

            databaseCommandsGenerator = () =>
            {
                string databaseUrl = Url;
                if (string.IsNullOrEmpty(DefaultDatabase) == false)
                {
                    databaseUrl = rootDatabaseUrl;
                    databaseUrl = databaseUrl + "/databases/" + DefaultDatabase;
                }
                return(new ServerClient(new AsyncServerClient(databaseUrl, Conventions, new OperationCredentials(ApiKey, Credentials), jsonRequestFactory,
                                                              currentSessionId, GetReplicationInformerForDatabase, null,
                                                              Listeners.ConflictListeners, true)));
            };

            asyncDatabaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, new OperationCredentials(ApiKey, Credentials), jsonRequestFactory, currentSessionId, GetReplicationInformerForDatabase, null, Listeners.ConflictListeners, true);

                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };
        }
Example #3
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
#if !SILVERLIGHT
            var replicationInformer = new ReplicationInformer(Conventions);
            databaseCommandsGenerator = () =>
            {
                var serverClient = new ServerClient(Url, Conventions, credentials, replicationInformer, jsonRequestFactory, currentSessionId);
                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(serverClient);
                }
                return(serverClient.ForDatabase(DefaultDatabase));
            };
#endif
#if !NET_3_5
            asyncDatabaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId);
                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };
#endif
        }
Example #4
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
#if !SILVERLIGHT
            var rootDatabaseUrl  = MultiDatabase.GetRootDatabaseUrl(Url);
            var rootServicePoint = ServicePointManager.FindServicePoint(new Uri(rootDatabaseUrl));
            rootServicePoint.UseNagleAlgorithm = false;
            rootServicePoint.Expect100Continue = false;
            rootServicePoint.ConnectionLimit   = 256;

            databaseCommandsGenerator = () =>
            {
                string databaseUrl = Url;
                if (string.IsNullOrEmpty(DefaultDatabase) == false)
                {
                    databaseUrl = rootDatabaseUrl;
                    databaseUrl = databaseUrl + "/databases/" + DefaultDatabase;
                }
                return(new ServerClient(databaseUrl, Conventions, credentials, GetReplicationInformerForDatabase, null, jsonRequestFactory, currentSessionId, listeners.ConflictListeners));
            };
#endif

            asyncDatabaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId, GetReplicationInformerForDatabase, null, listeners.ConflictListeners);

                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };
        }
Example #5
0
        protected virtual void InitializeInternal()
        {
            ReplicationInformer replicationInformer = new ReplicationInformer(this.Conventions);

            this.databaseCommandsGenerator = (Func <IDatabaseCommands>)(() =>
            {
                ServerClient local_0 = new ServerClient(this.Url, this.Conventions, this.credentials, replicationInformer, this.jsonRequestFactory, DocumentStore.currentSessionId);
                if (string.IsNullOrEmpty(this.DefaultDatabase))
                {
                    return((IDatabaseCommands)local_0);
                }
                else
                {
                    return(local_0.ForDatabase(this.DefaultDatabase));
                }
            });
            this.asyncDatabaseCommandsGenerator = (Func <IAsyncDatabaseCommands>)(() =>
            {
                AsyncServerClient local_0 = new AsyncServerClient(this.Url, this.Conventions, this.credentials, this.jsonRequestFactory, DocumentStore.currentSessionId);
                if (string.IsNullOrEmpty(this.DefaultDatabase))
                {
                    return((IAsyncDatabaseCommands)local_0);
                }
                else
                {
                    return(local_0.ForDatabase(this.DefaultDatabase));
                }
            });
        }
Example #6
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
            var rootDatabaseUrl = MultiDatabase.GetRootDatabaseUrl(Url);

            databaseCommandsGenerator = () =>
            {
                string databaseUrl = Url;
                if (string.IsNullOrEmpty(DefaultDatabase) == false)
                {
                    databaseUrl = rootDatabaseUrl;
                    databaseUrl = databaseUrl + "/databases/" + DefaultDatabase;
                }
                return(new ServerClient(new AsyncServerClient(databaseUrl, Conventions, new OperationCredentials(ApiKey, Credentials), jsonRequestFactory,
                                                              currentSessionId, GetRequestExecuterForDatabase, GetRequestTimeMetricForDatabase, Changes, null,
                                                              Listeners.ConflictListeners, true, Conventions.ClusterBehavior)));
            };

            asyncDatabaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, new OperationCredentials(ApiKey, Credentials), jsonRequestFactory, currentSessionId, GetRequestExecuterForDatabase, GetRequestTimeMetricForDatabase, Changes, null, Listeners.ConflictListeners, true, Conventions.ClusterBehavior);

                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };
        }
Example #7
0
        private static async Task CheckReplicationStatusOfEachActiveDatabase(ServerRecord server, AsyncServerClient client, IAsyncDocumentSession session)
        {
            await HandleDatabaseInServerAsync(server, Constants.SystemDatabase, client, session);

            foreach (var databaseName in server.LoadedDatabases)
            {
                await HandleDatabaseInServerAsync(server, databaseName, client.ForDatabase(databaseName), session);
            }
        }
Example #8
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
#if !SILVERLIGHT && !NETFX_CORE
            var rootDatabaseUrl  = MultiDatabase.GetRootDatabaseUrl(Url);
            var rootServicePoint = ServicePointManager.FindServicePoint(new Uri(rootDatabaseUrl));
            rootServicePoint.UseNagleAlgorithm = false;
            rootServicePoint.Expect100Continue = false;
            rootServicePoint.ConnectionLimit   = 256;

            databaseCommandsGenerator = () =>
            {
                string databaseUrl = Url;
                if (string.IsNullOrEmpty(DefaultDatabase) == false)
                {
                    databaseUrl = rootDatabaseUrl;
                    databaseUrl = databaseUrl + "/databases/" + DefaultDatabase;
                }
                return(new ServerClient(new AsyncServerClient(databaseUrl, Conventions, new OperationCredentials(ApiKey, Credentials), jsonRequestFactory,
                                                              currentSessionId, GetReplicationInformerForDatabase, null,
                                                              listeners.ConflictListeners)));
            };
#endif

#if SILVERLIGHT
            WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
            WebRequest.RegisterPrefix("https://", WebRequestCreator.ClientHttp);

            // required to ensure just a single auth dialog
            var task = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(null, (Url + "/docs?pageSize=0").NoCache(), "GET", new OperationCredentials(ApiKey, Credentials), Conventions))
                       .ExecuteRequestAsync();

            jsonRequestFactory.ConfigureRequest += (sender, args) =>
            {
                args.JsonRequest.WaitForTask = task;
            };
#endif

            asyncDatabaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, new OperationCredentials(ApiKey, Credentials), jsonRequestFactory, currentSessionId, GetReplicationInformerForDatabase, null, listeners.ConflictListeners);

                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };
        }
Example #9
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
#if !SILVERLIGHT && !NETFX_CORE
            var rootDatabaseUrl  = MultiDatabase.GetRootDatabaseUrl(Url);
            var rootServicePoint = ServicePointManager.FindServicePoint(new Uri(rootDatabaseUrl));
            rootServicePoint.UseNagleAlgorithm = false;
            rootServicePoint.Expect100Continue = false;
            rootServicePoint.ConnectionLimit   = 256;

            databaseCommandsGenerator = () =>
            {
                string databaseUrl = Url;
                if (string.IsNullOrEmpty(DefaultDatabase) == false)
                {
                    databaseUrl = rootDatabaseUrl;
                    databaseUrl = databaseUrl + "/databases/" + DefaultDatabase;
                }
                return(new ServerClient(databaseUrl, Conventions, ApiKey, Credentials, GetReplicationInformerForDatabase, null, jsonRequestFactory, currentSessionId, listeners.ConflictListeners));
            };
#endif

            asyncDatabaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, ApiKey, Credentials, jsonRequestFactory, currentSessionId, GetReplicationInformerForDatabase, null, listeners.ConflictListeners);

                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };


#if SILVERLIGHT
            // required to ensure just a single auth dialog
            var task = asyncDatabaseCommandsGenerator().GetDocumentsAsync(0, 0, metadataOnly: true)
                       .ContinueWith(t =>
            {
                // we don't actually _care_ if we succeed or not here, we just care that we
                // issued this command and now will only have a single auth dialog
                return(t.Exception != null);
            });
            jsonRequestFactory.ConfigureRequest += (sender, args) =>
            {
                args.JsonRequest.WaitForTask = task;
            };
#endif
        }
Example #10
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
            var rootDatabaseUrl = MultiDatabase.GetRootDatabaseUrl(Url);

#if !DNXCORE50
            // TODO [ppekrol] how to set this?
            rootServicePoint = ServicePointManager.FindServicePoint(new Uri(rootDatabaseUrl));
            rootServicePoint.UseNagleAlgorithm = false;
            rootServicePoint.Expect100Continue = false;
            rootServicePoint.ConnectionLimit   = 256;
            rootServicePoint.MaxIdleTime       = Timeout.Infinite;
#endif

            databaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, new OperationCredentials(ApiKey, Credentials), jsonRequestFactory,
                                                              currentSessionId, GetRequestExecuterForDatabase, GetRequestTimeMetricForUrl, null,
                                                              Listeners.ConflictListeners, true);

                var serverClient = new ServerClient(asyncServerClient);

                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(serverClient);
                }
                return(serverClient.ForDatabase(DefaultDatabase));
            };

            asyncDatabaseCommandsGenerator = () =>
            {
                var asyncServerClient = new AsyncServerClient(Url, Conventions, new OperationCredentials(ApiKey, Credentials),
                                                              jsonRequestFactory, currentSessionId,
                                                              GetRequestExecuterForDatabase, GetRequestTimeMetricForUrl, null,
                                                              Listeners.ConflictListeners, true);

                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };
        }
Example #11
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
        protected virtual void InitializeInternal()
        {
#if !SILVERLIGHT
            var rootDatabaseUrl  = MultiDatabase.GetRootDatabaseUrl(Url);
            var rootServicePoint = ServicePointManager.FindServicePoint(new Uri(rootDatabaseUrl));
            rootServicePoint.UseNagleAlgorithm = false;
            rootServicePoint.Expect100Continue = false;
            rootServicePoint.ConnectionLimit   = 256;

            databaseCommandsGenerator = () =>
            {
                string databaseUrl = Url;
                if (string.IsNullOrEmpty(DefaultDatabase) == false)
                {
                    databaseUrl = rootDatabaseUrl;
                    databaseUrl = databaseUrl + "/databases/" + DefaultDatabase;
                }
                return(new ServerClient(databaseUrl, Conventions, credentials, GetReplicationInformerForDatabase, null, jsonRequestFactory, currentSessionId));
            };
#endif
#if !NET35
#if SILVERLIGHT
            // required to ensure just a single auth dialog
            var task = jsonRequestFactory.CreateHttpJsonRequest(new CreateHttpJsonRequestParams(this, (Url + "/docs?pageSize=0").NoCache(), "GET", credentials, Conventions))
                       .ExecuteRequestAsync();
#endif
            asyncDatabaseCommandsGenerator = () =>
            {
#if SILVERLIGHT
                var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId, task, GetReplicationInformerForDatabase, null);
#else
                var asyncServerClient = new AsyncServerClient(Url, Conventions, credentials, jsonRequestFactory, currentSessionId, GetReplicationInformerForDatabase, null);
#endif
                if (string.IsNullOrEmpty(DefaultDatabase))
                {
                    return(asyncServerClient);
                }
                return(asyncServerClient.ForDatabase(DefaultDatabase));
            };
#endif
        }