Ejemplo n.º 1
0
        private IEnumerable <DomainObject <int> > GetMilestones(String text, int projectId)
        {
            Exp mileWhere;

            if (FullTextSearch.SupportModule(FullTextSearch.ProjectsMilestonesModule))
            {
                var mileIds = FullTextSearch.Search(FullTextSearch.ProjectsMilestonesModule.Match(text));
                mileWhere = Exp.In("t.id", mileIds);
            }
            else
            {
                mileWhere = BuildLike(new[] { "t.title" }, text, projectId);
            }

            return(MilestoneDao.GetMilestones(mileWhere));
        }
        private IEnumerable <DomainObject <int> > GetMilestones(String text, int projectId)
        {
            Exp mileWhere;

            List <int> mileIds;

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

            return(MilestoneDao.GetMilestones(mileWhere));
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }