private IEnumerable <DomainObject <int> > GetTasks(String text, int projectId) { Exp taskWhere; List <int> taskIds; if (FactoryIndexer <TasksWrapper> .TrySelectIds(s => s.MatchAll(text), out taskIds)) { taskWhere = Exp.In("t.id", taskIds); } else { taskWhere = BuildLike(new[] { "t.title", "t.description" }, text, projectId); } return(TaskDao.GetTasks(taskWhere)); }
private IEnumerable <DomainObject <int> > GetTasks(String text, int projectId) { Exp taskWhere; if (FullTextSearch.SupportModule(FullTextSearch.ProjectsTasksModule)) { var taskIds = FullTextSearch.Search(FullTextSearch.ProjectsTasksModule.Match(text)); taskWhere = Exp.In("t.id", taskIds); } else { taskWhere = BuildLike(new[] { "t.title", "t.description" }, text, projectId); } return(TaskDao.GetTasks(taskWhere)); }
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; }
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); }