예제 #1
0
        public static void NotifyAboutSharingEvent(ASC.Api.Calendar.BusinessObjects.Event calendarEvent, ASC.Api.Calendar.BusinessObjects.Event oldCalendarEvent)
        {
            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 calendarEvent.SharingOptions.PublicItems)
                {
                    if (oldCalendarEvent != null && oldCalendarEvent.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", "event"),
                                                      new TagValue("UserName", usr.DisplayUserName()),
                                                      new TagValue("UserLink", userLink),
                                                      new TagValue("EventName", calendarEvent.Name));
                    }
                }
                _notifyClient.EndSingleRecipientEvent(_syncName);
            }
            finally
            {
                _notifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
예제 #2
0
 public static void NotifyAboutSharingEvent(ASC.Api.Calendar.BusinessObjects.Event calendarEvent)
 {
     NotifyAboutSharingEvent(calendarEvent, null);
 }
예제 #3
0
        public List<Event> GetEventsByIds(object[] evtIds, Guid userId)
        {
            var cc = new ColumnCollection();
            var eId = cc.RegistryColumn("evt.id");
            var eName = cc.RegistryColumn("evt.name");
            var eDescription = cc.RegistryColumn("evt.description");
            var eTenant = cc.RegistryColumn("evt.tenant");
            var eCalId = cc.RegistryColumn("evt.calendar_id");
            var eStartDate = cc.RegistryColumn("evt.start_date");
            var eEndDate = cc.RegistryColumn("evt.end_date");
            var eIsAllDay = cc.RegistryColumn("evt.all_day_long");
            var eRRule = cc.RegistryColumn("evt.rrule");
            var eOwner = cc.RegistryColumn("evt.owner_id");
            var usrAlertType = cc.RegistryColumn("evt_usr.alert_type");
            var eAlertType = cc.RegistryColumn("evt.alert_type");

            var data = DbManager.ExecuteList(new SqlQuery(_eventTable)
                .LeftOuterJoin("calendar_event_user evt_usr", Exp.EqColumns(eId.Name, "evt_usr.event_id") & Exp.Eq("evt_usr.user_id", userId))
                                .Select(cc.SelectQuery).Where(Exp.In(eId.Name, evtIds)));

            var cc1 = new ColumnCollection();
            var evId = cc1.RegistryColumn("evt_itm.event_id");
            var itemId = cc1.RegistryColumn("evt_itm.item_id");
            var itemIsGroup = cc1.RegistryColumn("evt_itm.is_group");

            var sharingData = DbManager.ExecuteList(new SqlQuery(_eventItemTable).Select(cc1.SelectQuery)
                                                        .Where(Exp.In(evId.Name, evtIds)));

            //parsing           
            var events = new List<Event>();

            foreach (var r in data)
            {
                var ev = events.Find(e => String.Equals(e.Id, eId.Parse<string>(r), StringComparison.InvariantCultureIgnoreCase));
                if (ev == null)
                {
                    ev = new Event()
                    {
                        Id = eId.Parse<string>(r),
                        Name = eName.Parse<string>(r),
                        Description = eDescription.Parse<string>(r),
                        TenantId = eTenant.Parse<int>(r),
                        CalendarId = eCalId.Parse<string>(r),
                        UtcStartDate = eStartDate.Parse<DateTime>(r),
                        UtcEndDate = eEndDate.Parse<DateTime>(r),
                        AllDayLong = eIsAllDay.Parse<bool>(r),
                        OwnerId = eOwner.Parse<Guid>(r),
                        AlertType = (usrAlertType.IsNull(r)) ? (EventAlertType)eAlertType.Parse<int>(r) : (EventAlertType)usrAlertType.Parse<int>(r),
                        RecurrenceRule = eRRule.Parse<RecurrenceRule>(r)

                    };
                    events.Add(ev);
                }

                foreach (var row in sharingData)
                {
                    if (String.Equals(evId.Parse<string>(row), ev.Id, StringComparison.InvariantCultureIgnoreCase))
                    {
                        ev.SharingOptions.PublicItems.Add(new ASC.Web.Core.Calendars.SharingOptions.PublicItem()
                        {
                            Id = itemId.Parse<Guid>(row),
                            IsGroup = itemIsGroup.Parse<bool>(row)
                        });
                    }
                }
            }
            return events;
        }