Example #1
0
        private static Task ToTask(object[] r)
        {
            var offset    = ProjectDao.ProjectColumns.Length;
            var deadline  = Convert.ToDateTime(r[11 + offset]);
            var startDate = Convert.ToDateTime(r[12 + offset]);
            var task      = new Task
            {
                Project                                               = r[0] != null?ProjectDao.ToProject(r) : null,
                                                     ID               = Convert.ToInt32(r[0 + offset]),
                                                     Title            = (string)r[1 + offset],
                                                     CreateBy         = ToGuid(r[2 + offset]),
                                                     CreateOn         = TenantUtil.DateTimeFromUtc(Convert.ToDateTime(r[3 + offset])),
                                                     LastModifiedBy   = ToGuid(r[4 + offset]),
                                                     LastModifiedOn   = TenantUtil.DateTimeFromUtc(Convert.ToDateTime(r[5 + offset])),
                                                     Description      = (string)r[6 + offset],
                                                     Priority         = (TaskPriority)Convert.ToInt32(r[7 + offset]),
                                                     Status           = (TaskStatus)Convert.ToInt32(r[8 + offset]),
                                                     Milestone        = r[9 + offset] == null ? 0 : Convert.ToInt32(r[9 + offset]),
                                                     SortOrder        = Convert.ToInt32(r[10 + offset]),
                                                     Deadline         = !deadline.Equals(DateTime.MinValue) ? DateTime.SpecifyKind(deadline, DateTimeKind.Local) : default(DateTime),
                                                     StartDate        = !startDate.Equals(DateTime.MinValue) ? DateTime.SpecifyKind(startDate, DateTimeKind.Local) : default(DateTime),
                                                     Progress         = Convert.ToInt32(r[13 + offset]),
                                                     Responsibles     = !string.IsNullOrEmpty((string)r[14 + offset]) ? new List <Guid>(((string)r[14 + offset]).Split(',').Select(ToGuid)) : new List <Guid>(),
                                                     SubTasks         = new List <Subtask>(),
                                                     CustomTaskStatus = r[15 + offset] != null ? (int?)Convert.ToInt32(r[15 + offset]) : null
            };

            return(task);
        }
Example #2
0
        private Task ToTask(object[] r)
        {
            var offset = ProjectDao.PROJECT_COLUMNS.Length;
            var task   = new Task
            {
                Project                                           = r[0] != null?ProjectDao.ToProject(r) : null,
                                                   ID             = Convert.ToInt32(r[0 + offset]),
                                                   Title          = (string)r[1 + offset],
                                                   CreateBy       = ToGuid(r[2 + offset]),
                                                   CreateOn       = TenantUtil.DateTimeFromUtc((DateTime)r[3 + offset]),
                                                   LastModifiedBy = ToGuid(r[4 + offset]),
                                                   LastModifiedOn = TenantUtil.DateTimeFromUtc((DateTime)r[5 + offset]),
                                                   Description    = (string)r[6 + offset],
                                                   Responsible    = ToGuid(r[7 + offset]),
                                                   Priority       = (TaskPriority)Convert.ToInt32(r[8 + offset]),
                                                   Status         = (TaskStatus)Convert.ToInt32(r[9 + offset]),
                                                   Milestone      = r[10 + offset] == null ? 0 : Convert.ToInt32(r[10 + offset]),
                                                   SortOrder      = Convert.ToInt32(r[11 + offset]),
                                                   Deadline       = r[12 + offset] != null?DateTime.SpecifyKind((DateTime)r[12 + offset], DateTimeKind.Local) : default(DateTime),
                                                                        Responsibles = !string.IsNullOrEmpty((string)r[13 + offset]) ? new HashSet <Guid>(((string)r[13 + offset]).Split(',').Select(resp => ToGuid(resp))) : new HashSet <Guid>(),
                                                                        SubTasks     = new List <Subtask>()
            };

            if (!task.Responsible.Equals(Guid.Empty))
            {
                task.Responsibles.Add(task.Responsible);
            }

            return(task);
        }
Example #3
0
        public void AddToFollowingProjects(int project, Guid participant)
        {
            using (var db = new DbManager(DatabaseId))
            {
                db.ExecuteNonQuery(
                    new SqlInsert(FollowingProjectTable, true)
                        .InColumnValue("project_id", project)
                        .InColumnValue("participant_id", participant.ToString()));

                var projDao = new ProjectDao(db.DatabaseId, Tenant);
                projDao.UpdateLastModified(project);
            }
        }
Example #4
0
        public void RemoveFromFollowingProjects(int project, Guid participant)
        {
            using (var db = new DbManager(DatabaseId))
            {
                db.ExecuteNonQuery(
                    new SqlDelete(FollowingProjectTable)
                    .Where("project_id", project)
                    .Where("participant_id", participant.ToString()));

                var projDao = new ProjectDao(db.DatabaseId, Tenant);
                projDao.UpdateLastModified(project);
            }
        }
Example #5
0
        public void AddToFollowingProjects(int project, Guid participant)
        {
            using (var db = new DbManager(DatabaseId))
            {
                db.ExecuteNonQuery(
                    new SqlInsert(FollowingProjectTable, true)
                    .InColumnValue("project_id", project)
                    .InColumnValue("participant_id", participant.ToString()));

                var projDao = new ProjectDao(db.DatabaseId, Tenant);
                projDao.UpdateLastModified(project);
            }
        }
        public void RemoveFromFollowingProjects(int project, Guid participant)
        {
            using (var db = new DbManager(DatabaseId))
            {
                db.ExecuteNonQuery(
                    new SqlDelete(FollowingProjectTable)
                        .Where("project_id", project)
                        .Where("participant_id", participant.ToString()));

                var projDao = new ProjectDao(db.DatabaseId, Tenant);
                projDao.UpdateLastModified(project);
            }
        }
Example #7
0
        private Message ToMessage(object[] r)
        {
            var offset = ProjectDao.PROJECT_COLUMNS.Length;

            return(new Message()
            {
                Project = r[0] != null?ProjectDao.ToProject(r) : null,
                              ID = Convert.ToInt32(r[0 + offset]),
                              Title = (string)r[1 + offset],
                              CreateBy = ToGuid(r[2 + offset]),
                              CreateOn = TenantUtil.DateTimeFromUtc((DateTime)r[3 + offset]),
                              LastModifiedBy = ToGuid(r[4 + offset]),
                              LastModifiedOn = TenantUtil.DateTimeFromUtc((DateTime)r[5 + offset]),
                              Content = (string)r[6 + offset]
            });
        }
        private IEnumerable <DomainObject <int> > GetProjects(String text, int projectId)
        {
            Exp projWhere;

            if (FullTextSearch.SupportModule(FullTextSearch.ProjectsModule))
            {
                var projIds = FullTextSearch.Search(FullTextSearch.ProjectsModule.Match(text));
                projWhere = Exp.In("id", projIds);
            }
            else
            {
                projWhere = BuildLike(new[] { "title", "description" }, text, projectId);
            }

            return(ProjectDao.GetProjects(projWhere));
        }
 private Message ToMessage(object[] r)
 {
     var offset = ProjectDao.ProjectColumns.Length;
     return new Message
                {
                    Project = r[0] != null ? ProjectDao.ToProject(r) : null,
                    ID = Convert.ToInt32(r[0 + offset]),
                    Title = (string) r[1 + offset],
                    Status = (MessageStatus)Convert.ToInt32(r[2 + offset]),
                    CreateBy = ToGuid(r[3 + offset]),
                    CreateOn = TenantUtil.DateTimeFromUtc(Convert.ToDateTime(r[4 + offset])),
                    LastModifiedBy = ToGuid(r[5 + offset]),
                    LastModifiedOn = TenantUtil.DateTimeFromUtc(Convert.ToDateTime(r[6 + offset])),
                    Content = (string) r[7 + offset]
                };
 }
        private IEnumerable <DomainObject <int> > GetProjects(String text, int projectId)
        {
            Exp projWhere;

            List <int> projIds;

            if (FactoryIndexer <ProjectsWrapper> .TrySelectIds(s => s.MatchAll(text), out projIds))
            {
                projWhere = Exp.In("id", projIds);
            }
            else
            {
                projWhere = BuildLike(new[] { "title", "description" }, text, projectId);
            }

            return(ProjectDao.GetProjects(projWhere));
        }
Example #11
0
        private static Milestone ToMilestone(object[] r)
        {
            var offset = ProjectDao.ProjectColumns.Length;

            return(new Milestone
            {
                Project = r[0] != null?ProjectDao.ToProject(r) : null,
                              ID = Convert.ToInt32(r[0 + offset]),
                              Title = (string)r[1 + offset],
                              CreateBy = ToGuid(r[2 + offset]),
                              CreateOn = TenantUtil.DateTimeFromUtc(Convert.ToDateTime(r[3 + offset])),
                              LastModifiedBy = ToGuid(r[4 + offset]),
                              LastModifiedOn = TenantUtil.DateTimeFromUtc(Convert.ToDateTime(r[5 + offset])),
                              DeadLine = DateTime.SpecifyKind(Convert.ToDateTime(r[6 + offset]), DateTimeKind.Local),
                              Status = (MilestoneStatus)Convert.ToInt32(r[7 + offset]),
                              IsNotify = Convert.ToBoolean(r[8 + offset]),
                              IsKey = Convert.ToBoolean(r[9 + offset]),
                              Description = (string)r[10 + offset],
                              Responsible = ToGuid(r[11 + offset]),
                              ActiveTaskCount = Convert.ToInt32(r[12 + ProjectDao.ProjectColumns.Length]),
                              ClosedTaskCount = Convert.ToInt32(r[13 + ProjectDao.ProjectColumns.Length])
            });
        }
Example #12
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;
        }
Example #13
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);
        }