private IEnumerable <DomainObject <int> > GetMessages(String text, int projectId)
        {
            Exp messWhere;

            List <int> messIds;

            if (FactoryIndexer <DiscussionsWrapper> .TrySelectIds(s => s.MatchAll(text), out messIds))
            {
                messWhere = Exp.In("t.id", messIds);
            }
            else
            {
                messWhere = BuildLike(new[] { "t.title", "t.content" }, text, projectId);
            }

            return(MessageDao.GetMessages(messWhere));
        }
        private IEnumerable <DomainObject <int> > GetMessages(String text, int projectId)
        {
            Exp messWhere;

            if (FullTextSearch.SupportModule(FullTextSearch.ProjectsMessagesModule))
            {
                var messIds = FullTextSearch.Search(FullTextSearch.ProjectsMessagesModule.Match(text));

                messWhere = Exp.In("t.id", messIds);
            }
            else
            {
                messWhere = BuildLike(new[] { "t.title", "t.content" }, text, projectId);
            }

            return(MessageDao.GetMessages(messWhere));
        }
示例#3
0
        public IList Search(String text, int projectId)
        {
            var projWhere = Exp.Empty;
            var mileWhere = Exp.Empty;
            var messWhere = Exp.Empty;
            var taskWhere = Exp.Empty;

            if (FullTextSearch.SupportModule(FullTextSearch.ProjectsModule))
            {
                var searched = FullTextSearch.Search(text, FullTextSearch.ProjectsModule);

                var projIds = GetIdentifiers(searched, projectId, EntityType.Project);
                if (0 < projIds.Length) projWhere = Exp.In("id", projIds);
                
                var mileIds = GetIdentifiers(searched, projectId, EntityType.Milestone);
                if (0 < mileIds.Length) mileWhere = Exp.In("t.id", mileIds);
                
                var messIds = GetIdentifiers(searched, projectId, EntityType.Message);
                if (0 < messIds.Length) messWhere = Exp.In("t.id", messIds);
                
                var taskIds = GetIdentifiers(searched, projectId, EntityType.Task);
                if (0 < taskIds.Length) taskWhere = Exp.In("t.id", taskIds);
            }
            else
            {
                var keywords = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                    .Where(k => 3 <= k.Trim().Length)
                    .ToArray();
                if (keywords.Length == 0) return new ArrayList();

                var projIdWhere = 0 < projectId ? Exp.Eq("p.id", projectId) : Exp.Empty;
                projWhere = BuildLike(new[] { "title", "description" }, keywords, true) & projIdWhere;
                mileWhere = BuildLike(new[] { "t.title" }, keywords, true) & projIdWhere;
                messWhere = BuildLike(new[] { "t.title", "t.content" }, keywords, true) & projIdWhere;
                taskWhere = BuildLike(new[] { "t.title", "t.description" }, keywords, true) & projIdWhere;
            }

            var result = new ArrayList();

            if (projWhere != Exp.Empty)
            {
                var projDao = new ProjectDao(DatabaseId, Tenant);
                result.AddRange(projDao.GetProjects(projWhere));
            }
            if (mileWhere != Exp.Empty)
            {
                var mileDao = new MilestoneDao(DatabaseId, Tenant);
                result.AddRange(mileDao.GetMilestones(mileWhere));
            }
            if (messWhere != Exp.Empty)
            {
                var messDao = new MessageDao(DatabaseId, Tenant);
                result.AddRange(messDao.GetMessages(messWhere));
            }
            if (taskWhere != Exp.Empty)
            {
                var taskDao = new TaskDao(DatabaseId, Tenant);
                result.AddRange(taskDao.GetTasks(taskWhere));
            }

            return result;
        }
示例#4
0
        public IList Search(String text, int projectId)
        {
            var projWhere = Exp.Empty;
            var mileWhere = Exp.Empty;
            var messWhere = Exp.Empty;
            var taskWhere = Exp.Empty;

            if (FullTextSearch.SupportModule(FullTextSearch.ProjectsModule))
            {
                var searched = FullTextSearch.Search(text, FullTextSearch.ProjectsModule);

                var projIds = GetIdentifiers(searched, projectId, EntityType.Project);
                if (0 < projIds.Length)
                {
                    projWhere = Exp.In("id", projIds);
                }

                var mileIds = GetIdentifiers(searched, projectId, EntityType.Milestone);
                if (0 < mileIds.Length)
                {
                    mileWhere = Exp.In("t.id", mileIds);
                }

                var messIds = GetIdentifiers(searched, projectId, EntityType.Message);
                if (0 < messIds.Length)
                {
                    messWhere = Exp.In("t.id", messIds);
                }

                var taskIds = GetIdentifiers(searched, projectId, EntityType.Task);
                if (0 < taskIds.Length)
                {
                    taskWhere = Exp.In("t.id", taskIds);
                }
            }
            else
            {
                var keywords = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                               .Where(k => 3 <= k.Trim().Length)
                               .ToArray();
                if (keywords.Length == 0)
                {
                    return(new ArrayList());
                }

                var projIdWhere = 0 < projectId?Exp.Eq("p.id", projectId) : Exp.Empty;

                projWhere = BuildLike(new[] { "title", "description" }, keywords, true) & projIdWhere;
                mileWhere = BuildLike(new[] { "t.title" }, keywords, true) & projIdWhere;
                messWhere = BuildLike(new[] { "t.title", "t.content" }, keywords, true) & projIdWhere;
                taskWhere = BuildLike(new[] { "t.title", "t.description" }, keywords, true) & projIdWhere;
            }

            var result = new ArrayList();

            if (projWhere != Exp.Empty)
            {
                var projDao = new ProjectDao(DatabaseId, Tenant);
                result.AddRange(projDao.GetProjects(projWhere));
            }
            if (mileWhere != Exp.Empty)
            {
                var mileDao = new MilestoneDao(DatabaseId, Tenant);
                result.AddRange(mileDao.GetMilestones(mileWhere));
            }
            if (messWhere != Exp.Empty)
            {
                var messDao = new MessageDao(DatabaseId, Tenant);
                result.AddRange(messDao.GetMessages(messWhere));
            }
            if (taskWhere != Exp.Empty)
            {
                var taskDao = new TaskDao(DatabaseId, Tenant);
                result.AddRange(taskDao.GetTasks(taskWhere));
            }

            return(result);
        }