コード例 #1
0
        public static void CreateIndexes()
        {
            using (var nctxs = ContextRegistry.NamedContextsFor(typeof(DeviceManager)))
            {
                using (var session = DocumentStoreLocator.ContextualResolve())
                {
                    var config = Catalog.Factory.Resolve <IConfig>();
                    var dbName = config[CommonConfiguration.DefaultDataDatabase];

                    var tenancyUris = ContextRegistry.ContextsOf("Tenancy");
                    if (tenancyUris.Any())
                    {
                        var tenancyUri = tenancyUris.First();
                        var tenancy    = tenancyUri.Segments.Count() > 1 ? tenancyUri.Segments[1] : string.Empty;

                        if (!string.IsNullOrEmpty(tenancy)
                            &&
                            !tenancy.Equals(Tenants.SystemOwner, StringComparison.InvariantCultureIgnoreCase))
                        {
                            dbName = tenancy;
                        }
                    }

                    var store = session.Advanced.DocumentStore;
                    IndexesManager.CreateIndexes(store, dbName, typeof(AllDeviceIndex));
                }
            }
        }
コード例 #2
0
 public static void CreateIndexes()
 {
     using (var session = DocumentStoreLocator.ResolveOrRoot(CommonConfiguration.CoreDatabaseRoute))
     {
         var config = Catalog.Factory.Resolve <IConfig>();
         var dbName = config[CommonConfiguration.DefaultDataDatabase];
         IndexesManager.CreateIndexes(session.Advanced.DocumentStore, dbName, typeof(ApplicationUser_ByUserName));
     }
 }