public void should_query_with_special_string()
        {
            LuceneSearchProvider lueceneSearchProvider = new LuceneSearchProvider();

            var spaceOne = new SpaceObject
            {
                Id = Guid.NewGuid(),
                SpaceName = "技术空间",
                FileCount = 1,
                ParentId = Guid.NewGuid().ToString(),
                SpaceSize = 1024,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                CreateUserId = "5",
                CreateUserName = "******",

            };
            lueceneSearchProvider.Add(spaceOne);

            var results = lueceneSearchProvider.Query<SpaceObject>("*****");
            Assert.AreEqual(results.Count, 0);

            results = lueceneSearchProvider.Query<SpaceObject>("#@RF**__++||");
            Assert.AreEqual(results.Count, 0);

            results = lueceneSearchProvider.Query<SpaceObject>(" || __    ");
            Assert.AreEqual(results.Count, 0);
        }
        public void performance_test_with_writeindex()
        {
            LuceneSearchProvider _lueceneSearchProvider = new LuceneSearchProvider();

            List<SpaceObject> list = new List<SpaceObject>();
            for (int i = 0; i < 100000; i++)
            {
                var space = new SpaceObject
                              {
                                  Id = Guid.NewGuid(),
                                  SpaceName = "技术空间",
                                  FileCount = 1,
                                  ParentId = Guid.NewGuid().ToString(),
                                  SpaceSize = 1024,
                                  CreateTime = DateTime.Now,
                                  UpdateTime = DateTime.Now,
                                  CreateUserId = "5",
                                  CreateUserName = "******",

                              };
                list.Add(space);
            }

            Stopwatch stopWatcher = new Stopwatch();
            stopWatcher.Start();

            _lueceneSearchProvider.AddList(list, true);

            stopWatcher.Stop();
            Console.WriteLine("创建时间为<毫秒>:" + stopWatcher.ElapsedMilliseconds);
        }
Exemplo n.º 3
0
 public ActionResult Add(string Id)
 {
     var space = new SpaceObject();
     if (!string.IsNullOrEmpty(Id))
     {
         space.ParentId = Id;
     }
     return View(space);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 添加文件夹
        /// </summary>
        /// <param name="space"></param>
        /// <returns></returns>
        public SpaceObject Add(SpaceObject space)
        {
            _logger.Info("Add");

            space = _spaceRepository.Add(space.ToEntity<Space>()).ToObject<SpaceObject>();
            if (space != null)
            {
                _bus.Send(new CreateSpaceMessage { Content = space });
                _cacheService.Add(space);
            }

            return space;
        }
Exemplo n.º 5
0
 public void Add(SpaceObject space)
 {
     List<SpaceObject> cache = GetCache<List<SpaceObject>>(GenerateKey());
     if (cache != null && cache.Count > 0)
     {
         var result = cache.Find(f => f != null && f.Id.ToString() == space.Id.ToString());
         if (result == null)
         {
             cache.Add(space);
             _cachePolicy.Set(GenerateKey(), cache);
         }
     }
 }
Exemplo n.º 6
0
 public void Update(SpaceObject space)
 {
     List<SpaceObject> cache = GetCache<List<SpaceObject>>(GenerateKey());
     if (cache != null && cache.Count > 0)
     {
         for (int i = 0; i < cache.Count; ++i)
         {
             if (cache[i] != null && cache[i].Id.ToString() == space.Id.ToString())
             {
                 cache[i] = space.ToObject<SpaceObject>();
                 _cachePolicy.Set(GenerateKey(), cache);
                 break;
             }
         }
     }
 }
Exemplo n.º 7
0
 private static SpaceObject MakeSimpleSpace(string userId, string depId)
 {
     var space = new SpaceObject
     {
         Id = Guid.NewGuid(),
         CreateTime = DateTime.Now,
         UpdateTime = DateTime.Now,
         CreateUserId = userId,
         CreateUserName = "******",
         SpaceName = "技术空间",
         DepId = depId,
         SpaceSeqNo = Guid.NewGuid().ToString(),
         FileCount = 1,
         ParentId = Guid.NewGuid().ToString(),
         SpaceSize = 1024,
     };
     return space;
 }
Exemplo n.º 8
0
 private static SpaceObject MakeSpaceContract(string parentId, string spaceSeqNo, string name, string userId, string userName, string depId, int visible)
 {
     var spaceObject = new SpaceObject
     {
         Id = Guid.NewGuid(),
         SpaceSeqNo = spaceSeqNo,
         SpaceName = name,
         UpdateTime = DateTime.Now,
         CreateTime = DateTime.Now,
         ParentId = parentId,
         CreateUserId = userId,
         CreateUserName = userName,
         Visible = visible,
         DepId = depId,
     };
     return spaceObject;
 }
Exemplo n.º 9
0
        /// <summary>
        /// 修改文件夹
        /// </summary>
        /// <param name="space"></param>
        /// <returns></returns>
        public SpaceObject Update(SpaceObject space)
        {
            _logger.Info("Update");

            space = _spaceRepository.Update(f => f.Id == space.Id, space.ToEntity<Space>()).ToObject<SpaceObject>();
            if (space != null)
            {
                _cacheService.Update(space);
                _bus.Send(new UpdateSpaceMessage { Content = space });
            }

            return space;
        }
Exemplo n.º 10
0
 public void Update(SpaceObject space)
 {
     _cacheService.Update(space);
     SetCache(GenerateKey(space.Id.ToString()), space);
 }
Exemplo n.º 11
0
 public SpaceObject GetOrAdd(string id, SpaceObject document)
 {
     return base.GetOrAdd(GenerateKey(id), document);
 }
Exemplo n.º 12
0
        private static List<object> InitialzeData()
        {
            List<object> list = new List<object>();

            var space = new SpaceObject
            {
                Id = Guid.NewGuid(),
                CreateUserId = "1",
                SpaceName = "昆明空间",
                UpdateTime = DateTime.Parse("2014-06-21"),
                CreateTime = DateTime.Parse("2014-06-21")
            };
            var space2 = new SpaceObject
            {
                Id = Guid.NewGuid(),
                CreateUserId = "1",
                SpaceName = "技术空间",
                UpdateTime = DateTime.Parse("2014-06-21"),
                CreateTime = DateTime.Parse("2014-06-21")
            };
            list.Add(space);
            list.Add(space2);
            return list;
        }
        public void test_with_write_and_delete_document()
        {
            var lueceneSearchProvider = new LuceneSearchProvider();

            var spaceOne = new SpaceObject
            {
                Id = Guid.NewGuid(),
                SpaceName = "技术空间",
                FileCount = 1,
                ParentId = Guid.NewGuid().ToString(),
                SpaceSize = 1024,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                CreateUserId = "5",
                CreateUserName = "******",
            };

            Stopwatch stopWatcher = new Stopwatch();
            stopWatcher.Start();

            lueceneSearchProvider.IndexDirectory = "write_delete_space";
            lueceneSearchProvider.Add(spaceOne);

            var results = lueceneSearchProvider.Query<SpaceObject>("空间");
            Assert.IsTrue(results.Count>= 1);

            lueceneSearchProvider.Delete(spaceOne);
            results = lueceneSearchProvider.Query<SpaceObject>("空间");
            Assert.AreEqual(results.Count, 0);

            Console.WriteLine(results.Count);
        }
Exemplo n.º 14
0
        private SpaceObject TestVisiblity(SpaceObject space, Visible visible, ref SpaceObject childspace,
            ref SpaceObject childspace2, ref SpaceObject childspace_son)
        {
            space = _spaceService.SetVisiblity(space.Id.ToString(), visible);
            space = _spaceService.GetSpace(space.Id.ToString());
            Assert.IsTrue(space.Visible == (int) visible);

            childspace = _spaceService.GetSpace(childspace.Id.ToString());
            Assert.IsTrue(childspace.Visible == (int) visible);

            childspace2 = _spaceService.GetSpace(childspace2.Id.ToString());
            Assert.IsTrue(childspace2.Visible == (int) visible);

            childspace_son = _spaceService.GetSpace(childspace_son.Id.ToString());
            Assert.IsTrue(childspace_son.Visible == (int) visible);
            return space;
        }
        public void test_with_write_index_singleton()
        {
            LuceneSearchProvider lueceneSearchProvider = new LuceneSearchProvider();

            var spaceOne = new SpaceObject
            {
                Id = Guid.NewGuid(),
                SpaceName = "技术空间",
                FileCount = 1,
                ParentId = Guid.NewGuid().ToString(),
                SpaceSize = 1024,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                CreateUserId = "5",
                CreateUserName = "******",

            };

            var spaceTwo = new SpaceObject
            {
                Id = Guid.NewGuid(),
                SpaceName = "生存空间",
                FileCount = 1,
                ParentId = Guid.NewGuid().ToString(),
                SpaceSize = 1024,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now,
                CreateUserId = "5",
                CreateUserName = "******",

            };

            Stopwatch stopWatcher = new Stopwatch();
            stopWatcher.Start();

            lueceneSearchProvider.IndexDirectory = "tempspace";
            lueceneSearchProvider.Add(spaceOne);
            lueceneSearchProvider.Add(spaceTwo);

            var results = lueceneSearchProvider.Query<SpaceObject>("空间");
            Assert.IsTrue(results.Count>= 2);

            Console.WriteLine(results.Count);
        }
Exemplo n.º 16
0
 public SpaceViewModel(SpaceObject documentObject, string userId)
 {
     SpaceObject = documentObject;
     UserId = userId;
 }
Exemplo n.º 17
0
        private HomeViewModel BuildHomeViewModel(SpaceObject space, int page, string pageCodeType)
        {
            var documents = _documentService.GetVisibleDocuments( _contextService.UserId,
                                                                  _contextService.DepId,
                                                                  f=>f.SpaceId == space.Id.ToString());

            var childSpaces = _spaceService.GetChildren(space.Id.ToString(), _contextService.UserId, _contextService.DepId);
            var parentSpaces = _spaceService.GetParentsChain(space.Id.ToString());

            var homeViewModels = new HomeViewModel
            {
                CurrentSpace = new SpaceViewModel(space, _contextService.UserId),
                Documents = new DocumentViewModelCollection(documents, _contextService.UserId),

                ChildSpaces = new SpaceViewModelCollection(childSpaces, _contextService.UserId),
                ParentSpaces = new SpaceViewModelCollection(parentSpaces, _contextService.UserId),
                ActiveMenuType = MenuType.All,
                PageCode = PageService.GetPageCode(documents.Count, page, pageCodeType),
            };

            CurrentMenu = MenuType.All;
            _contextService.CurrentSpace = homeViewModels.CurrentSpace.SpaceObject;

            if (string.IsNullOrEmpty(_contextService.SpaceTreeHtml))
            {
                _contextService.SpaceTreeHtml = _spaceTreeService.GetOrSetSpaceTree(_contextService.UserId);
            }

            return homeViewModels;
        }
Exemplo n.º 18
0
        private static List<object> InitializeData()
        {
            List<object> list = new List<object>();

            list.Add(new DocumentObject
                         {
                             Id = Guid.NewGuid(),
                             DisplayPath = "http://localhost/view/1",

                             CreateTime = DateTime.Parse("2014-08-21"),
                             FileSize = 1024,
                             UpdateTime = DateTime.Parse("2014-08-21"),
                             DocumentType = DocumentType.PPT,
                             StorePath = Environment.CurrentDirectory + @"\TestFiles\智慧市政综合指挥平台97format.ppt",
                             FileName = "智慧市政综合指挥平台97format.ppt"
                         });

            list.Add(new DocumentObject
                         {
                             Id = Guid.NewGuid(),
                             DisplayPath = "http://localhost/view/1",

                             CreateTime = DateTime.Parse("2014-06-21"),
                             FileSize = 1024,
                             UpdateTime = DateTime.Parse("2014-06-21"),
                             DocumentType = DocumentType.PPT,
                             StorePath = Environment.CurrentDirectory + @"\TestFiles\Yapa   Tech.ppt",
                             FileName = "Yapa   Tech.ppt"
                         });

            list.Add(new DocumentObject
                         {
                             Id = Guid.NewGuid(),
                             DisplayPath = "http://localhost/view/1",

                             CreateTime = DateTime.Now,
                             FileSize = 1024,
                             UpdateTime = DateTime.Now,
                             DocumentType = DocumentType.Excel,
                             StorePath = Environment.CurrentDirectory + @"\TestFiles\报价明细表97format.xls",
                             FileName = "圣诞报价明细表97format.xls"
                         });

            list.Add(new DocumentObject
                           {
                               Id = Guid.NewGuid(),
                               DisplayPath = "http://localhost/view/1",

                               CreateTime = DateTime.Now,
                               FileSize = 1024,
                               UpdateTime = DateTime.Now,
                               DocumentType = DocumentType.Word,
                               StorePath = Environment.CurrentDirectory + @"\TestFiles\智慧市政综合指挥平台97format.doc",
                               FileName = "智慧市政综合指挥平台97format.doc"
                           });

            var space = new SpaceObject
                            {
                                Id = Guid.NewGuid(),
                                CreateUserId = "1",
                                SpaceName = "智慧市政",
                                UpdateTime = DateTime.Parse("2014-08-21"),
                                CreateTime = DateTime.Parse("2014-08-21")

                            };
            list.Add(space);
            return list;
        }