Пример #1
0
        public static void NotifyAboutSharingCalendar(ASC.Api.Calendar.BusinessObjects.Calendar calendar, ASC.Api.Calendar.BusinessObjects.Calendar oldCalendar)
        {
            var initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), SecurityContext.CurrentAccount.Name));
            try
            {
                var usr = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
                var userLink = PerformUrl(CommonLinkUtility.GetUserProfile(usr.ID.ToString(), Guid.Empty, UserProfileType.General, false));

                foreach (var item in calendar.SharingOptions.PublicItems)
                {
                    if (oldCalendar != null && oldCalendar.SharingOptions.PublicItems.Exists(i => i.Id.Equals(item.Id)))
                        continue;

                    var r = CalendarNotifySource.Instance.GetRecipientsProvider().GetRecipient(item.Id.ToString());
                    _notifyClient.SendNoticeAsync(CalendarNotifySource.CalendarSharing, null, r, true,
                        new TagValue(new Tag("SharingType"), "calendar"),
                        new TagValue(new Tag("UserName"), usr.DisplayUserName()),
                        new TagValue(new Tag("UserLink"), userLink),
                        new TagValue(new Tag("CalendarName"), calendar.Name));
                }
                _notifyClient.EndSingleRecipientEvent(_syncName);
            }
            finally
            {
                _notifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
 public static void SendNoticeAsync(string AuthorID, INotifyAction action, string objectID, SendNoticeCallback sendCallback, params ITagValue[] args)
 {
     InitiatorInterceptor initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(AuthorID, ""));
     try
     {
         NotifyClient.AddInterceptor(initatorInterceptor);
         NotifyClient.SendNoticeAsync(action, objectID, sendCallback, args);
     }
     finally
     {
         NotifyClient.RemoveInterceptor(initatorInterceptor.Name);
     }
 }
Пример #3
0
        public void SendAboutSubTaskResumed(List<IRecipient> recipients, Task task, Subtask subtask)
        {
            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            client.AddInterceptor(interceptor);

            try
            {
                client.SendNoticeToAsync(
                    NotifyConstants.Event_SubTaskResumed,
                    task.NotifyId,
                    recipients.ToArray(),
                    true,
                    new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
                    new TagValue(NotifyConstants.Tag_SubEntityTitle, subtask.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, task.ID),
                    ReplyToTagProvider.Comment("project.task", task.ID.ToString(CultureInfo.InvariantCulture)),
                    new AdditionalSenderTag("push.sender"),
                    new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Subtask, subtask.ID.ToString(CultureInfo.InvariantCulture), subtask.Title)),
                    new TagValue(PushConstants.PushParentItemTagName, new PushItem(PushItemType.Task, task.ID.ToString(CultureInfo.InvariantCulture), task.Title)),
                    new TagValue(PushConstants.PushModuleTagName, PushModule.Projects),
                    new TagValue(PushConstants.PushActionTagName, PushAction.Resumed));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Пример #4
0
        /// <summary>
        /// notify user about his password changed
        /// </summary>
        public void UserPasswordChanged(Guid userID, string password)
        {
            UserInfo Author = null;
            UserInfo newUserInfo = CoreContext.UserManager.GetUsers(userID);

            if (CoreContext.UserManager.UserExists(SecurityContext.CurrentAccount.ID))
                Author = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

            ISendInterceptor initInterceptor = null;
            if (Author != null)
            {
                initInterceptor = new InitiatorInterceptor(new[] { UserInfoAsRecipient(Author) });
                client.AddInterceptor(initInterceptor);
            }

            client.SendNoticeToAsync(
                           Constants.ActionPasswordChanged,
                           null,
                           new[] { UserInfoAsRecipient(newUserInfo) },
                           new[] { EMailSenderName },
                           null,
                           new TagValue(Constants.TagUserName, newUserInfo.DisplayUserName()),
                           new TagValue(Constants.TagUserEmail, newUserInfo.Email),
                           new TagValue(Constants.TagMyStaffLink, GetMyStaffLink()),
                           new TagValue(Constants.TagPassword, password)
                       );


            if (initInterceptor != null)
                client.RemoveInterceptor(initInterceptor.Name);
        }
Пример #5
0
 public void SendAboutTaskClosing(List<IRecipient> recipients, Task task)
 {
     client.BeginSingleRecipientEvent("task closed");
     var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
     client.AddInterceptor(interceptor);
     try
     {
         client.SendNoticeToAsync(
             NotifyConstants.Event_TaskClosed,
             task.NotifyId,
             recipients.ToArray(),
             GetDefaultSenders(recipients.FirstOrDefault()),
             null,
             new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
             new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
             new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
             new TagValue(NotifyConstants.Tag_EntityID, task.ID),
             new TagValue(NotifyConstants.Tag_AdditionalData, HttpUtility.HtmlEncode(task.Description)),
             ReplyToTagProvider.Comment("project.task", task.ID.ToString()));
     }
     finally
     {
         client.RemoveInterceptor(interceptor.Name);
         client.EndSingleRecipientEvent("task closed");
     }
 }
Пример #6
0
        private void NotifyNewComment(FeedComment comment, Feed feed)
        {
            var feedType = feed.FeedType == FeedType.Poll ? "poll" : "feed";

            var initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(comment.Creator, ""));
            try
            {
                NewsNotifyClient.NotifyClient.AddInterceptor(initatorInterceptor);
                NewsNotifyClient.NotifyClient.SendNoticeAsync(
                    NewsConst.NewComment, feed.Id.ToString(CultureInfo.InvariantCulture),
                    null,
                    new TagValue(NewsConst.TagFEED_TYPE, feedType),
                    //new TagValue(NewsConst.TagAnswers, feed.Variants.ConvertAll<string>(v => v.Name)),
                    new TagValue(NewsConst.TagCaption, feed.Caption),
                    new TagValue("CommentBody", HtmlUtility.GetFull(comment.Comment, Product.CommunityProduct.ID)),
                    new TagValue(NewsConst.TagDate, comment.Date.ToShortString()),
                    new TagValue(NewsConst.TagURL, CommonLinkUtility.GetFullAbsolutePath("~/products/community/modules/news/?docid=" + feed.Id)),
                    new TagValue("CommentURL", CommonLinkUtility.GetFullAbsolutePath("~/products/community/modules/news/?docid=" + feed.Id + "#" + comment.Id.ToString(CultureInfo.InvariantCulture))),
                    new TagValue(NewsConst.TagUserName, DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID)),
                    new TagValue(NewsConst.TagUserUrl, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID))),
                    GetReplyToTag(feed, comment)
                    );
            }
            finally
            {
                NewsNotifyClient.NotifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
Пример #7
0
        public void SendAboutAddRelationshipEventAdd(RelationshipEvent entity,
                                                    Hashtable fileListInfoHashtable, params Guid[] userID)
        {
            if (userID.Length == 0) return;

            NameValueCollection baseEntityData;

            if (entity.EntityID != 0)
            {
                baseEntityData = ExtractBaseDataFrom(entity.EntityType, entity.EntityID);
            }
            else
            {
                var contact = Global.DaoFactory.GetContactDao().GetByID(entity.ContactID);

                baseEntityData = new NameValueCollection();
                baseEntityData["title"] = contact.GetTitle();
                baseEntityData["id"] = contact.ID.ToString();
                baseEntityData["entityRelativeURL"] = "default.aspx?id=" + contact.ID;

                if (contact is Person)
                    baseEntityData["entityRelativeURL"] += "&type=people";

                baseEntityData["entityRelativeURL"] = String.Concat(PathProvider.BaseAbsolutePath,
                                                                    baseEntityData["entityRelativeURL"]);
            }

            client.BeginSingleRecipientEvent("send about add relationship event add");

            var interceptor = new InitiatorInterceptor(new DirectRecipient(ASC.Core.SecurityContext.CurrentAccount.ID.ToString(), ""));

            client.AddInterceptor(interceptor);

            try
            {

                client.SendNoticeToAsync(
                      NotifyConstants.Event_AddRelationshipEvent,
                      null,
                      userID.Select(item => ToRecipient(item)).ToArray(),
                      true,
                      new TagValue(NotifyConstants.Tag_EntityTitle, baseEntityData["title"]),
                      new TagValue(NotifyConstants.Tag_EntityID, baseEntityData["id"]),
                      new TagValue(NotifyConstants.Tag_EntityRelativeURL, baseEntityData["entityRelativeURL"]),
                      new TagValue(NotifyConstants.Tag_AdditionalData,
                      new Hashtable { 
                      { "Files", fileListInfoHashtable },
                      {"EventContent", entity.Content}}));

            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
                client.EndSingleRecipientEvent("send about add relationship event add");
            }


        }
Пример #8
0
        private void NotifyAlbumSave(Album currentAlbum, IEnumerable<AlbumItem> newItems)
        {
            var initiatorInterceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            try
            {
                NotifyClient.AddInterceptor(initiatorInterceptor);
                NotifyClient.BeginSingleRecipientEvent("photo uploaded");

                var albumUrl = UrlHelper.GetAbsoluteAlbumUrl(currentAlbum.Id);
                var eventUrl = UrlHelper.GetAbsoluteEventUrl(currentAlbum.Event.Id);
                var userName = DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID);
                var userUrl = CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID, ASC.Web.Community.Product.CommunityProduct.ID));

                NotifyClient.SendNoticeAsync(
                    PhotoConst.NewPhotoUploaded,
                    null,
                    null,
                    new[]{
                        new TagValue(PhotoConst.TagEventName, currentAlbum.Event.Name),
                        new TagValue(PhotoConst.TagUserName, userName),
                        new TagValue(PhotoConst.TagUserURL, userUrl),
                        new TagValue(PhotoConst.TagPhotoCount, newItems.Count()),
                        new TagValue(PhotoConst.TagDate, string.Format("{0:d} {0:t}", TenantUtil.DateTimeNow())),
                        new TagValue(PhotoConst.TagURL, albumUrl),
                        new TagValue(PhotoConst.TagEventUrl, eventUrl),
                        new TagValue("PHOTO_UPLOAD", true)});
            }
            finally
            {
                NotifyClient.EndSingleRecipientEvent("photo uploaded");
                NotifyClient.RemoveInterceptor(initiatorInterceptor.Name);
            }

            PhotoUserActivityPublisher.AddPhoto(currentAlbum, SecurityContext.CurrentAccount.ID, newItems.ToList());
        }
Пример #9
0
 public void SendAboutSubTaskDeleting(List<IRecipient> recipients, Task task, Subtask subtask)
 {
     var description = !string.IsNullOrEmpty(task.Description) ? HttpUtility.HtmlEncode(task.Description) : "";
     var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
     client.AddInterceptor(interceptor);
     try
     {
         client.SendNoticeToAsync(
             NotifyConstants.Event_SubTaskDeleted,
             task.NotifyId,
             recipients.ToArray(),
             true,
             new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
             new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
             new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
             new TagValue(NotifyConstants.Tag_SubEntityTitle, subtask.Title),
             new TagValue(NotifyConstants.Tag_EntityID, task.ID),
             new TagValue(NotifyConstants.Tag_AdditionalData, new Hashtable { { "TaskDescription", description } }),
             ReplyToTagProvider.Comment("project.task", task.ID.ToString(CultureInfo.InvariantCulture)),
             new AdditionalSenderTag("push.sender"),
             new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Subtask, subtask.ID.ToString(CultureInfo.InvariantCulture), subtask.Title)),
             new TagValue(PushConstants.PushParentItemTagName, new PushItem(PushItemType.Task, task.ID.ToString(CultureInfo.InvariantCulture), task.Title)),
             new TagValue(PushConstants.PushModuleTagName, PushModule.Projects),
             new TagValue(PushConstants.PushActionTagName, PushAction.Deleted));
     }
     finally
     {
         client.RemoveInterceptor(interceptor.Name);
     }
 }
Пример #10
0
        public void SendNewFile(List<IRecipient> recipients, ProjectEntity entity, string fileTitle)
        {
            INotifyAction action;
            if (entity.GetType() == typeof(Message)) action = NotifyConstants.Event_NewFileForDiscussion;
            else if (entity.GetType() == typeof(Task)) action = NotifyConstants.Event_NewFileForTask;
            else return;

            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            try
            {
                client.AddInterceptor(interceptor);
                client.SendNoticeToAsync(
                    action,
                    entity.NotifyId,
                    recipients.ToArray(), 
                    true,
                    new TagValue(NotifyConstants.Tag_ProjectID, entity.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, entity.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, entity.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, entity.ID),
                    new TagValue(NotifyConstants.Tag_AdditionalData, fileTitle));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Пример #11
0
 public void SendAboutRemoveResponsibleByTask(IEnumerable<Guid> recipients, Task task)
 {
     var description = !string.IsNullOrEmpty(task.Description) ? HttpUtility.HtmlEncode(task.Description) : "";
     var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
     client.AddInterceptor(interceptor);
     try
     {
         client.SendNoticeToAsync(
             NotifyConstants.Event_RemoveResponsibleForTask,
             task.NotifyId,
             recipients.Select(ToRecipient).Where(r => r != null).ToArray(),
             true,
             new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
             new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
             new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
             new TagValue(NotifyConstants.Tag_EntityID, task.ID),
             new TagValue(NotifyConstants.Tag_AdditionalData, new Hashtable { { "TaskDescription", description } }),
             ReplyToTagProvider.Comment("project.task", task.ID.ToString(CultureInfo.InvariantCulture)));
     }
     finally
     {
         client.RemoveInterceptor(interceptor.Name);
     }
 }
Пример #12
0
 public void SendAboutTaskClosing(IEnumerable<IRecipient> recipients, Task task)
 {
     client.BeginSingleRecipientEvent("task closed");
     var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
     client.AddInterceptor(interceptor);
     try
     {
         client.SendNoticeToAsync(
             NotifyConstants.Event_TaskClosed,
             task.NotifyId,
             recipients.ToArray(),
             true,
             new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
             new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
             new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
             new TagValue(NotifyConstants.Tag_EntityID, task.ID),
             new TagValue(NotifyConstants.Tag_AdditionalData, HttpUtility.HtmlEncode(task.Description)),
             ReplyToTagProvider.Comment("project.task", task.ID.ToString(CultureInfo.InvariantCulture)),
             new AdditionalSenderTag("push.sender"),
             new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Task, task.ID.ToString(), task.Title)),
             new TagValue(PushConstants.PushParentItemTagName, new PushItem(PushItemType.Project, task.Project.ID.ToString(), task.Project.Title)),
             new TagValue(PushConstants.PushModuleTagName, PushModule.Projects),
             new TagValue(PushConstants.PushActionTagName, PushAction.Closed));
     }
     finally
     {
         client.RemoveInterceptor(interceptor.Name);
         client.EndSingleRecipientEvent("task closed");
     }
 }
Пример #13
0
 public void SendAboutResponsibleBySubTask(Subtask subtask, Task task)
 {
     var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
     client.AddInterceptor(interceptor);
     try
     {
         var recipient = ToRecipient(subtask.Responsible);
         if (recipient != null)
         {
             client.SendNoticeToAsync(
                 NotifyConstants.Event_ResponsibleForSubTask,
                 task.NotifyId,
                 new[] { recipient },
                 true,
                 new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
                 new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
                 new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
                 new TagValue(NotifyConstants.Tag_SubEntityTitle, subtask.Title),
                 new TagValue(NotifyConstants.Tag_EntityID, task.ID),
                 new TagValue(NotifyConstants.Tag_AdditionalData, new Hashtable { { "TaskDescription", HttpUtility.HtmlEncode(task.Description) } }),
                 ReplyToTagProvider.Comment("project.task", task.ID.ToString(CultureInfo.InvariantCulture)),
                 new AdditionalSenderTag("push.sender"),
                 new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Subtask, subtask.ID.ToString(), subtask.Title)),
                 new TagValue(PushConstants.PushParentItemTagName, new PushItem(PushItemType.Task, task.ID.ToString(), task.Title)),
                 new TagValue(PushConstants.PushModuleTagName, PushModule.Projects),
                 new TagValue(PushConstants.PushActionTagName, PushAction.Assigned));
         }
     }
     finally
     {
         client.RemoveInterceptor(interceptor.Name);
     }
 }
Пример #14
0
        /// <summary>
        /// Notify user about his profile updated
        /// </summary>
        public void UserInfoUpdated(UserInfo prevUserInfo, UserInfo newUserInfo, string password)
        {
            UserInfo Author = null;
            if (CoreContext.UserManager.UserExists(SecurityContext.CurrentAccount.ID))
                Author = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

            ISendInterceptor initInterceptor = null;
            if (Author != null)
            {
                initInterceptor = new InitiatorInterceptor(new[] { UserInfoAsRecipient(Author) });
                client.AddInterceptor(initInterceptor);
            }

            client.SendNoticeToAsync(
                           Constants.ActionYourProfileUpdated,
                           null,
                           new[] { UserInfoAsRecipient(newUserInfo) },
                           AllSenderNames,
                           null,
                           new TagValue(Constants.TagProfileChanges, GetUserInfoChanges(prevUserInfo, newUserInfo)),
                           new TagValue(Constants.TagUserName, newUserInfo.DisplayUserName()),
                           new TagValue(Constants.TagMyStaffLink, GetMyStaffLink()),
                           new TagValue(Constants.TagPassword, password),
                           new TagValue(Constants.TagIsPasswordChange, password != null)
                       );

            if (initInterceptor != null)
                client.RemoveInterceptor(initInterceptor.Name);
        }
Пример #15
0
 public void SendAboutTaskRemoved(List<IRecipient> recipients, Task task, Milestone milestone, bool newMilestone)
 {
     var description = !string.IsNullOrEmpty(task.Description) ? HttpUtility.HtmlEncode(task.Description) : "";
     var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
     client.AddInterceptor(interceptor);
     try
     {
         client.SendNoticeToAsync(newMilestone ? NotifyConstants.Event_TaskMovedToMilestone : NotifyConstants.Event_TaskMovedFromMilestone,
             task.NotifyId,
             recipients.ToArray(),
             true,
             new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
             new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
             new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
             new TagValue(NotifyConstants.Tag_EntityID, task.ID),
             new TagValue(NotifyConstants.Tag_SubEntityTitle, milestone.Title),
             new TagValue(NotifyConstants.Tag_AdditionalData, description),
             ReplyToTagProvider.Comment("project.task", task.ID.ToString(CultureInfo.InvariantCulture)));
     }
     finally
     {
         client.RemoveInterceptor(interceptor.Name);
     }
 }
Пример #16
0
        public void SendAboutMessageAction(List<IRecipient> recipients, Message message, bool isNew, Hashtable fileListInfoHashtable)
        {
            var tags = new List<ITagValue>
                {
                    new TagValue(NotifyConstants.Tag_ProjectID, message.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, message.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, message.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, message.ID),
                    new TagValue(NotifyConstants.Tag_EventType, isNew ? NotifyConstants.Event_MessageCreated.ID : NotifyConstants.Event_MessageEdited.ID),
                    new TagValue(NotifyConstants.Tag_AdditionalData, new Hashtable {{"MessagePreview", message.Content}, {"Files", fileListInfoHashtable}}),
                    ReplyToTagProvider.Comment("project.message", message.ID.ToString(CultureInfo.InvariantCulture))
                };

            if (isNew) //don't send push about edited message!
            {
                tags.Add(new AdditionalSenderTag("push.sender"));
                tags.Add(new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Message, message.ID.ToString(CultureInfo.InvariantCulture), message.Title)));
                tags.Add(new TagValue(PushConstants.PushParentItemTagName, new PushItem(PushItemType.Project, message.Project.ID.ToString(CultureInfo.InvariantCulture), message.Project.Title)));
                tags.Add(new TagValue(PushConstants.PushModuleTagName, PushModule.Projects));
                tags.Add(new TagValue(PushConstants.PushActionTagName, PushAction.Created));
            }

            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            try
            {
                client.AddInterceptor(interceptor);
                client.SendNoticeToAsync(
                    isNew ? NotifyConstants.Event_MessageCreated : NotifyConstants.Event_MessageEdited,
                    message.NotifyId,
                    recipients.ToArray(),
                    true,
                    tags.ToArray());
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Пример #17
0
 public void SendAboutMessageDeleting(List<IRecipient> recipients, Message message)
 {
     var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
     try
     {
         client.AddInterceptor(interceptor);
         client.SendNoticeToAsync(
             NotifyConstants.Event_MessageDeleted,
             message.NotifyId,
             recipients.ToArray(),
             true,
             new TagValue(NotifyConstants.Tag_ProjectID, message.Project.ID),
             new TagValue(NotifyConstants.Tag_ProjectTitle, message.Project.Title),
             new TagValue(NotifyConstants.Tag_EntityTitle, message.Title),
             new TagValue(NotifyConstants.Tag_EntityID, message.ID),
             new AdditionalSenderTag("push.sender"),
             new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Message, message.ID.ToString(CultureInfo.InvariantCulture), message.Title)),
             new TagValue(PushConstants.PushParentItemTagName, new PushItem(PushItemType.Project, message.Project.ID.ToString(CultureInfo.InvariantCulture), message.Project.Title)),
             new TagValue(PushConstants.PushModuleTagName, PushModule.Projects),
             new TagValue(PushConstants.PushActionTagName, PushAction.Deleted));
     }
     finally
     {
         client.RemoveInterceptor(interceptor.Name);
     }
 }
        public void UserInfoUpdated(UserInfo prevUser, UserInfo newUser, string password)
        {
            var author = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            ISendInterceptor interceptor = null;
            if (!ASC.Core.Users.Constants.LostUser.Equals(author))
            {
                interceptor = new InitiatorInterceptor(new[] { ToRecipient(author.ID) });
                client.AddInterceptor(interceptor);
            }

            client.SendNoticeToAsync(
                           Constants.ActionYourProfileUpdated,
                           null,
                           new[] { ToRecipient(newUser.ID) },
                           AllSenderNames,
                           null,
                           new TagValue(Constants.TagProfileChanges, GetUserInfoChanges(prevUser, newUser)),
                           new TagValue(Constants.TagUserName, newUser.DisplayUserName()),
                           new TagValue(Constants.TagMyStaffLink, GetMyStaffLink()),
                           new TagValue(Constants.TagPassword, password),
                           new TagValue(Constants.TagIsPasswordChange, password != null));

            if (interceptor != null)
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Пример #19
0
        public void SendAboutProjectDeleting(IEnumerable<Guid> recipients, Project project)
        {
            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            client.AddInterceptor(interceptor);

            try
            {
                client.SendNoticeToAsync(
                    NotifyConstants.Event_ProjectDeleted,
                    project.UniqID,
                    recipients.Select(ToRecipient).Where(r => r != null).ToArray(),
                    true,
                    new TagValue(NotifyConstants.Tag_EntityTitle, project.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, project.ID),
                    new AdditionalSenderTag("push.sender"),
                    new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Project, project.ID.ToString(CultureInfo.InvariantCulture), project.Title)),
                    new TagValue(PushConstants.PushModuleTagName, PushModule.Projects),
                    new TagValue(PushConstants.PushActionTagName, PushAction.Deleted));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Пример #20
0
        private void NotifyCommentAdd(AlbumItem image, Comment newComment)
        {
            var initiatorInterceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            try
            {
                NotifyClient.AddInterceptor(initiatorInterceptor);

                var albumUrl = UrlHelper.GetAbsoluteAlbumUrl(image.Album.Id);
                var albumName = DisplayUserSettings.GetFullUserName(new Guid(image.UserID));
                var eventUrl = UrlHelper.GetAbsoluteEventUrl(image.Album.Event.Id);
                var userName = DisplayUserSettings.GetFullUserName(new Guid(newComment.UserID));
                var userUrl = CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(new Guid(newComment.UserID), ASC.Web.Community.Product.CommunityProduct.ID));
                var commentsUrl = UrlHelper.GetAbsolutePhotoUrl(image.Id);
                var commentText = newComment.Text;

                NotifyClient.SendNoticeAsync(
                            PhotoConst.NewEventComment,
                            image.Album.Event != null ? image.Album.Event.Id.ToString() : "0",
                            null,
                            new TagValue(PhotoConst.TagEventName, image.Album.Event.Name),
                            new TagValue(PhotoConst.TagUserName, userName),
                            new TagValue(PhotoConst.TagUserURL, userUrl),
                            new TagValue(PhotoConst.TagEventUrl, eventUrl),
                            new TagValue(PhotoConst.TagAlbumName, albumName),
                            new TagValue(PhotoConst.TagAlbumURL, albumUrl),
                            new TagValue(PhotoConst.TagPhotoName, image.Name),
                            new TagValue(PhotoConst.TagDate, string.Format("{0:d} {0:t}", newComment.Timestamp)),
                            new TagValue(PhotoConst.TagCommentBody, commentText),
                            new TagValue(PhotoConst.TagURL, commentsUrl));
            }
            finally
            {
                NotifyClient.RemoveInterceptor(initiatorInterceptor.Name);
            }

            PhotoUserActivityPublisher.AddComment(image, newComment);
        }
Пример #21
0
        public void SendAboutTaskCreating(List<IRecipient> recipients, Task task)
        {
            var description = !string.IsNullOrEmpty(task.Description) ? HttpUtility.HtmlEncode(task.Description) : "";
            var resp = "Nobody";

            if (task.Responsibles.Count != 0)
            {
                var recip = task.Responsibles.Select(ToRecipient).Where(r => r != null);
                resp = recip.Select(r => r.Name).Aggregate(string.Empty, (a, b) => a + ", " + b);
            }
            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            client.AddInterceptor(interceptor);

            try
            {
                client.SendNoticeToAsync(
                    NotifyConstants.Event_TaskCreated,
                    task.NotifyId,
                    recipients.ToArray(),
                    true,
                    new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, task.ID),
                    new TagValue(NotifyConstants.Tag_Responsible, resp),
                    new TagValue(NotifyConstants.Tag_AdditionalData, new Hashtable { { "TaskDescription", description } }),
                    ReplyToTagProvider.Comment("project.task", task.ID.ToString(CultureInfo.InvariantCulture)),
                    new AdditionalSenderTag("push.sender"),
                    new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Task, task.ID.ToString(CultureInfo.InvariantCulture), task.Title)),
                    new TagValue(PushConstants.PushParentItemTagName, new PushItem(PushItemType.Project, task.Project.ID.ToString(CultureInfo.InvariantCulture), task.Project.Title)),
                    new TagValue(PushConstants.PushModuleTagName, PushModule.Projects),
                    new TagValue(PushConstants.PushActionTagName, PushAction.Created));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Пример #22
0
        private static void NotifyFeed(Feed feed, bool isEdit, FeedType type)
        {
            var initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(feed.Creator, ""));
            try
            {
                NewsNotifyClient.NotifyClient.AddInterceptor(initatorInterceptor);
                var replyToTag = GetReplyToTag(feed, null);
                if (type == FeedType.Poll && feed is FeedPoll)
                {
                    NewsNotifyClient.NotifyClient.SendNoticeAsync(
                        NewsConst.NewFeed, null, null,
                        new TagValue(NewsConst.TagFEED_TYPE, "poll"),
                        new TagValue(NewsConst.TagAnswers, ((FeedPoll)feed).Variants.ConvertAll(v => v.Name)),
                        new TagValue(NewsConst.TagCaption, feed.Caption),
                        new TagValue(NewsConst.TagText, HtmlUtility.GetFull(feed.Text, Product.CommunityProduct.ID)),
                        new TagValue(NewsConst.TagDate, feed.Date.ToShortString()),
                        new TagValue(NewsConst.TagURL,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         "~/products/community/modules/news/?docid=" + feed.Id)),
                        new TagValue(NewsConst.TagUserName,
                                     DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID)),
                        new TagValue(NewsConst.TagUserUrl,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID))),
                        replyToTag
                        );
                }
                else
                {
                    NewsNotifyClient.NotifyClient.SendNoticeAsync(
                        NewsConst.NewFeed, null, null,
                        new TagValue(NewsConst.TagFEED_TYPE, "feed"),
                        new TagValue(NewsConst.TagCaption, feed.Caption),
                        new TagValue(NewsConst.TagText,
                                     HtmlUtility.GetFull(feed.Text, Product.CommunityProduct.ID)),
                        new TagValue(NewsConst.TagDate, feed.Date.ToShortString()),
                        new TagValue(NewsConst.TagURL,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         "~/products/community/modules/news/?docid=" + feed.Id)),
                        new TagValue(NewsConst.TagUserName,
                                     DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID)),
                        new TagValue(NewsConst.TagUserUrl,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID))),
                        replyToTag
                        );
                }

                // subscribe to new comments
                var subsciber = NewsNotifySource.Instance.GetSubscriptionProvider();
                var me = (IDirectRecipient)NewsNotifySource.Instance.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString());
                if (me != null && !subsciber.IsUnsubscribe(me, NewsConst.NewComment, feed.Id.ToString(CultureInfo.InvariantCulture)))
                {
                    subsciber.Subscribe(NewsConst.NewComment, feed.Id.ToString(CultureInfo.InvariantCulture), me);
                }
            }
            finally
            {
                NewsNotifyClient.NotifyClient.RemoveInterceptor(initatorInterceptor.Name);

            }
        }
Пример #23
0
        public void SendAboutTaskEditing(List<IRecipient> recipients, Task task)
        {
            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            client.AddInterceptor(interceptor);

            try
            {
                client.SendNoticeToAsync(
                    NotifyConstants.Event_TaskEdited,
                    task.NotifyId,
                    recipients.ToArray(),
                    true,
                    new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, task.ID),
                    ReplyToTagProvider.Comment("project.task", task.ID.ToString(CultureInfo.InvariantCulture)));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Пример #24
0
        public void SendNewComment(ProjectEntity entity, Comment comment)
        {
            INotifyAction action;
            if (entity.GetType() == typeof(Issue)) action = NotifyConstants.Event_NewCommentForIssue;
            else if (entity.GetType() == typeof(Message)) action = NotifyConstants.Event_NewCommentForMessage;
            else if (entity.GetType() == typeof(Milestone)) action = NotifyConstants.Event_NewCommentForMilestone;
            else if (entity.GetType() == typeof(Task)) action = NotifyConstants.Event_NewCommentForTask;
            else return;

            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            try
            {
                client.AddInterceptor(interceptor);
                client.SendNoticeAsync(
                    action,
                    entity.NotifyId,
                    null,
                    new TagValue(NotifyConstants.Tag_ProjectID, entity.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, entity.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, entity.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, entity.ID),
                    new TagValue(NotifyConstants.Tag_AdditionalData, comment.Content),
                    GetReplyToEntityTag(entity, comment));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Пример #25
0
        public void SendAboutSubTaskEditing(List<IRecipient> recipients, Task task, Subtask subtask)
        {
            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            client.AddInterceptor(interceptor);

            try
            {
                client.SendNoticeToAsync(
                    NotifyConstants.Event_SubTaskEdited,
                    task.NotifyId,
                    recipients.ToArray(),
                    true,
                    new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
                    new TagValue(NotifyConstants.Tag_SubEntityTitle, subtask.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, task.ID),
                    new TagValue(NotifyConstants.Tag_Responsible,
                                 !subtask.Responsible.Equals(Guid.Empty)
                                     ? ToRecipient(subtask.Responsible).Name
                                     : PatternResource.subtaskWithoutResponsible),
                    ReplyToTagProvider.Comment("project.task", task.ID.ToString(CultureInfo.InvariantCulture)));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Пример #26
0
        public void UserPasswordChanged(Guid userID, string password)
        {
            var author = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            var user = CoreContext.UserManager.GetUsers(userID);

            ISendInterceptor initInterceptor = null;
            if (!ASC.Core.Users.Constants.LostUser.Equals(author))
            {
                initInterceptor = new InitiatorInterceptor(new[] { ToRecipient(author.ID) });
                client.AddInterceptor(initInterceptor);
            }

            client.SendNoticeToAsync(
                           Constants.ActionPasswordChanged,
                           null,
                           new[] { ToRecipient(user.ID) },
                           new[] { EMailSenderName },
                           null,
                           new TagValue(Constants.TagUserName, user.DisplayUserName()),
                           new TagValue(Constants.TagUserEmail, user.Email),
                           new TagValue(Constants.TagMyStaffLink, GetMyStaffLink()),
                           new TagValue(Constants.TagPassword, password));

            if (initInterceptor != null)
            {
                client.RemoveInterceptor(initInterceptor.Name);
            }
        }
Пример #27
0
        public void SendAboutMilestoneResumed(IEnumerable<Guid> recipients, Milestone milestone)
        {
            var description = !string.IsNullOrEmpty(milestone.Description) ? HttpUtility.HtmlEncode(milestone.Description) : "";
            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            client.AddInterceptor(interceptor);

            try
            {
                client.SendNoticeToAsync(
                    NotifyConstants.Event_MilestoneResumed,
                    milestone.NotifyId,
                    recipients.Select(ToRecipient).Where(r => r != null).ToArray(),
                    true,
                    new TagValue(NotifyConstants.Tag_ProjectID, milestone.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, milestone.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, milestone.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, milestone.ID),
                    new TagValue(NotifyConstants.Tag_AdditionalData, description),
                    new AdditionalSenderTag("push.sender"),
                    new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Milestone, milestone.ID.ToString(CultureInfo.InvariantCulture), milestone.Title)),
                    new TagValue(PushConstants.PushParentItemTagName, new PushItem(PushItemType.Project, milestone.Project.ID.ToString(CultureInfo.InvariantCulture), milestone.Project.Title)),
                    new TagValue(PushConstants.PushModuleTagName, PushModule.Projects),
                    new TagValue(PushConstants.PushActionTagName, PushAction.Resumed));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }