public async Task <IEnumerable <EntityVersion <WebResourceName, string> > > GetAllVersions(IEnumerable <WebResourceName> idsOfknownEntities, TContext context) { using (AutomaticStopwatch.StartInfo(s_logger, "CardDavRepository.GetVersions")) { return(await _cardDavDataAccess.GetAllVersions()); } }
private async Task RunAndRescheduleNoThrow() { try { var logger = new SynchronizationLogger(_profileId, _profileName); using (AutomaticStopwatch.StartInfo(s_logger, string.Format("Running synchronization profile '{0}'", _profileName))) { await _synchronizer.SynchronizeNoThrow(logger); } GC.Collect(); GC.WaitForPendingFinalizers(); var synchronizationReport = logger.GetReport(); _synchronizationReportRepository.AddReport(synchronizationReport); } catch (Exception x) { ExceptionHandler.Instance.HandleException(x, s_logger); } finally { _lastRun = DateTime.UtcNow; } }
private async Task RunPartialNoThrow(IOutlookId[] itemsToSync) { try { using (var logger = new SynchronizationLogger(_profileId, _profileName, _reportSink)) { using (AutomaticStopwatch.StartInfo(s_logger, string.Format("Partial sync: Running synchronization profile '{0}'", _profileName))) { try { await _synchronizer.SynchronizePartial(itemsToSync, logger); } catch (Exception x) { logger.LogAbortedDueToError(x); ExceptionHandler.Instance.LogException(x, s_logger); } } GC.Collect(); GC.WaitForPendingFinalizers(); } } catch (Exception x) { s_logger.Error(null, x); } }
public async Task <bool> TryDelete(WebResourceName entityId, string version, TContext context) { using (AutomaticStopwatch.StartDebug(s_logger)) { return(await _cardDavDataAccess.TryDeleteEntity(entityId, version)); } }
public async Task <IReadOnlyList <EntityIdWithVersion <Uri, string> > > GetVersions() { using (AutomaticStopwatch.StartInfo(s_logger, "CardDavRepository.GetVersions")) { return(await _cardDavDataAccess.GetContacts()); } }
private async Task RunAndRescheduleNoThrow() { try { using (var logger = new SynchronizationLogger(_profileId, _profileName, _reportSink)) { using (AutomaticStopwatch.StartInfo(s_logger, string.Format("Running synchronization profile '{0}'", _profileName))) { try { await _synchronizer.Synchronize(logger); } catch (Exception x) { logger.LogAbortedDueToError(x); ExceptionHandler.Instance.LogException(x, s_logger); } } GC.Collect(); GC.WaitForPendingFinalizers(); } } catch (Exception x) { s_logger.Error(null, x); } finally { _lastRun = DateTime.UtcNow; } }
public Task Delete(Uri entityId) { using (AutomaticStopwatch.StartDebug(s_logger)) { return(_cardDavDataAccess.DeleteEntity(entityId)); } }
public Task Delete(Uri entityId, string version) { using (AutomaticStopwatch.StartDebug(s_logger)) { return(_calDavDataAccess.DeleteEntity(entityId, version)); } }
private async Task RunPartialNoThrow(IOutlookId[] itemsToSync) { try { using (var logger = new SynchronizationLogger(_profileId, _profile.ProfileName, _reportSink, _profile.IncludeEntityReportsWithoutErrorsOrWarnings)) { using (AutomaticStopwatch.StartInfo(s_logger, string.Format("Partial sync: Running synchronization profile '{0}'", _profile.ProfileName))) { try { await _profile.Synchronizer.SynchronizePartial(itemsToSync, logger); } catch (Exception x) { _errorHandlingStrategy.HandleException(x, logger); } } GC.Collect(); GC.WaitForPendingFinalizers(); } } catch (Exception x) { s_logger.Error(null, x); } }
public async Task Delete(WebResourceName entityId, string version) { using (AutomaticStopwatch.StartDebug(s_logger)) { await _calDavDataAccess.DeleteEntity(entityId, version); } }
public async Task RunNoThrowAndReschedule() { if (_inactive) { return; } try { using (AutomaticStopwatch.StartInfo(s_logger, string.Format("Running synchronization profile '{0}'", _profileName))) { try { await _synchronizer.Synchronize(); } finally { GC.Collect(); GC.WaitForPendingFinalizers(); } } } catch (Exception x) { ExceptionHandler.Instance.HandleException(x, s_logger); } finally { _lastRun = DateTime.UtcNow; } }
private async Task RunAndRescheduleNoThrow() { try { using (var logger = new SynchronizationLogger(_profileId, _profile.ProfileName, _reportSink, _profile.IncludeEntityReportsWithoutErrorsOrWarnings)) { using (AutomaticStopwatch.StartInfo(s_logger, string.Format("Running synchronization profile '{0}'", _profile.ProfileName))) { try { await _profile.Synchronizer.Synchronize(logger); } catch (Exception x) { _errorHandlingStrategy.HandleException(x, logger); } } GC.Collect(); GC.WaitForPendingFinalizers(); } } catch (Exception x) { s_logger.Error(null, x); } finally { _lastRun = _dateTimeProvider.Now; } }
public async Task <IReadOnlyList <EntityVersion <Uri, string> > > GetAllVersions(IEnumerable <Uri> idsOfknownEntities) { using (AutomaticStopwatch.StartInfo(s_logger, "CardDavRepository.GetVersions")) { return(await _cardDavDataAccess.GetContacts()); } }
public EntityIdWithVersion <Uri, string> Update(Uri entityId, IICalendar entityToUpdate, Func <IICalendar, IICalendar> entityModifier) { using (AutomaticStopwatch.StartDebug(s_logger)) { IICalendar newCalendar = new iCalendar(); newCalendar = entityModifier(newCalendar); if (entityToUpdate.Events.Count > 0) { for (int i = 0, newSequenceNumber = entityToUpdate.Events.Max(e => e.Sequence) + 1; i < newCalendar.Events.Count; i++, newSequenceNumber++) { newCalendar.Events[i].Sequence = newSequenceNumber; } } if (entityToUpdate.Todos.Count > 0) { for (int i = 0, newSequenceNumber = entityToUpdate.Todos.Max(e => e.Sequence) + 1; i < newCalendar.Todos.Count; i++, newSequenceNumber++) { newCalendar.Todos[i].Sequence = newSequenceNumber; } } return(_calDavDataAccess.UpdateEntity(entityId, SerializeCalendar(newCalendar))); } }
public Task <EntityIdWithVersion <Uri, string> > Update(Uri entityId, IICalendar entityToUpdate, Func <IICalendar, IICalendar> entityModifier) { using (AutomaticStopwatch.StartDebug(s_logger)) { var updatedEntity = entityModifier(entityToUpdate); return(_calDavDataAccess.UpdateEntity(entityId, SerializeCalendar(updatedEntity))); } }
public async Task <EntityIdWithVersion <Uri, string> > Create(Func <vCard, vCard> entityInitializer) { using (AutomaticStopwatch.StartDebug(s_logger)) { vCard newVcard = new vCard(); var initializedVcard = entityInitializer(newVcard); return(await _cardDavDataAccess.CreateEntity(Serialize (initializedVcard))); } }
public async Task <EntityIdWithVersion <Uri, string> > Create(Func <IICalendar, IICalendar> entityInitializer) { using (AutomaticStopwatch.StartDebug(s_logger)) { IICalendar newCalendar = new iCalendar(); newCalendar = entityInitializer(newCalendar); return(await _calDavDataAccess.CreateEntity(SerializeCalendar (newCalendar))); } }
public async Task <EntityVersion <WebResourceName, string> > Create(Func <IICalendar, IICalendar> entityInitializer) { using (AutomaticStopwatch.StartDebug(s_logger)) { IICalendar newCalendar = new iCalendar(); newCalendar = entityInitializer(newCalendar); var uid = (newCalendar.Events.Count > 0) ? newCalendar.Events[0].UID : newCalendar.Todos[0].UID; return(await _calDavDataAccess.CreateEntity(SerializeCalendar (newCalendar), uid)); } }
public async Task <EntityVersion <WebResourceName, string> > Create(Func <vCard, vCard> entityInitializer) { using (AutomaticStopwatch.StartDebug(s_logger)) { vCard newVcard = new vCard(); newVcard.UniqueId = Guid.NewGuid().ToString(); var initializedVcard = entityInitializer(newVcard); return(await _cardDavDataAccess.CreateEntity(Serialize (initializedVcard), newVcard.UniqueId)); } }
public Task <EntityIdWithVersion <Uri, string> > Update(Uri entityId, vCard entityToUpdate, Func <vCard, vCard> entityModifier) { using (AutomaticStopwatch.StartDebug(s_logger)) { vCard newVcard = new vCard(); newVcard.UniqueId = entityToUpdate.UniqueId; newVcard = entityModifier(newVcard); return(_cardDavDataAccess.UpdateEntity(entityId, Serialize(newVcard))); } }
public async Task <EntityVersion <WebResourceName, string> > Create(Func <TEntity, Task <TEntity> > entityInitializer, TContext context) { using (AutomaticStopwatch.StartDebug(s_logger)) { TEntity newEntity = new TEntity(); var uid = Guid.NewGuid().ToString(); SetUid(newEntity, uid); var initializedVcard = await entityInitializer(newEntity); return(await _cardDavDataAccess.CreateEntity(Serialize(initializedVcard), uid)); } }
public async Task <IReadOnlyList <EntityWithVersion <Uri, vCard> > > Get(ICollection <Uri> ids) { if (ids.Count == 0) { return new EntityWithVersion <Uri, vCard>[] { } } ; using (AutomaticStopwatch.StartInfo(s_logger, string.Format("CardDavRepository.Get ({0} entitie(s))", ids.Count))) { var entities = await _cardDavDataAccess.GetEntities(ids); return(ParallelDeserialize(entities)); } }
public Task <EntityVersion <Uri, string> > Update( Uri entityId, string entityVersion, vCard entityToUpdate, Func <vCard, vCard> entityModifier) { using (AutomaticStopwatch.StartDebug(s_logger)) { vCard newVcard = new vCard(); newVcard.UniqueId = (!string.IsNullOrEmpty(entityToUpdate.UniqueId)) ? entityToUpdate.UniqueId : Guid.NewGuid().ToString(); newVcard = entityModifier(newVcard); return(_cardDavDataAccess.UpdateEntity(entityId, entityVersion, Serialize(newVcard))); } }
public async Task <IEnumerable <EntityWithId <WebResourceName, TEntity> > > Get(ICollection <WebResourceName> ids, ILoadEntityLogger logger, TContext context) { if (ids.Count == 0) { return new EntityWithId <WebResourceName, TEntity>[] { } } ; using (AutomaticStopwatch.StartInfo(s_logger, string.Format("CardDavRepository.Get ({0} entitie(s))", ids.Count))) { var entities = await _cardDavDataAccess.GetEntities(ids); return(ParallelDeserialize(entities, logger)); } }
public async Task <IReadOnlyList <EntityWithId <WebResourceName, IICalendar> > > Get(ICollection <WebResourceName> ids, ILoadEntityLogger logger) { if (ids.Count == 0) { return new EntityWithId <WebResourceName, IICalendar>[] { } } ; using (AutomaticStopwatch.StartInfo(s_logger, string.Format("CalDavRepository.Get ({0} entitie(s))", ids.Count))) { var entities = await _calDavDataAccess.GetEntities(ids); return(await ParallelDeserialize(entities, logger)); } }
public async Task <EntityVersion <WebResourceName, string> > TryUpdate( WebResourceName entityId, string entityVersion, vCard entityToUpdate, Func <vCard, Task <vCard> > entityModifier, int context) { using (AutomaticStopwatch.StartDebug(s_logger)) { vCard newVcard = new vCard(); newVcard.UniqueId = (!string.IsNullOrEmpty(entityToUpdate.UniqueId)) ? entityToUpdate.UniqueId : Guid.NewGuid().ToString(); newVcard = await entityModifier(newVcard); return(await _cardDavDataAccess.TryUpdateEntity(entityId, entityVersion, Serialize (newVcard))); } }
public IReadOnlyList <EntityIdWithVersion <Uri, string> > GetVersions(DateTime from, DateTime to) { using (AutomaticStopwatch.StartInfo(s_logger, "CalDavRepository.GetVersions")) { switch (_entityType) { case EntityType.Event: return(_calDavDataAccess.GetEvents(from, to)); case EntityType.Todo: return(_calDavDataAccess.GetTodos(from, to)); default: throw new NotImplementedException(string.Format("EntityType '{0}' not implemented.", _entityType)); } } }
public Task <IReadOnlyList <EntityWithVersion <Uri, IICalendar> > > Get(ICollection <Uri> ids) { return(Task.Factory.StartNew(() => { if (ids.Count == 0) { return new EntityWithVersion <Uri, IICalendar>[] {} } ; using (AutomaticStopwatch.StartInfo(s_logger, string.Format("CalDavRepository.Get ({0} entitie(s))", ids.Count))) { var entities = _calDavDataAccess.GetEntities(ids); return ParallelDeserialize(entities); } })); }
public async Task <IReadOnlyList <EntityVersion <WebResourceName, string> > > GetAllVersions(IEnumerable <WebResourceName> idsOfknownEntities) { using (AutomaticStopwatch.StartInfo(s_logger, "CalDavRepository.GetVersions")) { switch (_entityType) { case EntityType.Event: return(await _calDavDataAccess.GetEventVersions(_dateTimeRangeProvider.GetRange())); case EntityType.Todo: return(await _calDavDataAccess.GetTodoVersions(_dateTimeRangeProvider.GetRange())); default: throw new NotImplementedException(string.Format("EntityType '{0}' not implemented.", _entityType)); } } }
public async Task <EntityVersion <WebResourceName, string> > TryUpdate( WebResourceName entityId, string entityVersion, TEntity entityToUpdate, Func <TEntity, Task <TEntity> > entityModifier, TContext context) { using (AutomaticStopwatch.StartDebug(s_logger)) { var updatedEntity = await entityModifier(entityToUpdate); if (string.IsNullOrEmpty(GetUid(updatedEntity))) { SetUid(updatedEntity, Guid.NewGuid().ToString()); } return(await _cardDavDataAccess.TryUpdateEntity(entityId, entityVersion, Serialize (updatedEntity))); } }