Пример #1
0
        public static void AddOrUpdate(MyPhoto.Entities.Entity.User user)
        {
            var search = new SearchbleUser(user);
            UserSearchDocument searchDoc = new UserSearchDocument(search);

            IndexBuilder.SaveOrUpdateDocument(searchDoc);
            IndexBuilder.BuildSpellIndex(search.Spell.ToList());
        }
Пример #2
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            this.container = container;
            OpenIdConnectAuthenticationModule.ClaimsRecieved(this.ClaimsRecieved);
            var controllers = Assembly.GetAssembly(typeof(WebInstaller)).GetTypes().Where(x => typeof(Controller).IsAssignableFrom(x));
            foreach (Type controller in controllers)
            {
                container.Register(Component.For(controller).LifeStyle.Transient);
            }
            sf = BuildSessionFactory();
            using (var session = sf.OpenSession())
            using (var tx = session.BeginTransaction())
            {
                var photos = session.Query<MyPhoto.Entities.Entity.Photo>().ToList();
                foreach (var item in photos)
                {
                    PhotoSearchDocument searchDoc = new PhotoSearchDocument(new SearchblePhoto(item));
                    IndexBuilder.SaveOrUpdateDocument(searchDoc);
                }

                var users = session.Query<MyPhoto.Entities.Entity.User>().ToList();
                foreach (var item in users)
                {
                    UserSearchDocument searchDoc = new UserSearchDocument(new SearchbleUser(item));
                    IndexBuilder.SaveOrUpdateDocument(searchDoc);
                }

            }
            container.Register(
                Component.For<SecurityManager>().LifeStyle.PerWebRequest,
                Component.For<ISessionFactory>().UsingFactoryMethod(x => BuildSessionFactory()).LifeStyle.Singleton,
                Component.For<ISession>()
                    .UsingFactoryMethod(x => OpenSession()).LifeStyle.PerWebRequest
                    .OnDestroy(x => CloseSession(x))
                    );
        }