protected override Event OnExecute()
        {
            EventDataProvider eventDataProvider = this.Scope.EventDataProvider;
            Event             result;

            try
            {
                eventDataProvider.StoreObjectSaved       += this.OnStoreObjectSaved;
                eventDataProvider.BeforeStoreObjectSaved += this.DataProviderOnBeforeStoreObjectSaved;
                if (!this.PropagationInProgress)
                {
                    using (ICalendarItemBase calendarItemBase = eventDataProvider.ValidateAndBindToWrite(base.Entity))
                    {
                        Event @event = eventDataProvider.ConvertToEntity(calendarItemBase);
                        base.MergeAttendeesList(@event.Attendees);
                        if (this.IsNprInstance(calendarItemBase))
                        {
                            this.ValidateSeriesMasterId(calendarItemBase as ICalendarItem);
                            this.PreProcessNprInstance(@event);
                        }
                    }
                }
                result = eventDataProvider.Update(base.Entity, this.Context);
            }
            finally
            {
                eventDataProvider.StoreObjectSaved       -= this.OnStoreObjectSaved;
                eventDataProvider.BeforeStoreObjectSaved -= this.DataProviderOnBeforeStoreObjectSaved;
            }
            return(result);
        }
Exemple #2
0
 public void ToXso(IList <Attendee> attendees, ICalendarItemBase calendarItem)
 {
     if (calendarItem == null)
     {
         throw new ExArgumentNullException("calendarItem");
     }
     if (calendarItem.IsOrganizer())
     {
         IAttendeeCollection attendeeCollection = calendarItem.AttendeeCollection;
         attendeeCollection.Clear();
         AttendeeConverter.StorageAttendeeData[] array;
         Participant[] array2;
         if (this.TryGetAttendeesData(calendarItem.Session, attendees, out array, out array2))
         {
             for (int i = 0; i < array2.Length; i++)
             {
                 AttendeeConverter.StorageAttendeeData storageAttendeeData = array[i];
                 calendarItem.AttendeeCollection.Add(array2[i], storageAttendeeData.AttendeeType, storageAttendeeData.ResponseType, storageAttendeeData.ReplyTime, true);
             }
         }
         if (calendarItem.AttendeeCollection.Count > 0)
         {
             calendarItem.IsMeeting = true;
         }
     }
 }
        protected override bool PerformTryGetValue(ICalendarItemBase container, out IList <Attendee> value)
        {
            AttendeeConverter      converter  = this.GetConverter(container);
            IEnumerable <Attendee> enumerable = converter.Convert(container.AttendeeCollection);

            value = ((enumerable == null) ? null : enumerable.ToList <Attendee>());
            return(enumerable != null);
        }
        private void StampRetryProperties(IEvent sourceEntity, ICalendarItemBase calendarItemBase)
        {
            calendarItemBase.ClientId = this.ClientId;
            ICalendarItem calendarItem = calendarItemBase as ICalendarItem;

            if (calendarItem != null)
            {
                calendarItem.InstanceCreationIndex = ((IEventInternal)sourceEntity).InstanceCreationIndex;
            }
        }
        protected virtual Event ReadMasterFromInstance(Event instance)
        {
            Event result;

            if (!this.TryReadMasterFromSeriesMasterId(instance, out result))
            {
                ICalendarItemBase storeObject = this.Scope.EventDataProvider.BindToMasterFromSeriesId(instance.SeriesId);
                result = this.Scope.EventDataProvider.ConvertToEntity(storeObject);
            }
            return(result);
        }
Exemple #6
0
        private void OnStoreObjectSaved(object sender, ICalendarItemBase calendarItemBase)
        {
            this.Scope.EventDataProvider.TryLogCalendarEventActivity(ActivityId.CreateCalendarEvent, calendarItemBase.Id.ObjectId);
            bool flag;

            CalendarItemAccessors.IsDraft.TryGetValue(calendarItemBase, out flag);
            if (!flag && calendarItemBase.AttendeeCollection != null && calendarItemBase.AttendeeCollection.Count > 0)
            {
                calendarItemBase.SendMeetingMessages(true, null, false, true, null, null);
                calendarItemBase.Load();
            }
        }
 private void OnStoreObjectSaved(object sender, ICalendarItemBase calendarItemBase)
 {
     this.Scope.EventDataProvider.TryLogCalendarEventActivity(ActivityId.UpdateCalendarEvent, calendarItemBase.Id.ObjectId);
     if (this.SendMeetingMessagesOnSave && calendarItemBase.IsOrganizer())
     {
         bool flag;
         CalendarItemAccessors.IsDraft.TryGetValue(calendarItemBase, out flag);
         if (!flag && (calendarItemBase.IsMeeting || (calendarItemBase.AttendeeCollection != null && calendarItemBase.AttendeeCollection.Count > 0)))
         {
             calendarItemBase.SendMeetingMessages(true, this.SeriesSequenceNumber, false, true, null, this.MasterGoid);
             calendarItemBase.Load();
         }
     }
 }
        internal void SendMessagesForInstances(IEnumerable <Event> occurrences, int seriesSequenceNumber, byte[] masterGoid)
        {
            SeriesEventDataProvider seriesEventDataProvider = this.Scope.SeriesEventDataProvider;

            foreach (Event @event in occurrences)
            {
                using (ICalendarItemBase calendarItemBase = seriesEventDataProvider.BindToWrite(@event.StoreId, @event.ChangeKey))
                {
                    if (this.ShouldSendMeetingRequest(calendarItemBase))
                    {
                        calendarItemBase.SendMeetingMessages(true, new int?(seriesSequenceNumber), false, true, null, masterGoid);
                    }
                }
            }
        }
Exemple #9
0
        protected override void BeforeParentItemSave(IItem parentItem)
        {
            ICalendarItemBase calendarItemBase = parentItem as ICalendarItemBase;

            if (calendarItemBase != null)
            {
                bool flag;
                CalendarItemAccessors.HasAttendees.TryGetValue(calendarItemBase, out flag);
                if (flag)
                {
                    calendarItemBase[CalendarItemBaseSchema.IsDraft] = true;
                    return;
                }
                calendarItemBase[CalendarItemBaseSchema.IsDraft] = false;
            }
        }
 public virtual void AdjustTimeProperties(ICalendarItemBase calendarItem)
 {
     EventTimeAdjuster.TimeProperties initialValues = new EventTimeAdjuster.TimeProperties
     {
         IsAllDay = this.GetValue <ICalendarItemBase, bool>(calendarItem, CalendarItemAccessors.IsAllDay),
         Start    = this.GetValue <ICalendarItemBase, ExDateTime>(calendarItem, CalendarItemAccessors.StartTime),
         End      = this.GetValue <ICalendarItemBase, ExDateTime>(calendarItem, CalendarItemAccessors.EndTime),
         IntendedStartTimeZone = this.GetValue <ICalendarItemBase, ExTimeZone>(calendarItem, CalendarItemAccessors.StartTimeZone),
         IntendedEndTimeZone   = this.GetValue <ICalendarItemBase, ExTimeZone>(calendarItem, CalendarItemAccessors.EndTimeZone)
     };
     EventTimeAdjuster.TimeProperties timeProperties = this.AdjustTimeProperties(initialValues, calendarItem.Session.ExTimeZone);
     CalendarItemAccessors.IsAllDay.Set(calendarItem, timeProperties.IsAllDay);
     CalendarItemAccessors.StartTime.Set(calendarItem, timeProperties.Start);
     CalendarItemAccessors.EndTime.Set(calendarItem, timeProperties.End);
     CalendarItemAccessors.StartTimeZone.Set(calendarItem, timeProperties.IntendedStartTimeZone);
     CalendarItemAccessors.EndTimeZone.Set(calendarItem, timeProperties.IntendedEndTimeZone);
 }
 internal Event SendMessagesForSeries(Event masterForInstanceCreation, int seriesSequenceNumber, string occurrencesViewPropertiesBlob)
 {
     if (!masterForInstanceCreation.IsDraft)
     {
         SeriesEventDataProvider seriesEventDataProvider = this.Scope.SeriesEventDataProvider;
         using (ICalendarItemBase calendarItemBase = seriesEventDataProvider.BindToWrite(masterForInstanceCreation.StoreId, masterForInstanceCreation.ChangeKey))
         {
             if (this.ShouldSendMeetingRequest(calendarItemBase))
             {
                 calendarItemBase.SendMeetingMessages(true, new int?(seriesSequenceNumber), false, true, occurrencesViewPropertiesBlob, null);
                 calendarItemBase.Load();
                 return(seriesEventDataProvider.ConvertToEntity(calendarItemBase));
             }
         }
         return(masterForInstanceCreation);
     }
     return(masterForInstanceCreation);
 }
        private void OnBeforeStoreObjectSaved(BirthdayEvent birthdayEvent, ICalendarItemBase calendarItemBase)
        {
            CreateBirthdayEventForContact.CreateBirthdayEventTracer.TraceDebug <BirthdayEvent, ICalendarItemBase>(0L, "CreateBirthdayEventForContact::OnBeforeStoreObjectSaved: The birthday event {0} was created, and the calendar item {1} will be saved", birthdayEvent, calendarItemBase);
            calendarItemBase.FreeBusyStatus = BusyType.Free;
            calendarItemBase.IsAllDayEvent  = true;
            ExDateTime        exDateTime = birthdayEvent.Birthday.ToUtc();
            RecurrencePattern pattern    = new YearlyRecurrencePattern(exDateTime.Day, exDateTime.Month);
            int             year         = birthdayEvent.IsBirthYearKnown ? exDateTime.Year : ExDateTime.Today.Year;
            ExTimeZone      timeZone     = this.DetermineRecurrenceStartTimeZone();
            ExDateTime      startDate    = new ExDateTime(timeZone, year, exDateTime.Month, exDateTime.Day);
            RecurrenceRange range        = new NoEndRecurrenceRange(startDate);
            ICalendarItem   calendarItem = calendarItemBase as ICalendarItem;

            if (calendarItem == null)
            {
                throw new NotSupportedException("Must be able to cast base to calendar item to specify recurrence.");
            }
            calendarItem.Recurrence = new Recurrence(pattern, range);
            calendarItem.ReminderMinutesBeforeStart = 1080;
            CreateBirthdayEventForContact.CreateBirthdayEventTracer.TraceDebug <ExDateTime, ExTimeZone>(0L, "CreateBirthdayEventForContact::OnBeforeStoreObjectSaved: recurrence start date is {0}, read time zone is {1}", calendarItem.Recurrence.Range.StartDate, calendarItem.Recurrence.ReadExTimeZone);
        }
        protected virtual IList <Event> GetPatternRecurrenceExceptionsInWindow(Event master, ExDateTime windowStart, ExDateTime windowEnd)
        {
            List <Event> list = new List <Event>();

            using (ICalendarItemBase calendarItemBase = this.Scope.EventDataProvider.BindToStoreObject(IdConverter.Instance.GetStoreId(master)))
            {
                CalendarItem calendarItem = calendarItemBase as CalendarItem;
                if (calendarItem != null && calendarItem.Recurrence != null)
                {
                    IList <OccurrenceInfo> modifiedOccurrences = calendarItem.Recurrence.GetModifiedOccurrences();
                    foreach (OccurrenceInfo occurrenceInfo in modifiedOccurrences)
                    {
                        if (CalendarFolder.IsInWindow(windowStart, windowEnd, occurrenceInfo.StartTime, occurrenceInfo.EndTime))
                        {
                            list.Add(this.Scope.Read(IdConverter.Instance.ToStringId(occurrenceInfo.VersionedId, this.Scope.Session), null));
                        }
                    }
                }
            }
            return(list);
        }
        protected virtual IList <Event> GetPatternRecurrenceOccurrenceInWindow(Event master, ExDateTime windowStart, ExDateTime windowEnd)
        {
            List <Event> list = new List <Event>();

            using (ICalendarItemBase calendarItemBase = this.Scope.EventDataProvider.BindToStoreObject(IdConverter.Instance.GetStoreId(master)))
            {
                CalendarItem calendarItem = calendarItemBase as CalendarItem;
                if (calendarItem != null && calendarItem.Recurrence != null)
                {
                    IList <OccurrenceInfo> occurrenceInfoList = calendarItem.Recurrence.GetOccurrenceInfoList(windowStart, windowEnd);
                    foreach (OccurrenceInfo occurrenceInfo in occurrenceInfoList)
                    {
                        Event @event = this.Scope.Read(IdConverter.Instance.ToStringId(occurrenceInfo.VersionedId, this.Scope.Session), null);
                        if (@event.Type == EventType.Occurrence)
                        {
                            list.Add(@event);
                        }
                    }
                }
            }
            return(list);
        }
        protected virtual IList <string> GetDeletedOccurrenceIds(Event master, ExDateTime windowStart, ExDateTime windowEnd)
        {
            List <string> list    = new List <string>();
            StoreId       storeId = IdConverter.Instance.GetStoreId(master);

            using (ICalendarItemBase calendarItemBase = this.Scope.EventDataProvider.BindToStoreObject(storeId))
            {
                CalendarItem calendarItem = calendarItemBase as CalendarItem;
                if (calendarItem != null && calendarItem.Recurrence != null)
                {
                    ExDateTime[] deletedOccurrences = calendarItem.Recurrence.GetDeletedOccurrences();
                    foreach (ExDateTime exDateTime in deletedOccurrences)
                    {
                        ExDateTime endTime = exDateTime.Add(master.End.Subtract(master.Start));
                        if (CalendarFolder.IsInWindow(windowStart, windowEnd, exDateTime, endTime))
                        {
                            OccurrenceStoreObjectId storeId2 = new OccurrenceStoreObjectId(StoreId.GetStoreObjectId(storeId).ProviderLevelItemId, exDateTime);
                            list.Add(IdConverter.Instance.ToStringId(storeId2, this.Scope.Session));
                        }
                    }
                }
            }
            return(list);
        }
Exemple #16
0
 private void StampRetryProperties(IEvent sourceEntity, ICalendarItemBase calendarItemBase)
 {
     calendarItemBase.ClientId = base.Entity.ClientId;
 }
Exemple #17
0
 private bool IsNprInstance(ICalendarItemBase targetStoreObject)
 {
     return(!string.IsNullOrEmpty(targetStoreObject.SeriesId) && !ObjectClass.IsCalendarItemSeries(targetStoreObject.ItemClass));
 }
 private AttendeeConverter GetConverter(ICalendarItemBase calendarItem)
 {
     return(new AttendeeConverter(StorageAttendeesPropertyAccessor.ResponseTypeConverter, StorageAttendeesPropertyAccessor.TypeConverter, calendarItem));
 }
Exemple #19
0
 protected virtual void DataProviderOnBeforeStoreObjectSaved(Event update, ICalendarItemBase itemToSave)
 {
     this.Scope.TimeAdjuster.AdjustTimeProperties(itemToSave);
 }
        protected override void PerformSet(ICalendarItemBase container, IList <Attendee> value)
        {
            AttendeeConverter converter = this.GetConverter(container);

            converter.ToXso(value, container);
        }
 private static void OnStoreObjectSaved(object sender, ICalendarItemBase calendarItemBase)
 {
     CreateBirthdayEventForContact.CreateBirthdayEventTracer.TraceDebug <ICalendarItemBase>(0L, "CreateBirthdayEventForContact::OnStoreObjectSaved: The birthday event calendar item was saved successfully: {0}", calendarItemBase);
 }
Exemple #22
0
 public AttendeeConverter(IResponseTypeConverter responseTypeConverter, IAttendeeTypeConverter attendeeTypeConverter, ICalendarItemBase calendarItem) : base(new ParticipantRoutingTypeConverter(calendarItem.AssertNotNull("calendarItem").Session))
 {
     this.includeStatus         = calendarItem.IsOrganizer();
     this.responseTypeConverter = responseTypeConverter;
     this.attendeeTypeConverter = attendeeTypeConverter;
 }
 private bool ShouldSendMeetingRequest(ICalendarItemBase calendarItemBase)
 {
     return(!calendarItemBase.MeetingRequestWasSent && calendarItemBase.AttendeeCollection != null && calendarItemBase.AttendeeCollection.Count > 0);
 }
 internal EventReference(IXSOFactory xsoFactory, ICalendarItemBase calendarItem) : base(new StorageEntitySetScope <IStoreSession>(calendarItem.Session, calendarItem.Session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), xsoFactory, null), calendarItem.Id.AssertNotNull("calendarItem.Id"), calendarItem.Session)
 {
 }