Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
 public async Task <IReadOnlyList <EntityIdWithVersion <Uri, string> > > GetVersions()
 {
     using (AutomaticStopwatch.StartInfo(s_logger, "CardDavRepository.GetVersions"))
     {
         return(await _cardDavDataAccess.GetContacts());
     }
 }
        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 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;
            }
        }
        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);
            }
        }
Exemplo n.º 6
0
 public async Task <IReadOnlyList <EntityVersion <Uri, string> > > GetAllVersions(IEnumerable <Uri> idsOfknownEntities)
 {
     using (AutomaticStopwatch.StartInfo(s_logger, "CardDavRepository.GetVersions"))
     {
         return(await _cardDavDataAccess.GetContacts());
     }
 }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        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;
            }
        }
Exemplo n.º 9
0
 public async Task <IEnumerable <EntityVersion <WebResourceName, string> > > GetAllVersions(IEnumerable <WebResourceName> idsOfknownEntities, TContext context)
 {
     using (AutomaticStopwatch.StartInfo(s_logger, "CardDavRepository.GetVersions"))
     {
         return(await _cardDavDataAccess.GetAllVersions());
     }
 }
Exemplo n.º 10
0
        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));
            }
        }
Exemplo n.º 11
0
        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));
            }
        }
Exemplo n.º 12
0
        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));
            }
        }
Exemplo n.º 13
0
        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));
                }
            }
        }
Exemplo n.º 14
0
        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);
                }
            }));
        }
Exemplo n.º 15
0
        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));
                }
            }
        }
        private async Task RunIfResponsibleNoThrow(IEnumerable <string> itemsToSync)
        {
            try
            {
                var logger = new SynchronizationLogger(_profileId, _profileName);

                using (AutomaticStopwatch.StartInfo(s_logger, string.Format("Running synchronization profile '{0}'", _profileName)))
                {
                    await _synchronizer.SnychronizePartialNoThrow(itemsToSync, logger);
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                var synchronizationReport = logger.GetReport();
                _synchronizationReportRepository.AddReport(synchronizationReport);
            }
            catch (Exception x)
            {
                ExceptionHandler.Instance.HandleException(x, s_logger);
            }
        }
        private async Task RunPartialNoThrow(IIdWithHints <string, DateTime>[] itemsToSync)
        {
            try
            {
                var logger = new SynchronizationLogger(_profileId, _profileName);

                using (AutomaticStopwatch.StartInfo(s_logger, string.Format("Partial sync: Running synchronization profile '{0}'", _profileName)))
                {
                    await _synchronizer.SnychronizePartialNoThrow(itemsToSync, logger);
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                var synchronizationReport = logger.GetReport();
                _reportSink.PostReport(synchronizationReport);
            }
            catch (Exception x)
            {
                s_logger.Error(null, x);
            }
        }