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(), 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()); if (r != null) { _notifyClient.SendNoticeAsync(CalendarNotifySource.CalendarSharing, null, r, true, new TagValue("SharingType", "calendar"), new TagValue("UserName", usr.DisplayUserName()), new TagValue("UserLink", userLink), new TagValue("CalendarName", calendar.Name)); } } _notifyClient.EndSingleRecipientEvent(_syncName); } finally { _notifyClient.RemoveInterceptor(initatorInterceptor.Name); } }
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"); } }
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); } }
/// <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); } }
public void SendAboutResponsibleByTask(IEnumerable <Guid> recipients, Task task) { var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), "")); client.AddInterceptor(interceptor); try { client.SendNoticeToAsync( NotifyConstants.Event_ResponsibleForTask, 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", 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.Assigned)); } finally { client.RemoveInterceptor(interceptor.Name); } }