Exemplo n.º 1
0
        public virtual void Delete(int projectId)
        {
            var project = GetByID(projectId);

            if (project == null)
            {
                return;
            }

            ProjectSecurity.DemandEdit(project);

            FileEngine.RemoveRoot(projectId);

            List <int> messages, tasks;

            DaoFactory.ProjectDao.Delete(projectId, out messages, out tasks);

            NotifyClient.Instance.SendAboutProjectDeleting(new HashSet <Guid> {
                project.Responsible
            }, project);

            MessageEngine.UnSubscribeAll(messages.Select(r => new Message {
                Project = project, ID = r
            }).ToList());
            TaskEngine.UnSubscribeAll(tasks.Select(r => new Task {
                Project = project, ID = r
            }).ToList());
        }
Exemplo n.º 2
0
        public IEnumerable <File> GetFiles(ProjectEntity entity)
        {
            if (entity == null)
            {
                return(new List <File>());
            }

            if (!ProjectSecurity.CanReadFiles(entity.Project))
            {
                return(new List <File>());
            }

            using (var tagdao = FilesIntegration.GetTagDao())
                using (var filedao = FilesIntegration.GetFileDao())
                {
                    var ids   = tagdao.GetTags(entity.GetType().Name + entity.ID, TagType.System).Where(t => t.EntryType == FileEntryType.File).Select(t => t.EntryId).ToArray();
                    var files = 0 < ids.Length ? filedao.GetFiles(ids) : new List <File>();

                    var rootId = FileEngine.GetRoot(entity.Project.ID);

                    //delete tags when file moved from project folder
                    files.Where(file => !file.RootFolderId.Equals(rootId)).ToList()
                    .ForEach(file =>
                    {
                        DetachFile(entity, file.ID);
                        files.Remove(file);
                    });

                    files.ForEach(r => r.Access = FileEngine.GetFileShare(r, entity.Project.ID));
                    return(files);
                }
        }
Exemplo n.º 3
0
        protected void NotifyParticipiant(Message message, bool isMessageNew, IEnumerable <Guid> participant,
                                          IEnumerable <File> uploadedFiles, bool sendNotify)
        {
            //Don't send anything if notifications are disabled
            if (DisableNotifications)
            {
                return;
            }

            var subscriptionRecipients = GetSubscribers(message);

            var recipients = new HashSet <Guid>(participant);

            foreach (var subscriptionRecipient in subscriptionRecipients)
            {
                var subscriptionRecipientId = new Guid(subscriptionRecipient.ID);
                if (!recipients.Contains(subscriptionRecipientId))
                {
                    UnSubscribe(message, subscriptionRecipientId);
                }
            }

            foreach (var subscriber in recipients)
            {
                Subscribe(message, subscriber);
            }

            if (sendNotify && recipients.Any())
            {
                NotifyClient.Instance.SendAboutMessageAction(GetSubscribers(message), message, isMessageNew,
                                                             FileEngine.GetFileListInfoHashtable(uploadedFiles));
            }
        }
Exemplo n.º 4
0
        public void AttachFile(ProjectEntity entity, object fileId, bool notify)
        {
            if (!ProjectSecurity.CanReadFiles(entity.Project))
            {
                return;
            }

            File file;

            using (var dao = FilesIntegration.GetTagDao())
            {
                dao.SaveTags(new Tag(entity.GetType().Name + entity.ID, TagType.System, Guid.Empty)
                {
                    EntryType = FileEntryType.File, EntryId = fileId
                });
                file = FileEngine.GetFile(fileId, 0);
                FileEngine.GenerateImageThumb(file);
            }

            if (notify && !Factory.DisableNotifications)
            {
                var senders = GetSubscribers(entity);
                NotifyClient.Instance.SendNewFile(senders, entity, file.Title);
            }
        }
Exemplo n.º 5
0
 public TaskEngine(IDaoFactory daoFactory, EngineFactory factory)
 {
     _factory      = factory;
     _taskDao      = daoFactory.GetTaskDao();
     _milestoneDao = daoFactory.GetMilestoneDao();
     _fileEngine   = factory.GetFileEngine();
     _subtaskDao   = daoFactory.GetSubtaskDao();
 }
Exemplo n.º 6
0
 public TaskEngine(IDaoFactory daoFactory, EngineFactory factory)
 {
     _factory = factory;
     _taskDao = daoFactory.GetTaskDao();
     _milestoneDao = daoFactory.GetMilestoneDao();
     _fileEngine = factory.GetFileEngine();
     _subtaskDao = daoFactory.GetSubtaskDao();
 }
Exemplo n.º 7
0
        public Project GetFullProjectByID(int projectID)
        {
            var project = DaoFactory.ProjectDao.GetById(projectID);

            if (!CanRead(project))
            {
                return(null);
            }

            var filter = new TaskFilter
            {
                ProjectIds = new List <int> {
                    projectID
                },
                MilestoneStatuses = new List <MilestoneStatus> {
                    MilestoneStatus.Open
                }
            };
            var taskCount = TaskEngine.GetByFilterCount(filter);

            project.MilestoneCount  = MilestoneEngine.GetByFilterCount(filter);
            project.TaskCount       = taskCount.TasksOpen;
            project.TaskCountTotal  = taskCount.TasksTotal;
            project.DiscussionCount = MessageEngine.GetByFilterCount(filter);

            using (var folderDao = FilesIntegration.GetFolderDao())
            {
                var folderId = FileEngine.GetRoot(projectID);
                project.DocumentsCount = folderDao.GetItemsCount(folderId);
            }

            project.TimeTrackingTotal = TimeTrackingEngine.GetTotalByProject(projectID);
            project.ParticipantCount  = GetTeam(projectID).Count();


            return(project);
        }
Exemplo n.º 8
0
        protected void NotifyParticipiant(Message message, bool isMessageNew, IEnumerable <Guid> participant, IEnumerable <Files.Core.File> uploadedFiles, bool sendNotify)
        {
            //Don't send anything if notifications are disabled
            if (_engineFactory.DisableNotifications)
            {
                return;
            }


            var subscriptionProvider = NotifySource.Instance.GetSubscriptionProvider();
            var recipientsProvider   = NotifySource.Instance.GetRecipientsProvider();

            var objectId = message.NotifyId;
            var subscriptionRecipients = subscriptionProvider.GetRecipients(NotifyConstants.Event_NewCommentForMessage, objectId);
            var recipients             = new HashSet <Guid>(participant)
            {
                SecurityContext.CurrentAccount.ID
            };

            foreach (var subscriptionRecipient in subscriptionRecipients)
            {
                var subscriptionRecipientId = new Guid(subscriptionRecipient.ID);
                if (!recipients.Contains(subscriptionRecipientId))
                {
                    subscriptionProvider.UnSubscribe(NotifyConstants.Event_NewCommentForMessage, objectId, subscriptionRecipient);
                }
            }
            var senders = recipients.Select(r => recipientsProvider.GetRecipient(r.ToString()))
                          .Where(r => r != null && !subscriptionProvider.IsUnsubscribe((IDirectRecipient)r, NotifyConstants.Event_NewCommentForMessage, objectId))
                          .ToList();

            senders.ForEach(r => subscriptionProvider.Subscribe(NotifyConstants.Event_NewCommentForMessage, objectId, r));
            senders.RemoveAll(r => r.ID == SecurityContext.CurrentAccount.ID.ToString());

            if (sendNotify && senders.Any())
            {
                NotifyClient.Instance.SendAboutMessageAction(senders, message, isMessageNew, FileEngine.GetFileListInfoHashtable(uploadedFiles));
            }
        }