public Task <IEnumerable <EntityVersion <Identifier, int> > > GetAllVersions(IEnumerable <Identifier> idsOfknownEntities, int context, IGetVersionsLogger logger) { return(Task.FromResult <IEnumerable <EntityVersion <Identifier, int> > >( EntityVersionAndContentById.Select(kv => EntityVersion.Create(kv.Key, kv.Value.Item1)).ToList())); }
public Task <IEnumerable <EntityVersion <string, DateTime> > > GetAllVersions(IEnumerable <string> idsOfknownEntities, Tcontext context, IGetVersionsLogger logger) { using (var addressbookFolderWrapper = CreateFolderWrapper()) { bool isInstantSearchEnabled = false; try { using (var store = GenericComObjectWrapper.Create(addressbookFolderWrapper.Inner.Store)) { if (store.Inner != null) { isInstantSearchEnabled = store.Inner.IsInstantSearchEnabled; } } } catch (COMException) { s_logger.Info("Can't access IsInstantSearchEnabled property of store, defaulting to false."); } var filter = _daslFilterProvider.GetContactFilter(isInstantSearchEnabled); return(Task.FromResult <IEnumerable <EntityVersion <string, DateTime> > >(_queryFolderStrategy.QueryContactItemFolder(_session, addressbookFolderWrapper.Inner, _folderId, filter, logger))); } }
public async Task <IEnumerable <EntityVersion <WebResourceName, string> > > GetAllVersions(IEnumerable <WebResourceName> idsOfknownEntities, ICardDavRepositoryLogger context, IGetVersionsLogger logger) { var result = await _inner.GetAllVersions(idsOfknownEntities, 0, logger); context.LogEntitiesExists(result.Select(e => e.Id)); return(result); }
public Task <IEnumerable <EntityVersion <string, DateTime> > > GetAllVersions(IEnumerable <string> idsOfknownEntities, int context, IGetVersionsLogger logger) { List <EntityVersion <string, DateTime> > tasks; using (var taskFolderWrapper = CreateFolderWrapper()) { bool isInstantSearchEnabled = false; try { using (var store = GenericComObjectWrapper.Create(taskFolderWrapper.Inner.Store)) { if (store.Inner != null) { isInstantSearchEnabled = store.Inner.IsInstantSearchEnabled; } } } catch (COMException) { s_logger.Info("Can't access IsInstantSearchEnabled property of store, defaulting to false."); } var filterBuilder = new StringBuilder(_daslFilterProvider.GetTaskFilter(isInstantSearchEnabled)); if (_configuration.UseTaskCategoryAsFilter) { OutlookEventRepository.AddCategoryFilter(filterBuilder, _configuration.TaskCategory, _configuration.InvertTaskCategoryFilter, _configuration.IncludeEmptyTaskCategoryFilter); } s_logger.DebugFormat("Using Outlook DASL filter: {0}", filterBuilder.ToString()); tasks = _queryFolderStrategy.QueryTaskFolder(_session, taskFolderWrapper.Inner, filterBuilder.ToString(), logger); } if (_configuration.IsCategoryFilterSticky && _configuration.UseTaskCategoryAsFilter) { var knownEntitesThatWereFilteredOut = idsOfknownEntities.Except(tasks.Select(e => e.Id)); tasks.AddRange( knownEntitesThatWereFilteredOut .Select(id => _session.GetTaskItemOrNull(id, _folderId, _folderStoreId)) .Where(i => i != null) .ToSafeEnumerable() .Select(t => new EntityVersion <string, DateTime> (t.EntryID, t.LastModificationTime.ToUniversalTime()))); } return(Task.FromResult <IEnumerable <EntityVersion <string, DateTime> > > (tasks)); }
public async Task <IEnumerable <EntityVersion <string, string> > > GetVersions(IEnumerable <IdWithAwarenessLevel <string> > idsOfEntitiesToQuery, int context, IGetVersionsLogger logger) { var idsOfEntitiesToQueryDictionary = idsOfEntitiesToQuery.ToDictionary(i => i.Id); return((await GetAllVersions(new string[] { }, context, logger)) .Where(v => idsOfEntitiesToQueryDictionary.ContainsKey(v.Id)) .ToArray()); }
public Task <IEnumerable <EntityVersion <WebResourceName, string> > > GetVersions(IEnumerable <IdWithAwarenessLevel <WebResourceName> > idsOfEntitiesToQuery, TContext context, IGetVersionsLogger logger) { return(_decorated.GetVersions(idsOfEntitiesToQuery, context, logger)); }
List <AppointmentSlim> IQueryOutlookAppointmentItemFolderStrategy.QueryAppointmentFolder(IOutlookSession session, Folder calendarFolder, string filter, IGetVersionsLogger logger) { 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); }
List <EntityVersion <string, DateTime> > IQueryOutlookTaskItemFolderStrategy.QueryTaskFolder(IOutlookSession session, Folder folder, string filter, IGetVersionsLogger logger) { return(QueryFolder(folder, filter, logger)); }
List <EntityVersion <string, DateTime> > IQueryOutlookDistListItemFolderStrategy.QueryDistListFolder(IOutlookSession session, Folder folder, string expectedFolderId, string filter, IGetVersionsLogger logger) { return(QueryFolder(folder, filter, logger)); }
public Task <IEnumerable <EntityVersion <string, GoogleContactVersion> > > GetAllVersions(IEnumerable <string> idsOfknownEntities, IGoogleContactContext context, IGetVersionsLogger logger) { return(context.ContactCache.GetAllVersions()); }
List <EntityVersion <string, DateTime> > QueryFolder(Folder folder, string filter, IGetVersionsLogger logger) { var versions = new List <EntityVersion <string, DateTime> > (); using (var tableWrapper = GenericComObjectWrapper.Create(folder.GetTable(filter))) { var table = tableWrapper.Inner; table.Columns.RemoveAll(); table.Columns.Add(PR_LONG_TERM_ENTRYID_FROM_TABLE); table.Columns.Add(LastModificationTimeColumnId); while (!table.EndOfTable) { var row = table.GetNextRow(); var entryId = row.BinaryToString(PR_LONG_TERM_ENTRYID_FROM_TABLE); var lastModificationTimeObject = row[LastModificationTimeColumnId]; DateTime lastModificationTime; if (lastModificationTimeObject != null) { lastModificationTime = (DateTime)lastModificationTimeObject; } else { s_logger.Warn($"Column '{nameof(LastModificationTimeColumnId)}' of entity '{entryId}' is NULL."); logger.LogWarning(entryId, $"Column '{nameof(LastModificationTimeColumnId)}' is NULL."); lastModificationTime = OutlookUtility.OUTLOOK_DATE_NONE; } versions.Add(new EntityVersion <string, DateTime> (entryId, lastModificationTime)); } } return(versions); }
public Task <IEnumerable <EntityVersion <string, GoogleContactVersion> > > GetVersions(IEnumerable <IdWithAwarenessLevel <string> > idsOfEntitiesToQuery, IGoogleContactContext context, IGetVersionsLogger logger) { var contacts = new List <EntityVersion <string, GoogleContactVersion> >(); foreach (var id in idsOfEntitiesToQuery) { Contact contact; if (context.ContactCache.TryGetValue(id.Id, out contact)) { contacts.Add(EntityVersion.Create(contact.Id, new GoogleContactVersion { ContactEtag = contact.ETag })); } } return(Task.FromResult <IEnumerable <EntityVersion <string, GoogleContactVersion> > >(contacts)); }
public List <EntityVersion <string, DateTime> > QueryTaskFolder(IOutlookSession session, Folder folder, string filter, IGetVersionsLogger logger) { throw new NotImplementedException(); }
public List <AppointmentSlim> QueryAppointmentFolder(IOutlookSession session, Folder calendarFolder, string filter, IGetVersionsLogger logger) { throw new NotImplementedException(); }
public async Task <(IEntityStateCollection <TEntityId, TEntityVersion> States, TStateToken NewToken)> GetFullRepositoryState(IEnumerable <TEntityId> idsOfknownEntities, TStateToken stateToken, TContext context, IGetVersionsLogger logger) { var repositoryVersions = await _adapted.GetAllVersions(idsOfknownEntities, context, logger); return(VersionAwareEntityStateCollection <TEntityId, TEntityVersion> .Create(repositoryVersions, _idComparer, _versionComparer), default(TStateToken)); }
List <EntityVersion <string, DateTime> > QueryFolder(Folder folder, string filter, IGetVersionsLogger logger) { var versions = new List <EntityVersion <string, DateTime> >(); using (var tableWrapper = GenericComObjectWrapper.Create(folder.GetTable(filter))) { var table = tableWrapper.Inner; table.Columns.RemoveAll(); table.Columns.Add(PR_LONG_TERM_ENTRYID_FROM_TABLE); table.Columns.Add(PR_ENTRYID); table.Columns.Add(LastModificationTimeColumnId); while (!table.EndOfTable) { var row = table.GetNextRow(); string entryId; byte[] entryIdArray = row[PR_LONG_TERM_ENTRYID_FROM_TABLE] as byte[]; if (entryIdArray != null && entryIdArray.Length > 0) { entryId = row.BinaryToString(PR_LONG_TERM_ENTRYID_FROM_TABLE); } else { // Fall back to short-term ENTRYID if long-term ID not available entryId = row.BinaryToString(PR_ENTRYID); s_logger.Warn($"Could not access long-term ENTRYID of entity '{entryId}', use short-term ENTRYID as fallback."); } var lastModificationTimeObject = row[LastModificationTimeColumnId]; DateTime lastModificationTime; if (lastModificationTimeObject != null) { lastModificationTime = ((DateTime)lastModificationTimeObject).ToUniversalTime(); } else { s_logger.Warn($"Column '{nameof(LastModificationTimeColumnId)}' of entity '{entryId}' is NULL."); logger.LogWarning(entryId, $"Column '{nameof(LastModificationTimeColumnId)}' is NULL."); lastModificationTime = OutlookUtility.OUTLOOK_DATE_NONE; } versions.Add(new EntityVersion <string, DateTime>(entryId, lastModificationTime.ToUniversalTime())); } } return(versions); }
public async Task <IEnumerable <EntityVersion <WebResourceName, string> > > GetAllVersions(IEnumerable <WebResourceName> idsOfknownEntities, TContext context, IGetVersionsLogger logger) { var versions = await _decorated.GetAllVersions(idsOfknownEntities, context, logger).ConfigureAwait(false); return((await _typeDetector.GetVCardTypesAndCleanupCache(versions)) .Where(t => t.Type == _typeToFilter) .Select(t => t.Id) .ToArray()); }
List <AppointmentSlim> IQueryOutlookAppointmentItemFolderStrategy.QueryAppointmentFolder(IOutlookSession session, Folder calendarFolder, string filter, IGetVersionsLogger logger) { var events = new List <AppointmentSlim>(); using (var tableWrapper = GenericComObjectWrapper.Create( calendarFolder.GetTable(filter))) { var table = tableWrapper.Inner; table.Columns.RemoveAll(); table.Columns.Add(PR_GLOBAL_OBJECT_ID); table.Columns.Add(PR_LONG_TERM_ENTRYID_FROM_TABLE); table.Columns.Add(PR_ENTRYID); table.Columns.Add(LastModificationTimeColumnId); table.Columns.Add(SubjectColumnId); table.Columns.Add(StartColumnId); table.Columns.Add(EndColumnId); while (!table.EndOfTable) { var row = table.GetNextRow(); string entryId; byte[] entryIdArray = row[PR_LONG_TERM_ENTRYID_FROM_TABLE] as byte[]; if (entryIdArray != null && entryIdArray.Length > 0) { entryId = row.BinaryToString(PR_LONG_TERM_ENTRYID_FROM_TABLE); } else { // Fall back to short-term ENTRYID if long-term ID not available entryId = row.BinaryToString(PR_ENTRYID); s_logger.Warn($"Could not access long-term ENTRYID of appointment '{entryId}', use short-term ENTRYID as fallback."); } string globalAppointmentId = null; try { byte[] globalIdArray = row[PR_GLOBAL_OBJECT_ID] as byte[]; if (globalIdArray != null && globalIdArray.Length > 0) { globalAppointmentId = row.BinaryToString(PR_GLOBAL_OBJECT_ID); } } catch (Exception ex) { s_logger.Warn($"Could not access GlobalAppointmentID of appointment '{entryId}'.", ex); } var subject = (string)row[SubjectColumnId]; var appointmentId = new AppointmentId(entryId, globalAppointmentId); var lastModificationTimeObject = row[LastModificationTimeColumnId]; DateTime lastModificationTime; if (lastModificationTimeObject != null) { lastModificationTime = ((DateTime)lastModificationTimeObject).ToUniversalTime(); } else { s_logger.Warn($"Column '{nameof(LastModificationTimeColumnId)}' of event '{entryId}' is NULL."); logger.LogWarning(entryId, $"Column '{nameof(LastModificationTimeColumnId)}' is NULL."); lastModificationTime = OutlookUtility.OUTLOOK_DATE_NONE; } var startObject = row[StartColumnId]; DateTime?start; if (startObject != null) { start = (DateTime)startObject; } else { s_logger.Warn($"Column '{nameof(StartColumnId)}' of event '{entryId}' is NULL."); logger.LogWarning(entryId, $"Column '{nameof(StartColumnId)}' is NULL."); start = null; } var endObject = row[EndColumnId]; DateTime?end; if (endObject != null) { end = (DateTime)endObject; } else { s_logger.Warn($"Column '{nameof(EndColumnId)}' of event '{entryId}' is NULL."); logger.LogWarning(entryId, $"Column '{nameof(EndColumnId)}' is NULL."); end = null; } events.Add(new AppointmentSlim(EntityVersion.Create(appointmentId, lastModificationTime.ToUniversalTime()), start, end, subject)); } } return(events); }
List <EntityVersion <string, DateTime> > IQueryOutlookTaskItemFolderStrategy.QueryTaskFolder(IOutlookSession session, Folder folder, string filter, IGetVersionsLogger logger) { var tasks = new List <EntityVersion <string, DateTime> > (); using (var tableWrapper = GenericComObjectWrapper.Create( folder.GetTable(filter))) { var table = tableWrapper.Inner; table.Columns.RemoveAll(); table.Columns.Add(c_entryIdColumnName); var storeId = folder.StoreID; while (!table.EndOfTable) { var row = table.GetNextRow(); var entryId = (string)row[c_entryIdColumnName]; try { using (var taskWrapper = GenericComObjectWrapper.Create(session.GetTaskItem(entryId, storeId))) { tasks.Add(new EntityVersion <string, DateTime> (taskWrapper.Inner.EntryID, taskWrapper.Inner.LastModificationTime)); } } catch (COMException ex) { s_logger.Error("Could not fetch TaskItem, skipping.", ex); } } } return(tasks); }
public Task <IEnumerable <EntityVersion <AppointmentId, DateTime> > > GetVersions(IEnumerable <IdWithAwarenessLevel <AppointmentId> > idsOfEntitiesToQuery, IEventSynchronizationContext context, IGetVersionsLogger logger) { var result = new List <EntityVersion <AppointmentId, DateTime> >(); foreach (var id in idsOfEntitiesToQuery) { var appointment = _session.GetAppointmentItemOrNull(id.Id.EntryId, _folderId, _folderStoreId); if (appointment != null) { try { if (_configuration.IsCategoryFilterSticky && id.IsKnown || DoesMatchCategoryCriterion(appointment)) { result.Add(EntityVersion.Create(id.Id, appointment.LastModificationTime)); context.DuplicateEventCleaner.AnnounceAppointment(AppointmentSlim.FromAppointmentItem(appointment)); } } finally { Marshal.FinalReleaseComObject(appointment); } } } return(Task.FromResult <IEnumerable <EntityVersion <AppointmentId, DateTime> > > (result)); }
List <EntityVersion <string, DateTime> > IQueryOutlookContactItemFolderStrategy.QueryContactItemFolder(IOutlookSession session, Folder folder, string expectedFolderId, string filter, IGetVersionsLogger logger) { var contacts = new List <EntityVersion <string, DateTime> > (); using (var tableWrapper = GenericComObjectWrapper.Create(folder.GetTable(filter))) { var table = tableWrapper.Inner; table.Columns.RemoveAll(); table.Columns.Add(c_entryIdColumnName); var storeId = folder.StoreID; while (!table.EndOfTable) { var row = table.GetNextRow(); var entryId = (string)row[c_entryIdColumnName]; var contact = session.GetContactItemOrNull(entryId, expectedFolderId, storeId); if (contact != null) { using (var contactWrapper = GenericComObjectWrapper.Create(contact)) { contacts.Add(new EntityVersion <string, DateTime> (contactWrapper.Inner.EntryID, contactWrapper.Inner.LastModificationTime)); } } } } return(contacts); }
public async Task <IEnumerable <EntityVersion <AppointmentId, DateTime> > > GetAllVersions(IEnumerable <AppointmentId> idsOfknownEntities, IEventSynchronizationContext context, IGetVersionsLogger logger) { var all = await GetAll(idsOfknownEntities, context, logger); foreach (var appointment in all) { context.DuplicateEventCleaner.AnnounceAppointment(appointment); } return(all.Select(a => a.Version).ToList()); }
public Task <IEnumerable <EntityVersion <string, DateTime> > > GetVersions(IEnumerable <IdWithAwarenessLevel <string> > idsOfEntitiesToQuery, int context, IGetVersionsLogger logger) { var result = new List <EntityVersion <string, DateTime> >(); foreach (var id in idsOfEntitiesToQuery) { var task = _session.GetTaskItemOrNull(id.Id, _folderId, _folderStoreId); if (task != null) { try { if (_configuration.IsCategoryFilterSticky && id.IsKnown || DoesMatchCategoryCriterion(task)) { result.Add(EntityVersion.Create(id.Id, task.LastModificationTime.ToUniversalTime())); } } finally { Marshal.FinalReleaseComObject(task); } } } return(Task.FromResult <IEnumerable <EntityVersion <string, DateTime> > > (result)); }
private Task <IReadOnlyList <AppointmentSlim> > GetAll(IEnumerable <AppointmentId> idsOfknownEntities, IEventSynchronizationContext context, IGetVersionsLogger logger) { var range = _dateTimeRangeProvider.GetRange(); List <AppointmentSlim> events; using (var calendarFolderWrapper = CreateFolderWrapper()) { bool isInstantSearchEnabled = false; try { using (var store = GenericComObjectWrapper.Create(calendarFolderWrapper.Inner.Store)) { if (store.Inner != null) { isInstantSearchEnabled = store.Inner.IsInstantSearchEnabled; } } } catch (COMException) { s_logger.Info("Can't access IsInstantSearchEnabled property of store, defaulting to false."); } // Table Filtering in the MSDN: https://msdn.microsoft.com/EN-US/library/office/ff867581.aspx var filterBuilder = new StringBuilder(_daslFilterProvider.GetAppointmentFilter(isInstantSearchEnabled)); if (range.HasValue) { filterBuilder.AppendFormat(" And \"urn:schemas:calendar:dtstart\" < '{0}' And \"urn:schemas:calendar:dtend\" > '{1}'", ToOutlookDateString(range.Value.To), ToOutlookDateString(range.Value.From)); } if (_configuration.UseEventCategoryAsFilter) { AddCategoryFilter(filterBuilder, _configuration.EventCategory, _configuration.InvertEventCategoryFilter, _configuration.IncludeEmptyEventCategoryFilter); } s_logger.DebugFormat("Using Outlook DASL filter: {0}", filterBuilder.ToString()); events = _queryFolderStrategy.QueryAppointmentFolder(_session, calendarFolderWrapper.Inner, filterBuilder.ToString(), logger); } if (_configuration.IsCategoryFilterSticky && _configuration.UseEventCategoryAsFilter) { var knownEntitesThatWereFilteredOut = idsOfknownEntities.Except(events.Select(e => e.Version.Id)); events.AddRange( knownEntitesThatWereFilteredOut .Select(id => _session.GetAppointmentItemOrNull(id.EntryId, _folderId, _folderStoreId)) .Where(i => i != null) .ToSafeEnumerable() .Select(AppointmentSlim.FromAppointmentItem)); } return(Task.FromResult <IReadOnlyList <AppointmentSlim> > (events)); }
public async Task <IEnumerable <EntityVersion <string, string> > > GetAllVersions(IEnumerable <string> idsOfknownEntities, int context, IGetVersionsLogger logger) { var request = _tasksService.Tasks.List(_taskList.Id); request.Fields = "items(etag,id),nextPageToken"; var tasks = new List <EntityVersion <string, string> >(); Google.Apis.Tasks.v1.Data.Tasks result = null; do { request.PageToken = result?.NextPageToken; result = await request.ExecuteAsync(); if (result.Items != null) { tasks.AddRange(result.Items.Select(t => EntityVersion.Create(t.Id, t.ETag))); } } while (result.NextPageToken != null); return(tasks); }
public Task <(string SyncToken, IReadOnlyList <(WebResourceName Id, string Version)> ChangedOrAddedItems, IReadOnlyList <WebResourceName> DeletedItems)> CollectionSync(string syncTokenOrNull, IGetVersionsLogger logger) { throw new NotSupportedException(); }
public async Task <IEnumerable <EntityVersion <WebResourceName, string> > > GetVersions(IEnumerable <IdWithAwarenessLevel <WebResourceName> > idsOfEntitiesToQuery, ICardDavRepositoryLogger context, IGetVersionsLogger logger) { var result = await _inner.GetVersions(idsOfEntitiesToQuery, 0, logger); context.LogEntitiesExists(result.Select(e => e.Id)); return(result); }
public async Task <(IEntityStateCollection <WebResourceName, string> States, string NewToken)> GetFullRepositoryState(IEnumerable <WebResourceName> idsOfknownEntities, string stateToken, ICardDavRepositoryLogger context, IGetVersionsLogger logger) { var result = await _inner.GetFullRepositoryState(idsOfknownEntities, stateToken, 0, logger); return(new LoggingEntityStateCollectionDecorator(result.States, context), result.NewToken); }
public Task <IEnumerable <EntityVersion <string, DateTime> > > GetVersions(IEnumerable <IdWithAwarenessLevel <string> > idsOfEntitiesToQuery, Tcontext context, IGetVersionsLogger logger) { return(Task.FromResult <IEnumerable <EntityVersion <string, DateTime> > >( idsOfEntitiesToQuery .Select(id => _session.GetContactItemOrNull(id.Id, _folderId, _folderStoreId)) .Where(e => e != null) .ToSafeEnumerable() .Select(c => EntityVersion.Create(c.EntryID, c.LastModificationTime.ToUniversalTime())) .ToList())); }
public Task <IEnumerable <EntityVersion <Identifier, int> > > GetVersions(IEnumerable <IdWithAwarenessLevel <Identifier> > idsOfEntitiesToQuery, int context, IGetVersionsLogger logger) { List <EntityVersion <Identifier, int> > result = new List <EntityVersion <Identifier, int> >(); foreach (var id in idsOfEntitiesToQuery) { Tuple <int, string> versionAndContent; if (EntityVersionAndContentById.TryGetValue(id.Id, out versionAndContent)) { result.Add(EntityVersion.Create(id.Id, versionAndContent.Item1)); } } return(Task.FromResult <IEnumerable <EntityVersion <Identifier, int> > >(result)); }