Beispiel #1
0
        public static byte[] ToRecurrenceBlob(Properties easCalendarItem, ExDateTime start, ExDateTime end, ExTimeZone targetTimeZone)
        {
            Microsoft.Exchange.Connections.Eas.Model.Response.Calendar.Recurrence recurrence = easCalendarItem.Recurrence;
            RecurrencePattern  pattern            = SyncCalendarUtils.CreateRecurrencePattern(recurrence);
            RecurrenceRange    range              = SyncCalendarUtils.CreateRecurrenceRange(start, recurrence);
            ExDateTime         dt                 = targetTimeZone.ConvertDateTime(start);
            ExDateTime         dt2                = targetTimeZone.ConvertDateTime(end);
            TimeSpan           startOffset        = dt - dt.Date;
            TimeSpan           endOffset          = dt2 - dt2.Date;
            InternalRecurrence internalRecurrence = new InternalRecurrence(pattern, range, null, targetTimeZone, ExTimeZone.UtcTimeZone, startOffset, endOffset);

            if (easCalendarItem.Exceptions != null)
            {
                foreach (Microsoft.Exchange.Connections.Eas.Model.Response.Calendar.Exception ex in easCalendarItem.Exceptions)
                {
                    ExDateTime originalStartTime = SyncCalendarUtils.ToUtcExDateTime(ex.ExceptionStartTime);
                    ExDateTime date = originalStartTime.Date;
                    if (ex.Deleted)
                    {
                        internalRecurrence.TryDeleteOccurrence(date);
                    }
                    else
                    {
                        ModificationType  modificationType  = (ModificationType)0;
                        MemoryPropertyBag memoryPropertyBag = new MemoryPropertyBag();
                        memoryPropertyBag.SetAllPropertiesLoaded();
                        if (ex.Subject != easCalendarItem.CalendarSubject)
                        {
                            modificationType |= ModificationType.Subject;
                            memoryPropertyBag[ItemSchema.Subject] = ex.Subject;
                        }
                        if (ex.Reminder != easCalendarItem.Reminder)
                        {
                            modificationType |= ModificationType.ReminderDelta;
                            memoryPropertyBag[ItemSchema.ReminderMinutesBeforeStartInternal] = ex.Reminder;
                        }
                        if (ex.Location != easCalendarItem.Location)
                        {
                            modificationType |= ModificationType.Location;
                            memoryPropertyBag[CalendarItemBaseSchema.Location] = ex.Location;
                        }
                        if (ex.BusyStatus != easCalendarItem.BusyStatus)
                        {
                            modificationType |= ModificationType.BusyStatus;
                            memoryPropertyBag[CalendarItemBaseSchema.FreeBusyStatus] = ex.BusyStatus;
                        }
                        if (ex.AllDayEvent != easCalendarItem.AllDayEvent)
                        {
                            modificationType |= ModificationType.SubType;
                            memoryPropertyBag[CalendarItemBaseSchema.MapiIsAllDayEvent] = ex.AllDayEvent;
                        }
                        ExDateTime    startTime     = targetTimeZone.ConvertDateTime(SyncCalendarUtils.ToUtcExDateTime(ex.StartTime));
                        ExDateTime    endTime       = targetTimeZone.ConvertDateTime(SyncCalendarUtils.ToUtcExDateTime(ex.EndTime));
                        ExceptionInfo exceptionInfo = new ExceptionInfo(null, date, originalStartTime, startTime, endTime, modificationType, memoryPropertyBag);
                        internalRecurrence.ModifyOccurrence(exceptionInfo);
                    }
                }
            }
            return(internalRecurrence.ToByteArray());
        }
Beispiel #2
0
        internal static Activity CreateResetActivity()
        {
            MemoryPropertyBag memoryPropertyBag = new MemoryPropertyBag();

            memoryPropertyBag.SetProperty(ActivitySchema.ActivityId, ActivityId.Min);
            memoryPropertyBag.SetProperty(ActivitySchema.ClientId, ClientId.Exchange.ToInt());
            memoryPropertyBag.SetProperty(ActivitySchema.SessionId, AppendOnlyActivityLog.ResetActivityClientSessionId);
            memoryPropertyBag.SetProperty(ActivitySchema.TimeStamp, ExDateTime.UtcNow);
            return(new Activity(memoryPropertyBag));
        }
 internal PropertyBagStream(MemoryPropertyBag propertyBag, PropertyDefinition propDef, PropertyType propertyType, int sizeEstimate) : base(sizeEstimate)
 {
     Util.ThrowOnNullArgument(propertyBag, "propertyBag");
     Util.ThrowOnNullArgument(propDef, "propDef");
     if (propertyType != PropertyType.Unicode && propertyType != PropertyType.Binary)
     {
         throw new NotSupportedException(string.Format("PropertyBagStream only supports Unicode and Binary streams, actual type: {0}.", propertyType));
     }
     this.propertyBag  = propertyBag;
     this.propDef      = propDef;
     this.propertyType = propertyType;
 }
        private static Activity DeserializeActivity(BinaryReader reader, List <ActivityLogSerializer.SerializedPropertyInfo> propertyInfos)
        {
            MemoryPropertyBag memoryPropertyBag = new MemoryPropertyBag();

            foreach (ActivityLogSerializer.SerializedPropertyInfo serializedPropertyInfo in propertyInfos)
            {
                bool flag = reader.ReadBoolean();
                if (flag)
                {
                    object value = serializedPropertyInfo.PropertyDeserializer(reader);
                    if (serializedPropertyInfo.PropertyDefinition != null)
                    {
                        value = ActivityLogSerializer.ConvertPropertyValue(serializedPropertyInfo.PropertyDefinition, value);
                        memoryPropertyBag.SetProperty(serializedPropertyInfo.PropertyDefinition, value);
                    }
                }
            }
            return(new Activity(memoryPropertyBag));
        }
Beispiel #5
0
 internal Activity(MemoryPropertyBag propertyBag)
 {
     Util.ThrowOnNullArgument(propertyBag, "propertyBag");
     this.propertyBag = propertyBag;
     this.propertyBag.SetAllPropertiesLoaded();
 }
 public ActivityMessageAdapter(MemoryPropertyBag propertyBag)
 {
     Util.ThrowOnNullArgument(propertyBag, "propertyBag");
     this.propertyBag        = propertyBag;
     this.propertyBagAdapter = new ActivityPropertyBagAdapter(this.propertyBag);
 }
 private NavigationNodeFolder(MemoryPropertyBag propertyBag) : base(propertyBag)
 {
 }
 protected NavigationNode(MemoryPropertyBag propertyBag)
 {
     this.propertyBag = propertyBag;
     this.propertyBag.SetAllPropertiesLoaded();
     this.isNew = false;
 }
 private NavigationNodeGroup(MemoryPropertyBag propertyBag) : base(propertyBag)
 {
     this.children = new NavigationNodeGroup.NavigationNodeFolderList(this);
 }