public TaskItemWrapper Map2To1(ITodo source, TaskItemWrapper target, IEntityMappingLogger logger) { target.Inner.Subject = source.Summary; target.Inner.Body = _configuration.MapBody ? source.Description : string.Empty; NodaTime.DateTimeZone localZone = NodaTime.DateTimeZoneProviders.Bcl.GetSystemDefault(); if (source.Start != null) { if (source.Start.IsUniversalTime) { target.Inner.StartDate = NodaTime.Instant.FromDateTimeUtc(source.Start.Value).InZone(localZone).ToDateTimeUnspecified().Date; } else { target.Inner.StartDate = source.Start.Date; } } if (source.Due != null) { if (source.Start == null || source.Start.Value <= source.Due.Value) { if (source.Due.IsUniversalTime) { target.Inner.DueDate = NodaTime.Instant.FromDateTimeUtc(source.Due.Value).InZone(localZone).ToDateTimeUnspecified().Date; } else { target.Inner.DueDate = source.Due.Date; } } } if (source.Completed != null) { if (source.Completed.IsUniversalTime) { target.Inner.DateCompleted = NodaTime.Instant.FromDateTimeUtc(source.Completed.Value).InZone(localZone).ToDateTimeUnspecified().Date; } else { target.Inner.DateCompleted = source.Completed.Date; } target.Inner.Complete = true; } else { target.Inner.Complete = false; } target.Inner.PercentComplete = source.PercentComplete; if (_configuration.MapPriority) { target.Inner.Importance = CommonEntityMapper.MapPriority2To1(source.Priority); } target.Inner.Sensitivity = CommonEntityMapper.MapPrivacy2To1(source.Class, false); target.Inner.Status = MapStatus2To1(source.Status); MapCategories2To1(source, target); MapReminder2To1(source, target, logger); if (_configuration.MapRecurringTasks) { MapRecurrance2To1(source, target, logger); } return(target); }
public ITaskItemWrapper Map2To1(ITodo source, ITaskItemWrapper target, IEntitySynchronizationLogger logger) { target.Inner.Subject = source.Summary; target.Inner.Body = _configuration.MapBody ? source.Description : string.Empty; DateTimeZone localZone = DateTimeZoneProviders.Bcl.GetSystemDefault(); if (source.Start != null) { if (source.Start.IsUniversalTime) { target.Inner.StartDate = Instant.FromDateTimeUtc(source.Start.Value).InZone(localZone).ToDateTimeUnspecified().Date; } else { target.Inner.StartDate = source.Start.Date; } } else { target.Inner.StartDate = OutlookUtility.OUTLOOK_DATE_NONE; } if (source.Due != null) { if (source.Start == null || source.Start.Value <= source.Due.Value) { if (source.Due.IsUniversalTime) { target.Inner.DueDate = Instant.FromDateTimeUtc(source.Due.Value).InZone(localZone).ToDateTimeUnspecified().Date; } else { target.Inner.DueDate = source.Due.Date; } } } else { target.Inner.DueDate = OutlookUtility.OUTLOOK_DATE_NONE; } if (source.Completed != null) { if (source.Completed.IsUniversalTime) { target.Inner.DateCompleted = Instant.FromDateTimeUtc(source.Completed.Value).InZone(localZone).ToDateTimeUnspecified().Date; } else { target.Inner.DateCompleted = source.Completed.Date; } target.Inner.Complete = true; } else { target.Inner.Complete = false; } target.Inner.Status = (target.Inner.Complete && target.Inner.PercentComplete == 100) ? OlTaskStatus.olTaskComplete : MapStatus2To1(source.Status); // Only set PercentComplete if source is actually set and status is not already completed to avoid overwriting the status again if (source.PercentComplete != 0 && target.Inner.Status != OlTaskStatus.olTaskComplete) { target.Inner.PercentComplete = source.PercentComplete; } if (_configuration.MapPriority) { target.Inner.Importance = CommonEntityMapper.MapPriority2To1(source.Priority); } target.Inner.Sensitivity = CommonEntityMapper.MapPrivacy2To1(source.Class, false, false); MapCategories2To1(source, target); MapReminder2To1(source, target, logger); if (_configuration.MapCustomProperties || _configuration.UserDefinedCustomPropertyMappings.Length > 0) { using (var userPropertiesWrapper = GenericComObjectWrapper.Create(target.Inner.UserProperties)) { CommonEntityMapper.MapCustomProperties2To1(source.Properties, userPropertiesWrapper, _configuration.MapCustomProperties, _configuration.UserDefinedCustomPropertyMappings, logger, s_logger); } } if (_configuration.MapRecurringTasks) { MapRecurrance2To1(source, target, logger); } return(target); }