#pragma warning disable 1998 public async Task <IEnumerable <EntityWithId <AppointmentId, IAppointmentItemWrapper> > > Get(ICollection <AppointmentId> ids, ILoadEntityLogger logger, IEventSynchronizationContext context) #pragma warning restore 1998 { return(ids .Select(id => EntityWithId.Create( id, _comWrapperFactory.Create( _session.GetAppointmentItem(id.EntryId, _folderStoreId), entryId => _session.GetAppointmentItem(entryId, _folderStoreId))))); }
private void SwitchEventCategories(ChangedOptions changedOption, string oldCategory, string newCategory, AppointmentId eventId) { using (var eventWrapper = new AppointmentItemWrapper( _session.GetAppointmentItem(eventId.EntryId, changedOption.New.OutlookFolderStoreId), entryId => _session.GetAppointmentItem(entryId, changedOption.New.OutlookFolderStoreId))) { var categories = eventWrapper.Inner.Categories .Split(new[] { CultureInfo.CurrentCulture.TextInfo.ListSeparator }, StringSplitOptions.RemoveEmptyEntries) .Select(c => c.Trim()); eventWrapper.Inner.Categories = string.Join( CultureInfo.CurrentCulture.TextInfo.ListSeparator, categories .Except(new[] { oldCategory }) .Concat(new[] { newCategory }) .Distinct()); eventWrapper.Inner.Save(); } }
public Task <bool> TryDelete( string entityId, DateTime version, Tcontext context, IEntitySynchronizationLogger logger) { var entityWithId = Get(new[] { entityId }, NullLoadEntityLogger.Instance, default(Tcontext)).Result.SingleOrDefault(); if (entityWithId == null) { return(Task.FromResult(true)); } using (var contact = entityWithId.Entity) { if (!contact.Inner.Anniversary.Equals(OutlookUtility.OUTLOOK_DATE_NONE)) { try { Byte[] ba = contact.Inner.GetPropertySafe(PR_ASSOCIATED_ANNIVERSARY_APPOINTMENT_ID); string anniversaryAppointmentItemID = BitConverter.ToString(ba).Replace("-", string.Empty); IAppointmentItemWrapper anniveraryWrapper = _comWrapperFactory.Create(_session.GetAppointmentItem(anniversaryAppointmentItemID), entryId => _session.GetAppointmentItem(anniversaryAppointmentItemID)); anniveraryWrapper.Inner.Delete(); } catch (COMException ex) { s_logger.Error("Could not delete associated Anniversary Appointment.", ex); logger.LogError("Could not delete associated Anniversary Appointment.", ex); } } if (!contact.Inner.Birthday.Equals(OutlookUtility.OUTLOOK_DATE_NONE)) { try { Byte[] ba = contact.Inner.GetPropertySafe(PR_ASSOCIATED_BIRTHDAY_APPOINTMENT_ID); string birthdayAppointmentItemID = BitConverter.ToString(ba).Replace("-", string.Empty); IAppointmentItemWrapper birthdayWrapper = _comWrapperFactory.Create(_session.GetAppointmentItem(birthdayAppointmentItemID), entryId => _session.GetAppointmentItem(birthdayAppointmentItemID)); birthdayWrapper.Inner.Delete(); } catch (COMException ex) { s_logger.Error("Could not delete associated Birthday Appointment.", ex); logger.LogError("Could not delete associated Birthday Appointment.", ex); } } contact.Inner.Delete(); } return(Task.FromResult(true)); }
List <AppointmentSlim> IQueryOutlookAppointmentItemFolderStrategy.QueryAppointmentFolder(IOutlookSession session, Folder calendarFolder, string filter) { var events = new List <AppointmentSlim>(); using (var tableWrapper = GenericComObjectWrapper.Create( calendarFolder.GetTable(filter))) { var table = tableWrapper.Inner; table.Columns.RemoveAll(); table.Columns.Add(c_entryIdColumnName); var storeId = calendarFolder.StoreID; while (!table.EndOfTable) { var row = table.GetNextRow(); var entryId = (string)row[c_entryIdColumnName]; try { using (var appointmentWrapper = GenericComObjectWrapper.Create(session.GetAppointmentItem(entryId, storeId))) { events.Add(AppointmentSlim.FromAppointmentItem(appointmentWrapper.Inner)); } } catch (COMException ex) { s_logger.Error("Could not fetch AppointmentItem, skipping.", ex); } } } return(events); }