public void Map1To2(TaskItemWrapper source, ITodo target, iCalTimeZone localIcalTimeZone, IEntityMappingLogger logger) { target.Summary = source.Inner.Subject; if (_configuration.MapBody) { target.Description = source.Inner.Body; } if (source.Inner.StartDate != _dateNull) { target.Start = new iCalDateTime(source.Inner.StartDate.Year, source.Inner.StartDate.Month, source.Inner.StartDate.Day, true); target.Start.SetTimeZone(localIcalTimeZone); } if (source.Inner.Complete && source.Inner.DateCompleted != _dateNull) { target.Completed = new iCalDateTime(source.Inner.DateCompleted.ToUniversalTime()) { IsUniversalTime = true, HasTime = true }; } target.PercentComplete = source.Inner.PercentComplete; if (_configuration.MapRecurringTasks) { MapRecurrance1To2(source.Inner, target, localIcalTimeZone); } if (source.Inner.DueDate != _dateNull) { target.Due = new iCalDateTime(source.Inner.DueDate.Year, source.Inner.DueDate.Month, source.Inner.DueDate.Day, 23, 59, 59); target.Due.SetTimeZone(localIcalTimeZone); // Workaround for a bug in DDay.iCal, according to RFC5545 DUE must not occur together with DURATION target.Properties.Remove(new CalendarProperty("DURATION")); } target.Properties.Set("STATUS", MapStatus1To2(source.Inner.Status)); if (_configuration.MapPriority) { target.Priority = CommonEntityMapper.MapPriority1To2(source.Inner.Importance); } target.Class = CommonEntityMapper.MapPrivacy1To2(source.Inner.Sensitivity, false); MapReminder1To2(source, target); MapCategories1To2(source, target); if (_configuration.MapCustomProperties || _configuration.UserDefinedCustomPropertyMappings.Length > 0) { using (var userPropertiesWrapper = GenericComObjectWrapper.Create(source.Inner.UserProperties)) { CommonEntityMapper.MapCustomProperties1To2(userPropertiesWrapper, target.Properties, _configuration.MapCustomProperties, _configuration.UserDefinedCustomPropertyMappings, logger, s_logger); } } }
public Task <vCard> Map1To2(IDistListItemWrapper source, vCard target, IEntityMappingLogger logger, DistributionListSychronizationContext context) { target.Members.Clear(); target.FormattedName = source.Inner.DLName; target.FamilyName = source.Inner.DLName; target.AccessClassification = CommonEntityMapper.MapPrivacy1To2(source.Inner.Sensitivity); target.Categories.Clear(); if (!string.IsNullOrEmpty(source.Inner.Categories)) { Array.ForEach( source.Inner.Categories.Split(new[] { CultureInfo.CurrentCulture.TextInfo.ListSeparator }, StringSplitOptions.RemoveEmptyEntries), c => target.Categories.Add(c.Trim()) ); } target.Notes.Clear(); if (!string.IsNullOrEmpty(source.Inner.Body)) { target.Notes.Add(new vCardNote(source.Inner.Body)); } for (int i = 1; i <= source.Inner.MemberCount; i++) { try { using (var recipientWrapper = GenericComObjectWrapper.Create(source.Inner.GetMember(i))) { var nameWithoutEmail = OutlookUtility.RemoveEmailFromName(recipientWrapper.Inner); var targetMember = CreateVCardMemberOrNull(recipientWrapper, nameWithoutEmail, context, logger, s_logger); if (targetMember != null) { target.Members.Add(targetMember); } } } catch (COMException ex) { s_logger.Warn("Can't access member of Distribution List!", ex); logger.LogMappingWarning("Can't access member of Distribution List!", ex); } } return(Task.FromResult(target)); }
public void Map1To2(TaskItemWrapper source, ITodo target, iCalTimeZone localIcalTimeZone) { target.Summary = source.Inner.Subject; target.Description = source.Inner.Body; if (source.Inner.StartDate != _dateNull) { target.Start = new iCalDateTime(source.Inner.StartDate.Year, source.Inner.StartDate.Month, source.Inner.StartDate.Day, true); target.Start.SetTimeZone(localIcalTimeZone); } if (source.Inner.DueDate != _dateNull) { target.Due = new iCalDateTime(source.Inner.DueDate.Year, source.Inner.DueDate.Month, source.Inner.DueDate.Day, 23, 59, 59); target.Due.SetTimeZone(localIcalTimeZone); // Workaround for a bug in DDay.iCal, according to RFC5545 DUE must not occur together with DURATION target.Properties.Remove(new CalendarProperty("DURATION")); } if (source.Inner.Complete && source.Inner.DateCompleted != _dateNull) { target.Completed = new iCalDateTime(source.Inner.DateCompleted.Year, source.Inner.DateCompleted.Month, source.Inner.DateCompleted.Day, true); target.Completed.SetTimeZone(localIcalTimeZone); } target.PercentComplete = source.Inner.PercentComplete; MapRecurrance1To2(source.Inner, target, localIcalTimeZone); target.Properties.Set("STATUS", MapStatus1To2(source.Inner.Status)); target.Priority = CommonEntityMapper.MapPriority1To2(source.Inner.Importance); target.Class = CommonEntityMapper.MapPrivacy1To2(source.Inner.Sensitivity, false); MapReminder1To2(source, target); MapCategories1To2(source, target); }
public Task <vCard> Map1To2(IContactItemWrapper source, vCard target, IEntitySynchronizationLogger logger, ICardDavRepositoryLogger context) { target.RevisionDate = source.Inner.LastModificationTime.ToUniversalTime(); target.GivenName = source.Inner.FirstName; target.FamilyName = source.Inner.LastName; target.NamePrefix = source.Inner.Title; target.NameSuffix = source.Inner.Suffix; target.AdditionalNames = source.Inner.MiddleName; target.Gender = MapGender2To1(source.Inner.Gender); target.Assistant = source.Inner.AssistantName; target.Spouse = source.Inner.Spouse; target.Manager = source.Inner.ManagerName; MapEmailAddresses1To2(source.Inner, target, logger); if (!string.IsNullOrEmpty(source.Inner.FileAs)) { target.FormattedName = source.Inner.FileAs; } else if (!string.IsNullOrEmpty(source.Inner.CompanyAndFullName)) { target.FormattedName = source.Inner.CompanyAndFullName; } else if (target.EmailAddresses.Count >= 1) { target.FormattedName = target.EmailAddresses[0].Address; } else { target.FormattedName = "<Empty>"; } target.Nicknames.Clear(); if (!string.IsNullOrEmpty(source.Inner.NickName)) { Array.ForEach( source.Inner.NickName.Split(new[] { CultureInfo.CurrentCulture.TextInfo.ListSeparator }, StringSplitOptions.RemoveEmptyEntries), c => target.Nicknames.Add(c) ); } target.AccessClassification = CommonEntityMapper.MapPrivacy1To2(source.Inner.Sensitivity); target.Categories.Clear(); if (!string.IsNullOrEmpty(source.Inner.Categories)) { Array.ForEach( source.Inner.Categories.Split(new[] { CultureInfo.CurrentCulture.TextInfo.ListSeparator }, StringSplitOptions.RemoveEmptyEntries), c => target.Categories.Add(c.Trim()) ); } target.IMs.Clear(); if (!string.IsNullOrEmpty(source.Inner.IMAddress)) { //IMAddress are expected to be in form of ([Protocol]: [Address]; [Protocol]: [Address]) var imsRaw = source.Inner.IMAddress.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (var imRaw in imsRaw) { var imDetails = imRaw.Trim().Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries); var im = new vCardIMPP(); if (imDetails.Length == 1) { im.Handle = imDetails[0].Trim(); // Set default ServiceType to the configured DefaultImServiceType (defaults to AIM) im.ServiceType = _configuration.DefaultImServicType; } else if (imDetails.Length > 1) { var serviceType = IMTypeUtils.GetIMServiceType(imDetails[0].Trim()); if (serviceType == null) { im.ServiceType = _configuration.DefaultImServicType; s_logger.Warn($"Unknown IM ServiceType '{imDetails[0]}' not implemented, defaulting to '{_configuration.DefaultImServicType}'"); logger.LogWarning($"Unknown IM ServiceType '{imDetails[0]}' not implemented, defaulting to '{_configuration.DefaultImServicType}'"); } else { im.ServiceType = serviceType.Value; } im.Handle = imRaw.Substring(imRaw.IndexOf(":") + 1).Trim(); } //Only add the im Address if not empty if (!string.IsNullOrEmpty(im.Handle)) { im.IsPreferred = target.IMs.Count == 0; im.ItemType = ItemType.HOME; target.IMs.Add(im); } } } target.DeliveryAddresses.Clear(); if (!string.IsNullOrEmpty(source.Inner.HomeAddress)) { vCardDeliveryAddress homeAddress = new vCardDeliveryAddress(); homeAddress.AddressType.Add(vCardDeliveryAddressTypes.Home); homeAddress.City = source.Inner.HomeAddressCity; homeAddress.Country = source.Inner.HomeAddressCountry; homeAddress.PostalCode = source.Inner.HomeAddressPostalCode; homeAddress.Region = source.Inner.HomeAddressState; homeAddress.Street = source.Inner.HomeAddressStreet; homeAddress.PoBox = source.Inner.HomeAddressPostOfficeBox; if (source.Inner.SelectedMailingAddress == OlMailingAddress.olHome) { homeAddress.AddressType.Add(vCardDeliveryAddressTypes.Preferred); } target.DeliveryAddresses.Add(homeAddress); } if (!string.IsNullOrEmpty(source.Inner.BusinessAddress) || !string.IsNullOrEmpty(source.Inner.OfficeLocation)) { vCardDeliveryAddress businessAddress = new vCardDeliveryAddress(); businessAddress.AddressType.Add(vCardDeliveryAddressTypes.Work); businessAddress.City = source.Inner.BusinessAddressCity; businessAddress.Country = source.Inner.BusinessAddressCountry; businessAddress.PostalCode = source.Inner.BusinessAddressPostalCode; businessAddress.Region = source.Inner.BusinessAddressState; businessAddress.Street = source.Inner.BusinessAddressStreet; businessAddress.PoBox = source.Inner.BusinessAddressPostOfficeBox; if (!string.IsNullOrEmpty(source.Inner.OfficeLocation)) { businessAddress.ExtendedAddress = source.Inner.OfficeLocation; } if (source.Inner.SelectedMailingAddress == OlMailingAddress.olBusiness) { businessAddress.AddressType.Add(vCardDeliveryAddressTypes.Preferred); } target.DeliveryAddresses.Add(businessAddress); } if (!string.IsNullOrEmpty(source.Inner.OtherAddress)) { vCardDeliveryAddress otherAddress = new vCardDeliveryAddress(); otherAddress.City = source.Inner.OtherAddressCity; otherAddress.Country = source.Inner.OtherAddressCountry; otherAddress.PostalCode = source.Inner.OtherAddressPostalCode; otherAddress.Region = source.Inner.OtherAddressState; otherAddress.Street = source.Inner.OtherAddressStreet; otherAddress.PoBox = source.Inner.OtherAddressPostOfficeBox; if (source.Inner.SelectedMailingAddress == OlMailingAddress.olOther) { otherAddress.AddressType.Add(vCardDeliveryAddressTypes.Preferred); } target.DeliveryAddresses.Add(otherAddress); } MapPhoneNumbers1To2(source.Inner, target); if (_configuration.MapAnniversary) { target.Anniversary = source.Inner.Anniversary.Equals(OutlookUtility.OUTLOOK_DATE_NONE) ? default(DateTime?) : source.Inner.Anniversary.Date; } if (_configuration.MapBirthday) { target.BirthDate = source.Inner.Birthday.Equals(OutlookUtility.OUTLOOK_DATE_NONE) ? default(DateTime?) : source.Inner.Birthday.Date; } target.Organization = source.Inner.CompanyName; target.Department = source.Inner.Department; target.Title = source.Inner.JobTitle; target.Role = source.Inner.Profession; target.Websites.Clear(); if (!string.IsNullOrEmpty(source.Inner.PersonalHomePage)) { target.Websites.Add(new vCardWebsite(source.Inner.PersonalHomePage, vCardWebsiteTypes.Personal)); } if (!string.IsNullOrEmpty(source.Inner.BusinessHomePage)) { target.Websites.Add(new vCardWebsite(source.Inner.BusinessHomePage, vCardWebsiteTypes.Work)); } MapCertificate1To2(source.Inner, target, logger); if (_configuration.MapContactPhoto) { MapPhoto1To2(source.Inner, target, logger); } target.Notes.Clear(); if (!string.IsNullOrEmpty(source.Inner.Body)) { target.Notes.Add(new vCardNote(source.Inner.Body)); } return(Task.FromResult(target)); }