Пример #1
0
        public Message SaveOrUpdate(Message message, bool notify, IEnumerable <Guid> participant, IEnumerable <int> fileIds, bool isImport)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            var isNew = message.ID == default(int);

            message.LastModifiedBy = SecurityContext.CurrentAccount.ID;
            message.LastModifiedOn = TenantUtil.DateTimeNow();

            if (isNew)
            {
                if (message.CreateBy == default(Guid))
                {
                    message.CreateBy = SecurityContext.CurrentAccount.ID;
                }
                if (message.CreateOn == default(DateTime))
                {
                    message.CreateOn = TenantUtil.DateTimeNow();
                }

                ProjectSecurity.DemandCreateMessage(message.Project);
                _messageDao.Save(message);
                TimeLinePublisher.Message(message, isImport ? EngineResource.ActionText_Imported : EngineResource.ActionText_Create, UserActivityConstants.ContentActionType, UserActivityConstants.NormalContent);
            }
            else
            {
                ProjectSecurity.DemandEdit(message);
                _messageDao.Save(message);
                TimeLinePublisher.Message(message, EngineResource.ActionText_Update, UserActivityConstants.ActivityActionType, UserActivityConstants.NormalActivity, true);
            }

            var fileEngine = _engineFactory.GetFileEngine();

            if (fileIds != null)
            {
                foreach (var fileId in fileIds)
                {
                    fileEngine.AttachFileToMessage(message.ID, fileId);
                }
            }

            NotifyParticipiant(message, isNew, participant, fileEngine.GetMessageFiles(message), notify);

            return(message);
        }
Пример #2
0
        public void Delete(Message message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }
            if (message.Project == null)
            {
                throw new Exception("Project");
            }

            ProjectSecurity.DemandEdit(message);
            TimeLinePublisher.Message(message, EngineResource.ActionText_Delete, UserActivityConstants.ActivityActionType, UserActivityConstants.SmallActivity);

            _messageDao.Delete(message.ID);

            String objectID = String.Format("{0}_{1}", message.UniqID, message.Project.ID);

            NotifySource.Instance.GetSubscriptionProvider().UnSubscribe(NotifyConstants.Event_NewCommentForMessage, objectID);
        }