private Activity GetFileActivity(FileEntry fileEntry, DateTimeRange range)
        {
            object wrapper;

            if (fileEntry is File)
                wrapper = new FileWrapper((File) fileEntry);
            else
                wrapper = new FolderWrapper((Folder) fileEntry);

            var activity = new Activity(Documents, wrapper)
            {
                Action = (range.In(fileEntry.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(fileEntry.ModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(fileEntry.SharedToMeOn) ? ActivityAction.Shared : ActivityAction.Undefined),
                ItemType = "file",
            };

            if (range.In(fileEntry.CreateOn))
            {
                activity.CreatedBy = fileEntry.CreateBy;
                activity.When = fileEntry.CreateOn;
            }
            else if (range.In(fileEntry.ModifiedOn))
            {
                activity.CreatedBy = fileEntry.ModifiedBy;
                activity.When = fileEntry.ModifiedOn;
            }
            else if (range.In(fileEntry.SharedToMeOn))
            {
                activity.CreatedBy = new Guid(fileEntry.SharedToMeBy);
                activity.When = fileEntry.SharedToMeOn;
            }

            return activity;
        }
예제 #2
0
        /// <summary>
        /// Return recent blog activities
        /// </summary>
        /// <param name="range"></param>
        /// <param name="relativeTo"></param>
        /// <param name="actions"></param>
        /// <returns></returns>
        public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
        {
            var activities = new List<Activity>();
            //Get blog posts in range
            activities.AddRange(_engine.GetPosts(range.From, range.To).Select(x => new Activity(BlogsSource, new BlogPostWrapperSummary(x), x.Author.ID, x.Updated, (range.In(x.Updated) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(x.Datetime) ? ActivityAction.Created : ActivityAction.Undefined)) { ItemType = "post" }));
            //Get post comments in range
            activities.AddRange(_engine.GetComments(range.From, range.To, SecurityContext.CurrentAccount.ID).Select(x => new Activity(BlogsSource, new BlogPostCommentWrapper(x), x.UserID, x.Datetime, ActivityAction.Commented | (x.Inactive ? ActivityAction.Undefined : ActivityAction.Deleted) | (x.ParentId==Guid.Empty ? ActivityAction.Undefined : ActivityAction.Reply)) { ItemType = "comment", IsNew = !x.IsReaded, RelativeTo = x.PostId}));

            return activities;
        }
        public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
        {
            var events = FeedStorage.GetFeedByDate(range.From, range.To, SecurityContext.CurrentAccount.ID);
            var comments = FeedStorage.GetCommentsByDate(range.From, range.To);
            
            var activities = new List<Activity>((events
                .Select(x => new Activity(Events, new EventWrapper(x), new Guid(x.Creator), x.Date,
                    (range.In(x.Date) ? ActivityAction.Created : ActivityAction.Undefined))
                {ItemType = "event"})));
            activities.AddRange(comments
                .Select(x => new Activity(Events, new EventCommentWrapper(x), new Guid(x.Creator), x.Date,
                    (range.In(x.Date) ? ActivityAction.Created : ActivityAction.Undefined) | (x.ParentId == 0 ? ActivityAction.Commented : ActivityAction.Reply) | (x.Inactive ? ActivityAction.Deleted : ActivityAction.Undefined))
                {ItemType = "comment"}));

            return activities;
        }
 public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
 {
     return
         CoreContext.UserManager.GetUsers().Where(x => x.WorkFromDate.HasValue && range.In(x.WorkFromDate.Value)).
             Select(x => new Activity(NewEmployes, null, x.WorkFromDate)
             {
                 RelativeTo = x.ID,
                 Action = ActivityAction.Created
             }
         );
 }
 public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
 {
     //Return birthdays
     return
         CoreContext.UserManager.GetUsers().Where(x => x.BirthDate.HasValue && range.In(x.BirthDate.Value)).
             Select(x => new Activity(Birthday, null, x.BirthDate)
                             {
                                 RelativeTo = x.ID, 
                                 Action = ActivityAction.Periodic
                             }
         );
 }
        public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
        {
            var comments = ImageStorage.GetComments(range.From, range.To);
            var albums = ImageStorage.GetPhotos(range.From, range.To)
                .GroupBy(x => x.UserID)
                .ToDictionary(x => x.Key, y => y.GroupBy(z => z.Album));

            var activities = new List<Activity>(comments
                .Select(x => new Activity(Images, new { Comment = new PhotoAlbumItemCommentWrapper(x.Comment), Image = new PhotoAlbumItemWrapper(x.Image) }, new Guid(x.Comment.UserID), x.Comment.Timestamp,
                    (range.In(x.Comment.Timestamp) ? ActivityAction.Created : ActivityAction.Undefined) | (x.Comment.ParentId == 0 ? ActivityAction.Commented : ActivityAction.Reply))
                {ItemType = "comment"}));
            foreach (var album in albums)
            {
                activities.AddRange(album.Value
                    .Select(x => new Activity(Images, new { Album = new PhotoAlbumWrapper(x.Key), Uploaded = x.Select(y => new PhotoAlbumItemWrapper(y)) }, new Guid(album.Key), null,
                        (range.In(x.Key.LastUpdate) ? ActivityAction.Created : ActivityAction.Undefined))
                    {ItemType = "album"}));
            }

            return activities;
        }
        public IEnumerable<Activity> GetActivities(DateTimeRange range, object relativeTo, ActivityAction? actions)
        {
            var milestones = EngineFactory.GetMilestoneEngine().GetUpdates(range.From, range.To);
            var projects = EngineFactory.GetProjectEngine().GetUpdates(range.From, range.To);
            var tasks = EngineFactory.GetTaskEngine().GetUpdates(range.From, range.To);
            var comments = EngineFactory.GetCommentEngine().GetUpdates(range.From, range.To);
            var messages = EngineFactory.GetMessageEngine().GetUpdates(range.From, range.To);
            var participants = EngineFactory.GetProjectEngine().GetTeamUpdates(range.From, range.To);
            var timeTracking = EngineFactory.GetTimeTrackingEngine().GetUpdates(range.From, range.To);
            var subtasks = EngineFactory.GetTaskEngine().GetSubtaskUpdates(range.From, range.To);

            var activities = new List<Activity>(milestones
                .Select(x => new Activity(Projects, new MilestoneWrapper(x), (range.In(x.CreateOn) ? x.CreateBy : x.LastModifiedBy), (range.In(x.CreateOn) ? x.CreateOn : x.LastModifiedOn),
                    (range.In(x.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.LastModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(x.StatusChangedOn) && x.Status == MilestoneStatus.Closed ? ActivityAction.Closed : ActivityAction.Opened))
                    { ItemType = "milestone"}));
            activities.AddRange(projects
                .Select(x => new Activity(Projects, new ProjectWrapper(x), (range.In(x.CreateOn) ? x.CreateBy : x.LastModifiedBy), (range.In(x.CreateOn) ? x.CreateOn : x.LastModifiedOn),
                    (range.In(x.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.LastModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(x.StatusChangedOn) && x.Status == ProjectStatus.Closed ? ActivityAction.Closed : ActivityAction.Opened)) 
                    { ItemType = "project" }));
            activities.AddRange(tasks
                .Select(x => new Activity(Projects, new TaskWrapper(x), (range.In(x.CreateOn) ? x.CreateBy : x.LastModifiedBy), (range.In(x.CreateOn) ? x.CreateOn : x.LastModifiedOn),
                    (range.In(x.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.LastModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(x.StatusChangedOn) && x.Status == TaskStatus.Closed ? ActivityAction.Closed : ActivityAction.Opened))
                    { ItemType = "task"}));
            activities.AddRange(messages
                .Select(x=>new Activity(Projects, new MessageWrapper(x), range.In(x.CreateOn) ? x.CreateBy : x.LastModifiedBy, range.In(x.CreateOn) ? x.CreateOn : x.LastModifiedOn,
                    (range.In(x.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.LastModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined))
                    { ItemType = "message"}));
            activities.AddRange(comments
                .Select(x=>new Activity(Projects,new { Comment = new CommentWrapper(x.Comment), CommentedType = x.CommentedType, CommentedTitle = x.CommentedTitle, CommentedId = x.CommentedId }, x.Comment.CreateBy, x.Comment.CreateOn,
                    (range.In(x.Comment.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (x.Comment.Inactive ? ActivityAction.Deleted : ActivityAction.Undefined) | (x.Comment.Parent == Guid.Empty ? ActivityAction.Commented : ActivityAction.Reply))
                    { ItemType = "comment"}));
            activities.AddRange(participants
                .Select(x => new Activity(Projects, new ParticipantFullWrapper(x), x.ID, range.In(x.Created) ? x.Created : x.Updated,
                    (range.In(x.Created) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.Updated) ? ActivityAction.Updated : ActivityAction.Undefined) | (x.Removed ? ActivityAction.Deleted : ActivityAction.Undefined)) 
                    { ItemType = "participant" }));
            activities.AddRange(timeTracking
                .Select(x => new Activity(Projects, new TimeWrapper(x), x.Person, x.Date, ActivityAction.Updated)
                    {ItemType = "time"}));
            foreach (var task in subtasks)
            {
                var group = task.SubTasks;
                task.SubTasks = null;
                activities.AddRange(group
                    .Select(x => new Activity(Projects, new {Task = new TaskWrapper(task), Subtask = new SubtaskWrapper(x, task)}, range.In(x.CreateOn) ? x.CreateBy : x.LastModifiedBy, range.In(x.CreateOn) ? x.CreateOn : x.LastModifiedOn,
                        (range.In(x.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(x.LastModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(x.StatusChangedOn) && x.Status == TaskStatus.Open ? ActivityAction.Opened : ActivityAction.Closed))
                        {ItemType = "subtask"}));
            }

            return activities;
        }