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 SendAboutMilestoneClosing(List <IRecipient> recipients, Milestone milestone) { client.BeginSingleRecipientEvent("milestone closed"); var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), "")); client.AddInterceptor(interceptor); try { client.SendNoticeToAsync( NotifyConstants.Event_MilestoneClosed, milestone.NotifyId, recipients.ToArray(), GetDefaultSenders(recipients.FirstOrDefault()), null, 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, HttpUtility.HtmlEncode(milestone.Description)), ReplyToTagProvider.Comment("project.milestone", milestone.ID.ToString())); } finally { client.RemoveInterceptor(interceptor.Name); client.EndSingleRecipientEvent("milestone closed"); } }
public void SendAboutMilestoneClosing(IEnumerable <Guid> recipients, Milestone milestone) { client.BeginSingleRecipientEvent("milestone closed"); var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), "")); client.AddInterceptor(interceptor); try { client.SendNoticeToAsync( NotifyConstants.Event_MilestoneClosed, 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, HttpUtility.HtmlEncode(milestone.Description)), new AdditionalSenderTag("push.sender"), new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Milestone, milestone.ID.ToString(), milestone.Title)), new TagValue(PushConstants.PushParentItemTagName, new PushItem(PushItemType.Project, milestone.Project.ID.ToString(), milestone.Project.Title)), new TagValue(PushConstants.PushModuleTagName, PushModule.Projects), new TagValue(PushConstants.PushActionTagName, PushAction.Closed)); } finally { client.RemoveInterceptor(interceptor.Name); client.EndSingleRecipientEvent("milestone closed"); } }
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"); } }