Exemple #1
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));
            }
        }
        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));
            }
        }