示例#1
0
        public static IEnumerable<RavenIndexGraphModel> GetIndexGraphs(RavenConfig ravenConfig)
        {
            var indexDataModels =
                ravenConfig.Stores
                    .SelectMany(store =>
                                store.Servers.Select(
                                    server =>
                                    new
                                        {
                                            StoreName = store.Name,
                                            ServerName = server.Name,
                                            IndexNames = GetIndexNames(server, store)
                                        }))
                    .SelectMany(flattenedByServer =>
                                flattenedByServer.IndexNames.Select(
                                    indexName =>
                                    new RavenIndexDataModel
                                        {
                                            StoreName = flattenedByServer.StoreName,
                                            ServerName = flattenedByServer.ServerName,
                                            IndexName = indexName,
                                        }))
                    .Where(indexData => IndexNameFilters.All(f => f(indexData.IndexName)))
                    .ToArray();

            var graphs = ReduceFlattenedDataIntoGraphs(indexDataModels);

            return graphs;
        }
示例#2
0
        public QueryIntegrationTestBase()
        {
            var conf  = new ConfigurationBuilder().AddJsonFile("appsettings.json", true, true).Build();
            var rconf = RavenConfig.FromConfiguration(conf);

            DocumentStore = new RavenDocumentStoreFactory().CreateDocumentStore(rconf);
        }
示例#3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes,
                                       path => ObjectFactory.Container.GetInstance <IDocumentService>().GetDocument(path),
                                       document => new[] {
                new DocumentRoutingInfo {
                    Controller = "Page", Action = "Archive", Pattern = "archive/{year}/{month}"
                },
                new DocumentRoutingInfo {
                    Controller = "Page", Action = "Archive", Pattern = "archive/{year}"
                },
                new DocumentRoutingInfo {
                    Controller = "Page", Action = "Archive", Pattern = "archive"
                },
                new DocumentRoutingInfo {
                    Controller = "Page", Action = "Index"
                }
            });
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            RavenConfig.Initialize(ObjectFactory.Container);
        }
        public void CanConnectToServer()
        {
            var conf  = new ConfigurationBuilder().AddJsonFile("appsettings.json", true, true).Build();
            var rconf = RavenConfig.FromConfiguration(conf);
            var store = new RavenDocumentStoreFactory().CreateDocumentStore(rconf);

            using (var s = store.OpenSession()) { }
        }
示例#5
0
        private Guid GetEtag(RavenConfig pending)
        {
            if (pending != null && !string.IsNullOrWhiteSpace(pending.Id))
            {
                return(this.RavenSession.Advanced.GetEtagFor(pending).Value);
            }

            return(Guid.Empty);
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            DocumentStore = RavenConfig.Init();
        }
示例#7
0
        private Guid GetEtag(RavenConfig pending)
        {
            if (pending != null && !string.IsNullOrWhiteSpace(pending.Id))
            {
                return this.RavenSession.Advanced.GetEtagFor(pending).Value;
            }

            return Guid.Empty;
        }
        private static IDocumentStore Init(IContext context)
        {
            var documentStore = new DocumentStore
            {
                ConnectionStringName = "RavenDb"
            }.Initialize();

            RavenConfig.Register(typeof(UserByIdIndex), documentStore);

            return(documentStore);
        }
示例#9
0
        private static IDocumentStore InitDocStore(IContext context)
        {
            var documentStore = new DocumentStore
            {
                Urls     = new[] { "http://127.0.0.1:3001" },
                Database = "WSUT"
            }.Initialize();

            RavenConfig.Register(typeof(IndexEmailConfirmationKey), documentStore);

            return(documentStore);
        }
 protected void ThrowIfEtagDoesNotMatch(RavenConfig config, Guid originalEtag)
 {
     var currentEtag = (config.Id == null) ?
         Guid.Empty :
         this.RavenSession.Advanced.GetEtagFor(config).Value;
     if (originalEtag != currentEtag)
     {
         throw new InvalidOperationException(
             "The Raven config was modified by someone else or in a different browser window. " +
             "Refresh the page to load the current version.");
     }
 }
示例#11
0
        protected void ThrowIfEtagDoesNotMatch(RavenConfig config, Guid originalEtag)
        {
            var currentEtag = (config.Id == null) ?
                              Guid.Empty :
                              this.RavenSession.Advanced.GetEtagFor(config).Value;

            if (originalEtag != currentEtag)
            {
                throw new InvalidOperationException(
                          "The Raven config was modified by someone else or in a different browser window. " +
                          "Refresh the page to load the current version.");
            }
        }
示例#12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var ravenConfig = new RavenConfig();

            Configuration.GetSection("RavenDbConfig").Bind(ravenConfig);
            services.ConfigureApplicationCookie(options =>
            {
                // Cookie settings
                options.Cookie.HttpOnly = true;
                options.ExpireTimeSpan  = TimeSpan.FromMinutes(20);

                options.LoginPath         = "/Login";
                options.AccessDeniedPath  = "/Error";
                options.SlidingExpiration = true;
            });
            services.AddRavenDbAsyncSession(connectionString: $"Database={ravenConfig.DBName};Urls={ravenConfig.Url}");
            services.AddIdentity <ApplicationUser, ApplicationRole>(options => {
                options.Password.RequireDigit           = true;
                options.Password.RequireLowercase       = false;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = false;
                options.Password.RequiredLength         = 6;
                options.Password.RequiredUniqueChars    = 1;
            }).AddRavenDbStores()
            .AddDefaultTokenProviders();

            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme);
            services.AddScoped <ITweetRepo, TweetRepo>();
            services.AddScoped <IFollowingRepo, FollowingRepo>();
            services.AddSession();

            services.AddRazorPages()
            .AddViewOptions(options => options.HtmlHelperOptions.ClientValidationEnabled = true)
            .AddRazorPagesOptions(options => {
                options.Conventions.AddPageRoute("/Account/Login", "");
                options.Conventions.AuthorizeFolder("/SecuredPage");
            });
        }
示例#13
0
        static IHostBuilder CreateHostBuilder(string[] args)
        => Host.CreateDefaultBuilder()
        .ConfigureServices((hostContext, services) =>
        {
            var docStore = new RavenDocumentStoreFactory().CreateAndInitializeDocumentStore(RavenConfig.FromConfiguration(hostContext.Configuration));
            services.AddSingleton(docStore);
            services.AddSingleton <INoSqlStore, DefensiveRavenDbProjectionsStore>();
            services.AddSingleton <ISqlStore, DefensiveRavenDbProjectionsStore>();
            services.AddTransient <IQueryById, QueryById>();
            services.AddTransient <ICheckpointReader, RavenDbCheckpointReader>();
            services.AddTransient <ICheckpointWriter, RavenDbCheckpointWriter>();
            services.AddTransient <IHandlerFactory, DIHandlerFactory>();
            services.AddTransient <ISubscriptionFactory, ESSubscriptionFactory>();
            services.AddTransient <IProjectionsFactory, ProjectionsFactory>();
            services.AddTransient <IJSProjectionsFactory, JSProjectionsFactory>();

            RegisterProjectionHandlers(services);

            services.AddHostedService <ServiceInstance>();
        })
        .ConfigureHostConfiguration(configHost =>
        {
            configHost.SetBasePath(Directory.GetCurrentDirectory());
            configHost.AddJsonFile("appsettings.json", optional: false);
            configHost.AddEnvironmentVariables(prefix: "STARNET_");
            configHost.AddCommandLine(args);
        });
示例#14
0
        internal static void UpdateAllStores(RavenConfig ravenConfig)
        {
            LogBuffer.Current.LogPriority = LogPriority.Application;

            lock (AllStores)
            {
                RavenConfig = ravenConfig ?? new RavenConfig();

                foreach (var store in AllStores)
                {
                    store.UpdateInnerStore();
                }
            }
        }
 IDocumentStore CreateRavenDbDocumentStore()
 => new RavenDocumentStoreFactory().CreateAndInitializeDocumentStore(RavenConfig.FromConfiguration(Configuration));
        private List<ReplicationInfo> StartGatheringRavenReplicationInformation(RavenConfig ravenConfig)
        {
            var ravenReplicationInformation = new List<ReplicationInfo>();

            foreach (var store in ravenConfig.Stores)
            {
                foreach (var server in store.Servers)
                {
                    var replicationSourceDocumentsUrl = RavenHelper.GetStoreUrl(server.Name, store.Name, "/docs?startsWith=Raven/Replication/Sources/");
                    var serverStatsDocumentUrl = RavenHelper.GetStoreUrl(server.Name, store.Name, "/stats");
                    var serverUrl = RavenHelper.GetStoreUrl(server.Name);
                    var replicationInfo = new ReplicationInfo(server.Name, store.Name, serverUrl);

                    ravenReplicationInformation.Add(replicationInfo);

                    this.SendRequests(replicationInfo, serverStatsDocumentUrl, replicationSourceDocumentsUrl);
                }
            }

            return ravenReplicationInformation;
        }