Exemplo n.º 1
0
        public void NotifyAboutSharingEvent(ASC.Calendar.BusinessObjects.Event calendarEvent, ASC.Calendar.BusinessObjects.Event oldCalendarEvent)
        {
            var initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(AuthContext.CurrentAccount.ID.ToString(), AuthContext.CurrentAccount.Name));

            try
            {
                var usr      = UserManager.GetUsers(AuthContext.CurrentAccount.ID);
                var userLink = PerformUrl(CommonLinkUtility.GetUserProfile(usr.ID.ToString(), false));

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

                    var r = CalendarNotifySource.GetRecipientsProvider().GetRecipient(item.Id.ToString());
                    if (r != null)
                    {
                        _notifyClient.SendNoticeAsync(CalendarNotifySource.CalendarSharing, null, r, true,
                                                      new TagValue("SharingType", "event"),
                                                      new TagValue("UserName", usr.DisplayUserName(DisplayUserSettingsHelper)),
                                                      new TagValue("UserLink", userLink),
                                                      new TagValue("EventName", calendarEvent.Name));
                    }
                }
                _notifyClient.EndSingleRecipientEvent(_syncName);
            }
            finally
            {
                _notifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
Exemplo n.º 2
0
        public CalendarNotifyClient(
            AuthContext authContext,
            IServiceProvider serviceProvider,
            UserManager userManager,
            CalendarNotifySource calendarNotifySource,
            CommonLinkUtility commonLinkUtility,
            DisplayUserSettingsHelper displayUserSettingsHelper)
        {
            AuthContext               = authContext;
            ServiceProvider           = serviceProvider;
            CalendarNotifySource      = calendarNotifySource;
            UserManager               = userManager;
            CommonLinkUtility         = commonLinkUtility;
            DisplayUserSettingsHelper = displayUserSettingsHelper;

            NotifyContext = new NotifyContext(serviceProvider);
            _notifyClient = NotifyContext.NotifyService.RegisterClient(CalendarNotifySource, ServiceProvider.CreateScope());
        }